From 3f3c57193f5c0ba295a5be1c2affd4f34d24137f Mon Sep 17 00:00:00 2001 From: John Derek Chapman <chapman@hep.phy.cam.ac.uk> Date: Fri, 19 May 2017 12:43:18 +0000 Subject: [PATCH] Backport LArG4 Calculator Updates from master to 21.0 Former-commit-id: 5bee4643ada1f4e295466fc80889a4ebd0e3d704 --- .../CaloG4Sim/CalibrationDefaultProcessing.h | 2 +- .../CaloG4Sim/CaloG4Sim/SimulationEnergies.h | 40 +- .../src/CalibrationDefaultProcessing.cc | 2 +- .../CaloG4Sim/src/SimulationEnergies.cc | 96 +- .../GeoModel/GeoSpecialShapes/CMakeLists.txt | 11 +- .../GeoSpecialShapes/LArCustomShape.h | 3 +- .../GeoSpecialShapes/LArWheelCalculator.h | 25 +- .../LArWheelCalculatorEnums.h | 25 + .../GeoSpecialShapes/selectionEnums.xml | 8 + .../GeoSpecialShapes/cmt/requirements | 2 + .../GeoSpecialShapes/src/LArCustomShape.cxx | 100 +- .../src/LArWheelCalculator.cxx | 280 +- .../DistanceCalculatorSaggingOn.cxx | 10 +- .../LArG4/LArG4Barrel/CMakeLists.txt | 12 +- LArCalorimeter/LArG4/LArG4Barrel/GNUmakefile | 27 - .../LArG4/LArG4Barrel/LArG4Barrel/AccMap.h | 56 - .../LArG4/LArG4Barrel/LArG4Barrel/CurrMap.h | 37 - .../LArG4Barrel/LArBarrelCalculator.h | 151 - .../LArG4Barrel/LArBarrelGeometry.h | 183 - .../LArBarrelPresamplerCalculator.h | 114 - .../LArG4Barrel/LArBarrelPresamplerGeometry.h | 96 - .../LArG4Barrel/LArCoudeAbsorbers.h | 28 - .../LArG4Barrel/LArCoudeElectrodes.h | 28 - .../LArG4/LArG4Barrel/LArG4Barrel/LArCoudes.h | 19 - .../LArG4Barrel/LArStraightAbsorbers.h | 34 - .../LArG4Barrel/LArStraightElectrodes.h | 34 - .../LArG4/LArG4Barrel/cmt/requirements | 31 - .../LArG4Barrel/python/LArG4BarrelConfig.py | 33 + .../LArG4Barrel/python/LArG4BarrelConfigDb.py | 15 + .../LArG4/LArG4Barrel/src/AccMap.cc | 156 - .../LArG4/LArG4Barrel/src/AccMap.cxx | 141 + LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.h | 48 + .../src/CryostatCalibrationCalculator.cc | 675 --- .../src/CryostatCalibrationCalculator.cxx | 676 +++ .../CryostatCalibrationCalculator.h | 33 +- .../src/CryostatCalibrationLArCalculator.cc | 309 -- .../src/CryostatCalibrationLArCalculator.cxx | 310 ++ .../CryostatCalibrationLArCalculator.h | 34 +- .../src/CryostatCalibrationMixedCalculator.cc | 253 - .../CryostatCalibrationMixedCalculator.cxx | 252 + .../CryostatCalibrationMixedCalculator.h | 39 +- .../LArG4/LArG4Barrel/src/CurrMap.cc | 192 - .../LArG4/LArG4Barrel/src/CurrMap.cxx | 192 + .../LArG4/LArG4Barrel/src/CurrMap.h | 37 + .../src/DMCalibrationCalculator.cc | 166 - .../src/DMCalibrationCalculator.cxx | 164 + .../DMCalibrationCalculator.h | 28 +- .../LArG4Barrel/src/ILArBarrelGeometry.h | 69 + .../src/ILArBarrelPresamplerGeometry.h | 60 + .../LArG4Barrel/src/LArBarrelCalculator.cc | 794 ---- .../LArG4Barrel/src/LArBarrelCalculator.cxx | 761 +++ .../LArG4Barrel/src/LArBarrelCalculator.h | 106 + .../src/LArBarrelCalibrationCalculator.cc | 104 - .../src/LArBarrelCalibrationCalculator.cxx | 107 + .../LArBarrelCalibrationCalculator.h | 45 +- .../LArG4Barrel/src/LArBarrelGeometry.cc | 1402 ------ .../LArG4Barrel/src/LArBarrelGeometry.cxx | 1371 ++++++ .../LArG4/LArG4Barrel/src/LArBarrelGeometry.h | 143 + .../src/LArBarrelPresamplerCalculator.cc | 392 -- .../src/LArBarrelPresamplerCalculator.cxx | 369 ++ .../src/LArBarrelPresamplerCalculator.h | 69 + .../src/LArBarrelPresamplerGeometry.cc | 519 --- .../src/LArBarrelPresamplerGeometry.cxx | 483 ++ .../src/LArBarrelPresamplerGeometry.h | 88 + .../LArG4Barrel/src/LArCoudeAbsorbers.cc | 99 - .../LArG4Barrel/src/LArCoudeAbsorbers.cxx | 99 + .../LArG4/LArG4Barrel/src/LArCoudeAbsorbers.h | 28 + .../LArG4Barrel/src/LArCoudeElectrodes.cc | 100 - .../LArG4Barrel/src/LArCoudeElectrodes.cxx | 100 + .../LArG4Barrel/src/LArCoudeElectrodes.h | 28 + .../LArG4/LArG4Barrel/src/LArCoudes.cc | 44 - .../LArG4/LArG4Barrel/src/LArCoudes.cxx | 44 + .../LArG4/LArG4Barrel/src/LArCoudes.h | 19 + .../LArG4Barrel/src/LArStraightAbsorbers.cc | 165 - .../LArG4Barrel/src/LArStraightAbsorbers.cxx | 164 + .../LArG4Barrel/src/LArStraightAbsorbers.h | 34 + .../LArG4Barrel/src/LArStraightElectrodes.cc | 164 - .../LArG4Barrel/src/LArStraightElectrodes.cxx | 163 + .../LArG4Barrel/src/LArStraightElectrodes.h | 34 + .../LArG4/LArG4Barrel/src/MapEta.cc | 204 - .../LArG4/LArG4Barrel/src/MapEta.cxx | 204 + .../LArG4Barrel/{LArG4Barrel => src}/MapEta.h | 24 +- .../LArG4Barrel/src/PhysicalVolumeAccessor.cc | 67 - .../src/PhysicalVolumeAccessor.cxx | 68 + .../PhysicalVolumeAccessor.h | 14 +- .../{LArG4Barrel => src}/PresParameterDef.h | 0 .../src/PresamplerCalibrationCalculator.cc | 104 - .../src/PresamplerCalibrationCalculator.cxx | 108 + .../PresamplerCalibrationCalculator.h | 43 +- LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cc | 83 - .../LArG4/LArG4Barrel/src/PsMap.cxx | 83 + .../LArG4Barrel/{LArG4Barrel => src}/PsMap.h | 10 +- .../src/components/LArG4Barrel_entries.cxx | 23 + LArCalorimeter/LArG4/LArG4Code/CMakeLists.txt | 15 +- .../LArG4/LArG4Code/LArG4Code/CalibSDTool.h | 90 + .../LArG4Code/LArG4Code/ILArCalculatorSvc.h | 48 + .../LArG4Code/ILArCalibCalculatorSvc.h | 43 + .../LArG4Code/LArG4Code/LArCalculatorSvcImp.h | 32 + .../LArG4Code/LArCalibCalculatorSvcImp.h | 20 + .../LArG4/LArG4Code/LArG4Code/LArG4CalibSD.h | 7 +- .../LArG4Code/LArG4DetectorComponents.h | 73 - .../LArG4/LArG4Code/LArG4Code/LArG4EnumDefs.h | 26 + .../LArG4/LArG4Code/LArG4Code/LArG4SDTool.h | 2 + .../LArG4/LArG4Code/LArG4Code/LArG4SimpleSD.h | 6 +- .../LArG4/LArG4Code/LArG4Code/LArHitMaker.h | 41 - .../LArG4Code/LArG4Code/LArVCalculator.h | 74 - .../LArG4Code/LArG4Code/LArVolumeInterface.h | 36 - .../LArG4/LArG4Code/LArG4Code/OptionsStore.h | 116 - .../LArG4/LArG4Code/LArG4Code/RunOptions.h | 71 - .../LArG4/LArG4Code/LArG4Code/SDWrapper.h | 106 + .../LArG4/LArG4Code/LArG4Code/SimpleSDTool.h | 95 + .../LArG4Code/VCalibrationCalculator.h | 59 - .../LArG4/LArG4Code/LArG4Code/VolumeUtils.h | 49 + .../LArG4Code/LArG4Code/selectionEnums.xml | 7 + .../LArG4/LArG4Code/cmt/requirements | 33 +- .../LArG4/LArG4Code/src/CalibSDTool.cc | 119 + .../src/CalibrationDefaultCalculator.cc | 319 -- .../LArG4/LArG4Code/src/CalibrationHit.cc | 2 +- .../LArG4Code/src/EscapedEnergyProcessing.cc | 2 +- .../LArG4Code/src/LArCalculatorSvcImp.cxx | 30 + .../src/LArCalibCalculatorSvcImp.cxx | 22 + .../LArG4/LArG4Code/src/LArG4CalibSD.cc | 18 +- .../LArG4Code/src/LArG4DetectorComponents.cc | 51 - .../LArG4/LArG4Code/src/LArG4SDTool.cc | 35 +- .../LArG4/LArG4Code/src/LArG4SimpleSD.cc | 24 +- .../LArG4/LArG4Code/src/LArHitMaker.cc | 168 - .../LArG4/LArG4Code/src/SDWrapper.cc | 133 + .../LArG4/LArG4Code/src/SimpleSDTool.cc | 122 + .../LArG4/LArG4Code/src/VolumeUtils.cc | 86 + LArCalorimeter/LArG4/LArG4EC/CMakeLists.txt | 12 +- .../LArG4/LArG4EC/LArG4EC/EnergyCalculator.h | 364 -- .../LArG4EC/LArG4EC/IECPresamplerGeometry.h | 36 + .../LArG4EC/LArEndcapPresamplerCalculator.h | 101 - .../LArG4EC/LArG4EC/PresamplerGeometry.h | 38 +- LArCalorimeter/LArG4/LArG4EC/cmt/requirements | 22 +- .../LArG4/LArG4EC/python/LArG4ECConfig.py | 112 + .../LArG4/LArG4EC/python/LArG4ECConfigDb.py | 28 + .../LArG4EC/python/LArWheelCalculatorEnum.py | 24 + .../LArG4EC/src/CalibrationCalculator.cc | 125 +- .../{LArG4EC => src}/CalibrationCalculator.h | 32 +- .../src/CryostatCalibrationCalculator.cc | 775 ++-- .../CryostatCalibrationCalculator.h | 31 +- .../src/CryostatCalibrationLArCalculator.cc | 672 ++- .../CryostatCalibrationLArCalculator.h | 49 +- .../src/CryostatCalibrationMixedCalculator.cc | 673 +-- .../CryostatCalibrationMixedCalculator.h | 31 +- .../src/EMECSupportCalibrationCalculator.cc | 98 +- .../EMECSupportCalibrationCalculator.h | 31 +- .../LArG4/LArG4EC/src/EnergyCalculator.cc | 4092 ++++++++--------- .../LArG4/LArG4EC/src/EnergyCalculator.h | 391 ++ .../LArG4/LArG4EC/src/GetCurrent1.cc | 683 ++- .../LArG4EC/src/LArEMECChargeCollection.cc | 2196 +++++---- .../src/LArEndcapPresamplerCalculator.cc | 105 +- .../src/LArEndcapPresamplerCalculator.h | 61 + .../src/PresamplerCalibrationCalculator.cc | 69 +- .../PresamplerCalibrationCalculator.h | 34 +- .../LArG4/LArG4EC/src/PresamplerGeometry.cc | 208 +- .../src/components/LArG4EC_entries.cxx | 21 + LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt | 10 +- LArCalorimeter/LArG4/LArG4FCAL/GNUmakefile | 0 .../LArG4FCAL/LArG4FCAL/LArFCAL1Calculator.h | 38 - .../LArG4FCAL/LArFCAL1CalibCalculator.h | 40 - .../LArG4FCAL/LArG4FCAL/LArFCAL2Calculator.h | 38 - .../LArG4FCAL/LArFCAL2CalibCalculator.h | 40 - .../LArG4FCAL/LArG4FCAL/LArFCAL3Calculator.h | 38 - .../LArG4FCAL/LArFCAL3CalibCalculator.h | 40 - .../LArG4FCAL/LArFCALCalculatorBase.h | 96 - .../LArG4FCAL/LArFCALCalibCalculatorBase.h | 105 - .../LArG4/LArG4FCAL/cmt/requirements | 14 +- .../LArG4/LArG4FCAL/python/LArG4FCALConfig.py | 36 + .../LArG4FCAL/python/LArG4FCALConfigDb.py | 10 + .../LArG4/LArG4FCAL/src/LArFCAL1Calculator.cc | 29 - .../LArG4FCAL/src/LArFCAL1CalibCalculator.cc | 43 - .../LArG4/LArG4FCAL/src/LArFCAL2Calculator.cc | 29 - .../LArG4FCAL/src/LArFCAL2CalibCalculator.cc | 43 - .../LArG4/LArG4FCAL/src/LArFCAL3Calculator.cc | 30 - .../LArG4FCAL/src/LArFCAL3CalibCalculator.cc | 43 - .../LArG4FCAL/src/LArFCALCalculatorBase.cc | 124 +- .../LArG4FCAL/src/LArFCALCalculatorBase.h | 68 + .../src/LArFCALCalibCalculatorBase.cc | 313 +- .../src/LArFCALCalibCalculatorBase.h | 87 + .../src/components/LArG4FCAL_entries.cxx | 7 + .../LArG4/LArG4FastSimulation/doc/mainpage.h | 49 - .../python/LArG4FastSimulationConfig.py | 4 +- .../src/EndcapFastSimDedicatedSD.cxx | 8 +- .../LArG4/LArG4GenShowerLib/CMakeLists.txt | 20 +- .../LArG4GenShowerLib/TestActionShowerLib.h | 20 +- .../LArG4/LArG4GenShowerLib/cmt/requirements | 6 +- .../LArG4/LArG4GenShowerLib/doc/mainpage.h | 72 - .../python/LArG4GenShowerLibConfig.py | 2 +- .../share/LArG4GenerateShowerLib.py | 13 +- .../src/LArG4GenShowerLib.cxx | 32 +- .../src/TestActionShowerLib.cxx | 136 +- .../src/TestActionShowerLibTool.cxx | 3 +- LArCalorimeter/LArG4/LArG4H6SD/CMakeLists.txt | 6 +- .../LArG4/LArG4H6SD/cmt/requirements | 11 +- .../LArG4/LArG4H6SD/python/LArG4H6SDConfig.py | 266 +- .../LArG4H6SD/python/LArG4H6SDConfigDb.py | 30 + .../LArG4/LArG4H6SD/src/H62004ActiveSDTool.cc | 84 + .../LArG4/LArG4H6SD/src/H62004ActiveSDTool.h | 63 + .../LArG4/LArG4H6SD/src/H62004CalibSDTool.cc | 52 + .../LArG4/LArG4H6SD/src/H62004CalibSDTool.h | 39 + .../LArG4/LArG4H6SD/src/H62004DeadSDTool.cc | 74 + .../LArG4/LArG4H6SD/src/H62004DeadSDTool.h | 54 + .../LArG4/LArG4H6SD/src/H62004EMECSDTool.cc | 48 + .../LArG4/LArG4H6SD/src/H62004EMECSDTool.h | 50 + .../LArG4/LArG4H6SD/src/H62004FCALSDTool.cc | 57 + .../LArG4/LArG4H6SD/src/H62004FCALSDTool.h | 60 + .../LArG4/LArG4H6SD/src/H62004HECSDTool.cc | 46 + .../LArG4/LArG4H6SD/src/H62004HECSDTool.h | 48 + .../LArG4H6SD/src/H62004InactiveSDTool.cc | 77 + .../LArG4H6SD/src/H62004InactiveSDTool.h | 63 + .../LArG4/LArG4H6SD/src/H62004SimpleSDTool.cc | 53 + .../LArG4/LArG4H6SD/src/H62004SimpleSDTool.h | 39 + .../src/LArFCAL1H62004CalibCalculator.cc | 33 - .../src/LArFCAL1H62004CalibCalculator.h | 29 - .../src/LArFCAL2H62004CalibCalculator.cc | 33 - .../src/LArFCAL2H62004CalibCalculator.h | 29 - .../src/LArFCALH62004CalibCalculatorBase.cc | 518 ++- .../src/LArFCALH62004CalibCalculatorBase.h | 69 +- .../LArG4H6SD/src/LArG4H62004ActiveSDTool.cc | 38 +- .../LArG4H6SD/src/LArG4H62004ActiveSDTool.h | 13 +- .../LArG4/LArG4H6SD/src/LArG4H62004CalibSD.cc | 17 +- .../LArG4/LArG4H6SD/src/LArG4H62004CalibSD.h | 2 +- .../LArG4H62004DeadCalibrationCalculator.cc | 130 +- .../LArG4H62004DeadCalibrationCalculator.h | 22 +- .../LArG4H6SD/src/LArG4H62004DeadSDTool.cc | 16 +- .../LArG4H6SD/src/LArG4H62004DeadSDTool.h | 12 +- .../LArG4H6SD/src/LArG4H62004EMECSDTool.cc | 12 +- .../LArG4H6SD/src/LArG4H62004EMECSDTool.h | 20 +- .../LArG4H6SD/src/LArG4H62004FCALSDTool.cc | 26 +- .../LArG4H6SD/src/LArG4H62004FCALSDTool.h | 11 +- .../LArG4H6SD/src/LArG4H62004HECSDTool.cc | 15 +- .../LArG4H6SD/src/LArG4H62004HECSDTool.h | 10 +- .../src/LArG4H62004InactiveSDTool.cc | 33 +- .../LArG4H6SD/src/LArG4H62004InactiveSDTool.h | 15 +- .../LArG4/LArG4H6SD/src/LArG4H62004SD.cc | 20 +- .../LArG4/LArG4H6SD/src/LArG4H62004SD.h | 4 +- .../LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.cc | 2 + .../LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.h | 2 +- .../src/LArG4H6COLDTCMod0Calculator.cc | 134 +- .../src/LArG4H6COLDTCMod0Calculator.h | 87 +- .../src/LArG4H6COLDTCMod0CalibCalculator.cc | 79 +- .../src/LArG4H6COLDTCMod0CalibCalculator.h | 39 +- .../src/LArG4H6COLDTCMod0ChannelMap.cc | 30 +- .../src/LArG4H6COLDTCMod0ChannelMap.h | 4 +- .../LArG4H6SD/src/LArG4H6WarmTCCalculator.cc | 149 +- .../LArG4H6SD/src/LArG4H6WarmTCCalculator.h | 62 +- .../LArG4H6SD/src/LArG4H6WarmTCSDTool.cc | 5 +- .../LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.h | 2 +- .../src/LArG4TBECBeamChCalculator.cc | 56 +- .../LArG4H6SD/src/LArG4TBECBeamChSDTool.h | 2 +- .../src/LArGeoH62004EventActionTool.cc | 2 +- .../src/LArGeoH62004SteppingAction.cc | 3 +- .../src/LArGeoH62004SteppingActionTool.cc | 2 +- .../LArG4/LArG4H6SD/src/RadLenNtupleTool.cc | 2 +- .../src/TBECBackOuterBarretteTool.cc | 49 +- .../LArG4H6SD/src/TBECBackOuterBarretteTool.h | 20 +- .../LArG4H6SD/src/TBECInnerModuleTool.cc | 48 +- .../LArG4/LArG4H6SD/src/TBECInnerModuleTool.h | 20 +- .../LArG4H6SD/src/TBECOuterModuleTool.cc | 49 +- .../LArG4/LArG4H6SD/src/TBECOuterModuleTool.h | 18 +- .../src/components/LArG4H6SDTools_entries.cxx | 48 +- LArCalorimeter/LArG4/LArG4H8SD/CMakeLists.txt | 8 +- .../LArG4/LArG4H8SD/cmt/requirements | 7 +- .../LArG4/LArG4H8SD/python/LArG4H8SDConfig.py | 48 +- .../LArG4H8SD/python/LArG4H8SDConfigDb.py | 5 +- .../LArG4/LArG4H8SD/src/H8CalibSDTool.cc | 109 + .../LArG4/LArG4H8SD/src/H8CalibSDTool.h | 62 + .../src/H8CalibrationDefaultCalculator.cc | 374 +- .../src/H8CalibrationDefaultCalculator.h | 74 +- .../LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.cc | 147 +- .../LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.h | 12 +- .../src/LArTBCryostatCalibrationCalculator.cc | 277 +- .../src/LArTBCryostatCalibrationCalculator.h | 79 +- .../src/components/LArG4H8SD_entries.cxx | 10 +- LArCalorimeter/LArG4/LArG4HEC/CMakeLists.txt | 12 +- LArCalorimeter/LArG4/LArG4HEC/GNUmakefile | 0 .../LArG4HEC/LArG4HEC/CalibrationCalculator.h | 86 - .../LArG4/LArG4HEC/LArG4HEC/Geometry.h | 67 - .../LArG4/LArG4HEC/LArG4HEC/HECGeometry.h | 71 +- .../LArG4/LArG4HEC/LArG4HEC/IHECGeometry.h | 46 + .../LArG4/LArG4HEC/LArG4HEC/ILocalGeometry.h | 47 + .../LArG4HEC/LArG4HEC/LArHECCalculator.h | 103 - .../LArHECCalibrationWheelCalculator.h | 57 - .../LArG4HEC/LArG4HEC/LArHECLocalCalculator.h | 111 - .../LArG4HEC/LArG4HEC/LArHECWheelCalculator.h | 104 - .../LArG4HEC/LocalCalibrationCalculator.h | 55 - .../LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h | 47 +- .../LArG4/LArG4HEC/cmt/requirements | 27 +- .../LArG4/LArG4HEC/python/HECGeometryType.py | 5 + .../LArG4/LArG4HEC/python/LArG4HECConfig.py | 36 + .../LArG4/LArG4HEC/python/LArG4HECConfigDb.py | 13 + .../LArG4HEC/src/CalibrationCalculator.cc | 90 - LArCalorimeter/LArG4/LArG4HEC/src/Geometry.cc | 396 -- .../LArG4/LArG4HEC/src/HECGeometry.cc | 869 ++-- .../LArG4/LArG4HEC/src/LArHECCalculator.cc | 146 - .../src/LArHECCalibrationWheelCalculator.cc | 90 +- .../src/LArHECCalibrationWheelCalculator.h | 52 + .../LArG4HEC/src/LArHECLocalCalculator.cc | 107 +- .../LArG4HEC/src/LArHECLocalCalculator.h | 64 + .../LArG4HEC/src/LArHECWheelCalculator.cc | 129 +- .../LArG4HEC/src/LArHECWheelCalculator.h | 64 + .../src/LocalCalibrationCalculator.cc | 97 +- .../LArG4HEC/src/LocalCalibrationCalculator.h | 51 + .../LArG4/LArG4HEC/src/LocalGeometry.cc | 1075 +++-- .../src/components/LArG4HEC_entries.cxx | 15 + .../LArG4/LArG4MiniFCAL/CMakeLists.txt | 11 +- .../LArG4MiniFCAL/MiniFCALAssignIdentifier.h | 1 - .../LArG4MiniFCAL/MiniFCALCalculator.h | 94 - .../LArG4/LArG4MiniFCAL/cmt/requirements | 11 +- .../python/LArG4MiniFCALConfig.py | 22 + .../python/LArG4MiniFCALConfigDb.py | 9 + .../src/MiniFCALAssignIdentifier.cc | 26 +- .../LArG4MiniFCAL/src/MiniFCALCalculator.cc | 67 +- .../LArG4MiniFCAL/src/MiniFCALCalculator.h | 54 + .../src/MiniFCALCalibrationCalculator.cc | 61 +- .../MiniFCALCalibrationCalculator.h | 26 +- .../src/components/LArG4MiniFCAL_entries.cxx | 7 + .../LArG4RunControl/LArG4BarrelOptions.h | 102 - .../LArG4RunControl/LArG4EMECOptions.h | 145 - .../LArG4RunControl/LArG4FCALOptions.h | 57 - .../LArG4RunControl/LArG4GlobalOptions.h | 50 - .../LArG4RunControl/LArG4HECOptions.h | 59 - .../LArG4RunControl/LArG4RunControlDict.h | 5 - .../LArG4RunControl/selection.xml | 5 - .../LArG4/LArG4RunControl/cmt/requirements | 30 - .../src/LArG4BarrelOptions.cxx | 42 - .../LArG4RunControl/src/LArG4EMECOptions.cxx | 56 - .../LArG4RunControl/src/LArG4FCALOptions.cxx | 34 - .../src/LArG4GlobalOptions.cxx | 32 - .../LArG4RunControl/src/LArG4HECOptions.cxx | 34 - .../LArG4RunControl/src/LArG4TBPosOptions.cxx | 10 +- .../src/LArGeoTB2004Options.cxx | 8 +- .../src/LArGeoTBGeometricOptions.cxx | 8 +- .../src/LArGeoTBH1GeoOptions.cxx | 8 +- LArCalorimeter/LArG4/LArG4SD/CMakeLists.txt | 16 +- LArCalorimeter/LArG4/LArG4SD/cmt/requirements | 27 +- .../LArG4/LArG4SD/python/LArG4SDConfig.py | 18 +- .../LArG4/LArG4SD/python/LArG4SDConfigDb.py | 3 +- .../LArG4/LArG4SD/src/ActiveSDTool.cc | 113 + .../LArG4/LArG4SD/src/ActiveSDTool.h | 78 + .../src/CalibrationDefaultCalculator.cc | 309 ++ .../src}/CalibrationDefaultCalculator.h | 42 +- .../LArG4/LArG4SD/src/DeadSDTool.cc | 137 + LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.h | 84 + LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.cc | 64 + LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.h | 61 + .../LArG4/LArG4SD/src/EMECSDTool.cc | 95 + LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.h | 67 + .../LArG4/LArG4SD/src/FCALSDTool.cc | 68 + LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.h | 59 + LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.cc | 61 + LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.h | 56 + .../LArG4/LArG4SD/src/InactiveSDTool.cc | 147 + .../LArG4/LArG4SD/src/InactiveSDTool.h | 77 + .../LArG4/LArG4SD/src/LArG4ActiveSDTool.cc | 128 - .../LArG4/LArG4SD/src/LArG4ActiveSDTool.h | 69 - .../LArG4/LArG4SD/src/LArG4DeadSDTool.cc | 167 - .../LArG4/LArG4SD/src/LArG4DeadSDTool.h | 70 - .../LArG4/LArG4SD/src/LArG4EMBSDTool.cc | 65 - .../LArG4/LArG4SD/src/LArG4EMBSDTool.h | 56 - .../LArG4/LArG4SD/src/LArG4EMECSDTool.cc | 97 - .../LArG4/LArG4SD/src/LArG4EMECSDTool.h | 57 - .../LArG4/LArG4SD/src/LArG4FCALSDTool.cc | 73 - .../LArG4/LArG4SD/src/LArG4FCALSDTool.h | 56 - .../LArG4/LArG4SD/src/LArG4HECSDTool.cc | 61 - .../LArG4/LArG4SD/src/LArG4HECSDTool.h | 55 - .../LArG4/LArG4SD/src/LArG4InactiveSDTool.cc | 136 - .../LArG4/LArG4SD/src/LArG4InactiveSDTool.h | 70 - .../LArG4/LArG4SD/src/LArG4MiniFCALSDTool.cc | 47 - .../LArG4/LArG4SD/src/LArG4MiniFCALSDTool.h | 46 - .../LArG4/LArG4SD/src/MiniFCALSDTool.cc | 48 + .../LArG4/LArG4SD/src/MiniFCALSDTool.h | 53 + .../src/components/LArG4SD_entries.cxx | 37 +- .../LArG4/LArG4Validation/cmt/requirements | 56 - .../src/EMECSupportConstruction.cxx | 16 +- .../G4AtlasApps/python/SimAtlasKernel.py | 23 +- .../G4AtlasTools/SensitiveDetectorBase.h | 5 + .../src/SensitiveDetectorBase.cxx | 130 +- .../Geo2G4/src/LArWheelSolidInit.cxx | 26 +- .../ISF_Geant4UserActions/CMakeLists.txt | 6 +- .../FastCaloSimParamAction.h | 116 +- .../FastCaloSimParamActionTool.h | 45 +- .../ISF_Geant4UserActions/cmt/requirements | 4 - .../src/FastCaloSimParamAction.cxx | 1261 +++-- .../src/FastCaloSimParamActionTool.cxx | 76 +- .../src/TestBoundariesUserAction.cxx | 1 + .../src/TestBoundariesUserAction.h | 1 + .../VP1/VP1Utils/src/SoVisualizeAction.cxx | 18 +- 390 files changed, 21628 insertions(+), 22197 deletions(-) create mode 100644 DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculatorEnums.h create mode 100644 DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/selectionEnums.xml delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/GNUmakefile delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/AccMap.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CurrMap.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalculator.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelGeometry.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerCalculator.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerGeometry.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeAbsorbers.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeElectrodes.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudes.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightAbsorbers.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightElectrodes.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/cmt/requirements create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfig.py create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfigDb.py delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/CryostatCalibrationCalculator.h (73%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/CryostatCalibrationLArCalculator.h (71%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/CryostatCalibrationMixedCalculator.h (67%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/DMCalibrationCalculator.h (67%) create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelGeometry.h create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelPresamplerGeometry.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/LArBarrelCalibrationCalculator.h (59%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.h delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/MapEta.h (55%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/PhysicalVolumeAccessor.h (59%) rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/PresParameterDef.h (100%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/PresamplerCalibrationCalculator.h (62%) delete mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cc create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx rename LArCalorimeter/LArG4/LArG4Barrel/{LArG4Barrel => src}/PsMap.h (76%) create mode 100644 LArCalorimeter/LArG4/LArG4Barrel/src/components/LArG4Barrel_entries.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibSDTool.h create mode 100755 LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalculatorSvc.h create mode 100755 LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalibCalculatorSvc.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalculatorSvcImp.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalibCalculatorSvcImp.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4DetectorComponents.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4EnumDefs.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArHitMaker.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVCalculator.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVolumeInterface.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/OptionsStore.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/RunOptions.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/SimpleSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/VCalibrationCalculator.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/VolumeUtils.h create mode 100644 LArCalorimeter/LArG4/LArG4Code/LArG4Code/selectionEnums.xml create mode 100644 LArCalorimeter/LArG4/LArG4Code/src/CalibSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4Code/src/CalibrationDefaultCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4Code/src/LArCalculatorSvcImp.cxx create mode 100644 LArCalorimeter/LArG4/LArG4Code/src/LArCalibCalculatorSvcImp.cxx delete mode 100644 LArCalorimeter/LArG4/LArG4Code/src/LArG4DetectorComponents.cc delete mode 100644 LArCalorimeter/LArG4/LArG4Code/src/LArHitMaker.cc create mode 100644 LArCalorimeter/LArG4/LArG4Code/src/SDWrapper.cc create mode 100644 LArCalorimeter/LArG4/LArG4Code/src/SimpleSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4Code/src/VolumeUtils.cc delete mode 100644 LArCalorimeter/LArG4/LArG4EC/LArG4EC/EnergyCalculator.h create mode 100644 LArCalorimeter/LArG4/LArG4EC/LArG4EC/IECPresamplerGeometry.h delete mode 100644 LArCalorimeter/LArG4/LArG4EC/LArG4EC/LArEndcapPresamplerCalculator.h create mode 100644 LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfig.py create mode 100644 LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfigDb.py create mode 100644 LArCalorimeter/LArG4/LArG4EC/python/LArWheelCalculatorEnum.py rename LArCalorimeter/LArG4/LArG4EC/{LArG4EC => src}/CalibrationCalculator.h (70%) rename LArCalorimeter/LArG4/LArG4EC/{LArG4EC => src}/CryostatCalibrationCalculator.h (73%) rename LArCalorimeter/LArG4/LArG4EC/{LArG4EC => src}/CryostatCalibrationLArCalculator.h (57%) rename LArCalorimeter/LArG4/LArG4EC/{LArG4EC => src}/CryostatCalibrationMixedCalculator.h (73%) rename LArCalorimeter/LArG4/LArG4EC/{LArG4EC => src}/EMECSupportCalibrationCalculator.h (69%) create mode 100644 LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.h create mode 100644 LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.h rename LArCalorimeter/LArG4/LArG4EC/{LArG4EC => src}/PresamplerCalibrationCalculator.h (68%) create mode 100644 LArCalorimeter/LArG4/LArG4EC/src/components/LArG4EC_entries.cxx mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4FCAL/GNUmakefile delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1Calculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1CalibCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2Calculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2CalibCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3Calculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3CalibCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalculatorBase.h delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalibCalculatorBase.h create mode 100644 LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfig.py create mode 100644 LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfigDb.py delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1Calculator.cc delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1CalibCalculator.cc delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2Calculator.cc delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2CalibCalculator.cc delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3Calculator.cc delete mode 100755 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3CalibCalculator.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc create mode 100644 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc create mode 100644 LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.h create mode 100644 LArCalorimeter/LArG4/LArG4FCAL/src/components/LArG4FCAL_entries.cxx delete mode 100644 LArCalorimeter/LArG4/LArG4FastSimulation/doc/mainpage.h delete mode 100644 LArCalorimeter/LArG4/LArG4GenShowerLib/doc/mainpage.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.cc delete mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.h delete mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.cc delete mode 100644 LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/cmt/requirements create mode 100644 LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/GNUmakefile delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/CalibrationCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/Geometry.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/HECGeometry.h create mode 100644 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/IHECGeometry.h create mode 100644 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/ILocalGeometry.h delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalibrationWheelCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECLocalCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECWheelCalculator.h delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalCalibrationCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h create mode 100644 LArCalorimeter/LArG4/LArG4HEC/python/HECGeometryType.py create mode 100644 LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfig.py create mode 100644 LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfigDb.py delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/src/CalibrationCalculator.cc delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/src/Geometry.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/src/HECGeometry.cc delete mode 100755 LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalculator.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc create mode 100644 LArCalorimeter/LArG4/LArG4HEC/src/components/LArG4HEC_entries.cxx mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALAssignIdentifier.h delete mode 100755 LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalculator.h create mode 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfig.py create mode 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfigDb.py mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.cc create mode 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.h mode change 100755 => 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.cc rename LArCalorimeter/LArG4/LArG4MiniFCAL/{LArG4MiniFCAL => src}/MiniFCALCalibrationCalculator.h (60%) mode change 100755 => 100644 create mode 100644 LArCalorimeter/LArG4/LArG4MiniFCAL/src/components/LArG4MiniFCAL_entries.cxx delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4BarrelOptions.h delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4EMECOptions.h delete mode 100644 LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4FCALOptions.h delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4GlobalOptions.h delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4HECOptions.h delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/cmt/requirements delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/src/LArG4BarrelOptions.cxx delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/src/LArG4EMECOptions.cxx delete mode 100644 LArCalorimeter/LArG4/LArG4RunControl/src/LArG4FCALOptions.cxx delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/src/LArG4GlobalOptions.cxx delete mode 100755 LArCalorimeter/LArG4/LArG4RunControl/src/LArG4HECOptions.cxx create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.cc rename LArCalorimeter/LArG4/{LArG4Code/LArG4Code => LArG4SD/src}/CalibrationDefaultCalculator.h (56%) create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.h delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.cc delete mode 100644 LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.h create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.cc create mode 100644 LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.h delete mode 100755 LArCalorimeter/LArG4/LArG4Validation/cmt/requirements mode change 100644 => 100755 graphics/VP1/VP1Utils/src/SoVisualizeAction.cxx diff --git a/Calorimeter/CaloG4Sim/CaloG4Sim/CalibrationDefaultProcessing.h b/Calorimeter/CaloG4Sim/CaloG4Sim/CalibrationDefaultProcessing.h index a4c4c8094f36..04926f29e771 100644 --- a/Calorimeter/CaloG4Sim/CaloG4Sim/CalibrationDefaultProcessing.h +++ b/Calorimeter/CaloG4Sim/CaloG4Sim/CalibrationDefaultProcessing.h @@ -72,4 +72,4 @@ namespace G4UA { -#endif // CaloG4_CalibrationDefaultProcessing_h +#endif // CaloG4_CalibrationDefaultProcessing_h \ No newline at end of file diff --git a/Calorimeter/CaloG4Sim/CaloG4Sim/SimulationEnergies.h b/Calorimeter/CaloG4Sim/CaloG4Sim/SimulationEnergies.h index 269c2018197f..9a09b08eb244 100644 --- a/Calorimeter/CaloG4Sim/CaloG4Sim/SimulationEnergies.h +++ b/Calorimeter/CaloG4Sim/CaloG4Sim/SimulationEnergies.h @@ -37,6 +37,11 @@ #include <map> #include <vector> +#ifdef ATHENAHIVE +# include <thread> +# include "tbb/concurrent_unordered_map.h" +#endif + // Forward declarations. class G4Step; @@ -53,7 +58,7 @@ namespace CaloG4 { // Examine the G4Step and return the energies required for a // calibration hit. - void Energies( const G4Step* , std::vector<G4double> & ); + void Energies( const G4Step* , std::vector<G4double> & ) const; // Accessing detailed information: @@ -100,32 +105,43 @@ namespace CaloG4 { // energy is routed to some other volume that the one in which the // G4Step occurs. - ClassifyResult_t Classify( const G4Step*, const G4bool processEscaped = true ); + ClassifyResult_t Classify( const G4Step*, const G4bool processEscaped = true ) const; // Has this routine been called for this G4Step? - static G4bool StepWasProcessed() { return m_calledForStep; } - static void SetStepProcessed() { m_calledForStep = true; } - static void ResetStepProcessed() { m_calledForStep = false; } + static G4bool StepWasProcessed(); + static void SetStepProcessed(); + static void ResetStepProcessed(); private: // Some private methods for internal calculations: - G4double m_measurableEnergy(const G4ParticleDefinition *particleDef, + G4double measurableEnergy(const G4ParticleDefinition *particleDef, G4int PDGEncoding, G4double totalEnergy, - G4double kineticEnergy); + G4double kineticEnergy) const; - G4double m_measurableEnergyV2(const G4ParticleDefinition *particleDef, - G4int PDGEncoding, - G4double totalEnergy, - G4double kineticEnergy); + G4double measurableEnergyV2(const G4ParticleDefinition *particleDef, + G4int PDGEncoding, + G4double totalEnergy, + G4double kineticEnergy) const; // Escaped energy requires special processing. - G4bool m_ProcessEscapedEnergy( G4ThreeVector point, G4double energy ); + G4bool ProcessEscapedEnergy( G4ThreeVector point, G4double energy ) const; // Used to keep track of processing state. +#ifdef ATHENAHIVE + /// Thread-to-SD concurrent map type + /// TODO: this needs a redesign. The map structure is bizarre and needless. + using StCallThreadMap_t = tbb::concurrent_unordered_map + < std::thread::id, G4bool, std::hash<std::thread::id> >; + /// Concurrent map of flags, one for each thread + static StCallThreadMap_t m_calledForStepThreadMap; +#else + // flag to mark that call was made static G4bool m_calledForStep; +#endif + }; } // namespace CaloG4 diff --git a/Calorimeter/CaloG4Sim/src/CalibrationDefaultProcessing.cc b/Calorimeter/CaloG4Sim/src/CalibrationDefaultProcessing.cc index eadb2cdfee9c..8f9bad1c3dc2 100644 --- a/Calorimeter/CaloG4Sim/src/CalibrationDefaultProcessing.cc +++ b/Calorimeter/CaloG4Sim/src/CalibrationDefaultProcessing.cc @@ -90,4 +90,4 @@ namespace G4UA { } // namespace CaloG4 -} // namespace G4UA +} // namespace G4UA \ No newline at end of file diff --git a/Calorimeter/CaloG4Sim/src/SimulationEnergies.cc b/Calorimeter/CaloG4Sim/src/SimulationEnergies.cc index 9efc867d8bfe..abece5fe1cbe 100644 --- a/Calorimeter/CaloG4Sim/src/SimulationEnergies.cc +++ b/Calorimeter/CaloG4Sim/src/SimulationEnergies.cc @@ -28,7 +28,7 @@ // geometry problems when touchableHandle->GetVolume()==0 // 20-Apr-2006 M. Leltchouk: internal particle mass table is used now -// in SimulationEnergies::m_measurableEnergy because in recently released +// in SimulationEnergies::measurableEnergy because in recently released // G4 8.0 particle masses may not be available when SimulationEnergies // constructor is looking for them, see Andrea Dell'Acqua's comment below. @@ -59,7 +59,7 @@ // 2) These escaped energies are recorded to the cell where the escaping // track originates (i.e. where neutrinos have been born as a result of // some particle decay) without call of -// m_ProcessEscapedEnergy( thisTrackVertex, escapedEnergy ). +// ProcessEscapedEnergy( thisTrackVertex, escapedEnergy ). // 3) If a neutrino is tracked (was not killed) then the special early // return from SimulationEnergies::Classify is used to avoid the second // counting of the same neutrino energy when this neutrino escapes from @@ -135,8 +135,11 @@ namespace CaloG4 { G4double SimulationEnergies::helium3Mass = 0; */ +#ifdef ATHENAHIVE + SimulationEnergies::StCallThreadMap_t SimulationEnergies::m_calledForStepThreadMap; +#else G4bool SimulationEnergies::m_calledForStep = false; - +#endif SimulationEnergies::SimulationEnergies() { @@ -176,8 +179,39 @@ namespace CaloG4 { {;} + G4bool SimulationEnergies::StepWasProcessed() { +#ifdef ATHENAHIVE + // Get current thread-ID + const auto tid = std::this_thread::get_id(); + // Retrieve it from the call flags map + auto cfPair = m_calledForStepThreadMap.find(tid); + if(cfPair == m_calledForStepThreadMap.end()) return false; + return cfPair->second; +#else + return m_calledForStep; +#endif + } + + void SimulationEnergies::SetStepProcessed() { +#ifdef ATHENAHIVE + const auto tid = std::this_thread::get_id(); + m_calledForStepThreadMap.insert( std::make_pair(tid, true) ); +#else + m_calledForStep = true; +#endif + } + + void SimulationEnergies::ResetStepProcessed() { +#ifdef ATHENAHIVE + const auto tid = std::this_thread::get_id(); + m_calledForStepThreadMap.insert( std::make_pair(tid, false) ); +#else + m_calledForStep = false; +#endif + } + // The "simple" call, intended for calibration calculators: - void SimulationEnergies::Energies( const G4Step* a_step , std::vector<G4double>& energies ) + void SimulationEnergies::Energies( const G4Step* a_step , std::vector<G4double>& energies ) const { // Call the detailed classification. Process any escaped energy. ClassifyResult_t category = Classify( a_step, true ); @@ -215,7 +249,7 @@ namespace CaloG4 { // energy will be not be routed to some other volume's hits. SimulationEnergies::ClassifyResult_t SimulationEnergies::Classify( const G4Step* step, - const G4bool a_processEscaped ) + const G4bool a_processEscaped ) const { // Initialize our result to zero. @@ -250,10 +284,10 @@ namespace CaloG4 { G4double incomingEtot = dynParticle->GetMass() + incomingEkin; result.energy[kInvisible0] = - m_measurableEnergy(particle, - particle->GetPDGEncoding(), - incomingEtot, - incomingEkin); + measurableEnergy(particle, + particle->GetPDGEncoding(), + incomingEtot, + incomingEkin); } else if (status == fAlive || status == fStopButAlive){// Alive stepping particle at PostStep result.energy[kInvisible0] = EkinPreStep - EkinPostStep - dEStepVisible; @@ -299,10 +333,10 @@ namespace CaloG4 { else { //----- extract further information about each new secondary particle: kinEofSecondary = (*fSecondary)[lp1]->GetKineticEnergy(); - measurEofSecondary = m_measurableEnergy(secondaryID, - secondaryID->GetPDGEncoding(), - totalEofSecondary, - kinEofSecondary); + measurEofSecondary = measurableEnergy(secondaryID, + secondaryID->GetPDGEncoding(), + totalEofSecondary, + kinEofSecondary); result.energy[kInvisible0] -= measurEofSecondary; } } @@ -323,10 +357,10 @@ namespace CaloG4 { } G4double escapedEnergy = - m_measurableEnergy(particle, - particle->GetPDGEncoding(), - dynParticle->GetTotalEnergy(), - EkinPostStep); + measurableEnergy(particle, + particle->GetPDGEncoding(), + dynParticle->GetTotalEnergy(), + EkinPostStep); result.energy[kInvisible0] -= escapedEnergy; @@ -334,9 +368,9 @@ namespace CaloG4 { #ifdef DEBUG_ENERGIES allOK = #endif - m_ProcessEscapedEnergy( pTrack->GetVertexPosition(), escapedEnergy ); + ProcessEscapedEnergy( pTrack->GetVertexPosition(), escapedEnergy ); else - result.energy[kEscaped] = escapedEnergy; + result.energy[kEscaped] += escapedEnergy; } // END of calculation of Invisible and Escaped energy for current step @@ -371,10 +405,10 @@ namespace CaloG4 { - G4double SimulationEnergies::m_measurableEnergyV2(const G4ParticleDefinition *particleDef, - G4int PDGEncoding, - G4double totalEnergy, - G4double kineticEnergy) + G4double SimulationEnergies::measurableEnergyV2(const G4ParticleDefinition *particleDef, + G4int PDGEncoding, + G4double totalEnergy, + G4double kineticEnergy) const // 15-Dec-2003 Mikhail Leltchouk: inspired by FORTRAN Function PrMeasE // used by Michael Kuhlen and Peter Loch with Geant3 since 1991. @@ -425,10 +459,10 @@ namespace CaloG4 { } - G4double SimulationEnergies::m_measurableEnergy(const G4ParticleDefinition* particleDef, - G4int PDGEncoding, - G4double totalEnergy, - G4double kineticEnergy) + G4double SimulationEnergies::measurableEnergy(const G4ParticleDefinition* particleDef, + G4int PDGEncoding, + G4double totalEnergy, + G4double kineticEnergy) const // 5-Dec-2003 Mikhail Leltchouk: extended version of FORTRAN Function PrMeasE // used by Michael Kuhlen and Peter Loch with Geant3 since 1991. @@ -446,7 +480,7 @@ namespace CaloG4 { // totalEnergy - particle total energy // kineticEnergy - particle kinetic energy - // Output: m_measurableEnergy - energy measurable in a calorimeter + // Output: measurableEnergy - energy measurable in a calorimeter { @@ -516,7 +550,7 @@ namespace CaloG4 { - G4bool SimulationEnergies::m_ProcessEscapedEnergy( G4ThreeVector a_point, G4double a_energy ) + G4bool SimulationEnergies::ProcessEscapedEnergy( G4ThreeVector a_point, G4double a_energy ) const { // Escaped energy requires special processing. The energy was not // deposited in the current G4Step, but at the beginning of the @@ -588,7 +622,7 @@ namespace CaloG4 { if ( ! errorDisplayed ) { errorDisplayed = true; - G4cout << "SimulationEnergies::m_ProcessEscapedEnergy - " << G4endl + G4cout << "SimulationEnergies::ProcessEscapedEnergy - " << G4endl << " WARNING! CaloG4::EscapedEnergyRegistry was never initialized for 'LArG4::'" << G4endl << " and LArG4Sim is the package with the code that handles CalibrationHits" << G4endl << " in non-sensitive volumes. Not all energies deposited in this simulation" << G4endl @@ -611,7 +645,7 @@ namespace CaloG4 { if ( ! errorDisplayed1 ) { errorDisplayed1 = true; - G4cout << "SimulationEnergies::m_ProcessEscapedEnergy - " << G4endl + G4cout << "SimulationEnergies::ProcessEscapedEnergy - " << G4endl <<" WARNING! touchableHandle->GetVolume()==0 geometry problem ? and also" << G4endl << " WARNING! CaloG4::EscapedEnergyRegistry was never initialized for 'LArG4::'" << G4endl << " and LArG4Sim is the package with the code that handles CalibrationHits" << G4endl diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/CMakeLists.txt b/DetectorDescription/GeoModel/GeoSpecialShapes/CMakeLists.txt index 287f25bef615..178b14395f78 100644 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/CMakeLists.txt +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/CMakeLists.txt @@ -21,6 +21,7 @@ atlas_depends_on_subdirs( PUBLIC # External dependencies: find_package( Boost COMPONENTS filesystem thread system ) find_package( CLHEP ) +find_package( GSL ) find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) find_package( ROOT COMPONENTS Matrix Core Tree MathCore Hist RIO pthread MathMore Minuit Minuit2 Physics HistPainter Rint ) @@ -33,11 +34,17 @@ atlas_add_library( GeoSpecialShapes PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES ${CLHEP_LIBRARIES} SGTools GeoModelKernel StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${ROOT_LIBRARIES} AthenaKernel CxxUtils GeoModelUtilities GaudiKernel ) + PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${ROOT_LIBRARIES} ${GSL_LIBRARIES} AthenaKernel CxxUtils GeoModelUtilities GaudiKernel ) atlas_add_dictionary( LArGeoCheckerDict GeoSpecialShapes/LArGeoCheckerDict.h GeoSpecialShapes/selection.xml INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} SGTools StoreGateLib SGtests GeoModelKernel AthenaKernel CxxUtils GeoModelUtilities GaudiKernel GeoSpecialShapes ) + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${ROOT_LIBRARIES} ${GSL_LIBRARIES} ${CLHEP_LIBRARIES} SGTools StoreGateLib SGtests GeoModelKernel AthenaKernel CxxUtils GeoModelUtilities GaudiKernel GeoSpecialShapes ) + +atlas_add_dictionary( LArWheelEnums + GeoSpecialShapes/LArWheelCalculatorEnums.h + GeoSpecialShapes/selectionEnums.xml + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${ROOT_LIBRARIES} ${GSL_LIBRARIES} ${CLHEP_LIBRARIES} SGTools StoreGateLib SGtests GeoModelKernel AthenaKernel CxxUtils GeoModelUtilities GaudiKernel GeoSpecialShapes ) diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArCustomShape.h b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArCustomShape.h index d440aeac0240..a027b48abfd9 100644 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArCustomShape.h +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArCustomShape.h @@ -14,6 +14,7 @@ #include "GeoModelKernel/GeoShape.h" #include "GeoSpecialShapes/LArWheelCalculator.h" +#include "GeoSpecialShapes/LArWheelCalculatorEnums.h" // Forward declaration @@ -23,7 +24,7 @@ class GeoShapeAction; class LArCustomShape : public GeoShape { public: typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t; - typedef std::pair<LArWheelCalculator::LArWheelCalculator_t, int> CalcDef_t; + typedef std::pair<LArG4::LArWheelCalculator_t, int> CalcDef_t; typedef std::map<std::string, CalcDef_t> ShapeCalc_typemap; // The custom shape has only one property: a string that contains diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h index a8223046e4ca..88e0c34d9763 100644 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculator.h @@ -14,6 +14,8 @@ #include "CLHEP/Vector/ThreeVector.h" #include "SGTools/CLASS_DEF.h" +#include "GeoSpecialShapes/LArWheelCalculatorEnums.h" + #define LARWC_SINCOS_POLY 5 #define LARWC_DTNF_NEW @@ -42,33 +44,20 @@ class LArWheelCalculator template <typename SaggingType> friend class LArWheelCalculator_Impl::DistanceToTheNeutralFibre_OfFan; public: - typedef enum { - InnerAbsorberWheel, OuterAbsorberWheel, - InnerElectrodWheel, OuterElectrodWheel, - InnerAbsorberModule, OuterAbsorberModule, - InnerElectrodModule, OuterElectrodModule, - BackInnerBarretteWheel, BackOuterBarretteWheel, - BackInnerBarretteWheelCalib, BackOuterBarretteWheelCalib, - BackInnerBarretteModule, BackOuterBarretteModule, - BackInnerBarretteModuleCalib, BackOuterBarretteModuleCalib, - InnerGlueWheel, OuterGlueWheel, - InnerLeadWheel, OuterLeadWheel - } LArWheelCalculator_t; - - LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zside = 1); + LArWheelCalculator(LArG4::LArWheelCalculator_t a_wheelType, int zside = 1); virtual ~LArWheelCalculator(); LArWheelCalculator (const LArWheelCalculator&) = delete; LArWheelCalculator& operator= (const LArWheelCalculator&) = delete; - static const char *LArWheelCalculatorTypeString(LArWheelCalculator_t); - static double GetFanHalfThickness(LArWheelCalculator_t); + static const char *LArWheelCalculatorTypeString(LArG4::LArWheelCalculator_t); + static double GetFanHalfThickness(LArG4::LArWheelCalculator_t); // "Get constant" methods: double GetWheelThickness(void) const { return m_WheelThickness; } double GetdWRPtoFrontFace(void) const { return m_dWRPtoFrontFace; } double GetStraightStartSection(void) const { return m_StraightStartSection; } - virtual LArWheelCalculator_t type() const { return m_type; } + virtual LArG4::LArWheelCalculator_t type() const { return m_type; } // "zShift" is the z-distance (cm) that the EM endcap is shifted // (due to cabling, etc.) int GetAtlasZside() const { return m_AtlasZside; } @@ -117,7 +106,7 @@ class LArWheelCalculator double AmplitudeOfSurface(const CLHEP::Hep3Vector& P, int side, int fan_number) const; private: - LArWheelCalculator_t m_type; + LArG4::LArWheelCalculator_t m_type; int m_AtlasZside; bool m_SaggingOn; // ! diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculatorEnums.h b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculatorEnums.h new file mode 100644 index 000000000000..a565e53c9753 --- /dev/null +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/LArWheelCalculatorEnums.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef GEOSPECIALSHAPES_LARWHEELCALCULATORENUMS_H +#define GEOSPECIALSHAPES_LARWHEELCALCULATORENUMS_H + +namespace LArG4 { + + enum LArWheelCalculator_t { + InnerAbsorberWheel, OuterAbsorberWheel, + InnerElectrodWheel, OuterElectrodWheel, + InnerAbsorberModule, OuterAbsorberModule, + InnerElectrodModule, OuterElectrodModule, + BackInnerBarretteWheel, BackOuterBarretteWheel, + BackInnerBarretteWheelCalib, BackOuterBarretteWheelCalib, + BackInnerBarretteModule, BackOuterBarretteModule, + BackInnerBarretteModuleCalib, BackOuterBarretteModuleCalib, + InnerGlueWheel, OuterGlueWheel, + InnerLeadWheel, OuterLeadWheel + }; + + struct ROOT6_NamespaceAutoloadHook_WheelCalc{}; +} +#endif diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/selectionEnums.xml b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/selectionEnums.xml new file mode 100644 index 000000000000..c9d830fd6545 --- /dev/null +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/GeoSpecialShapes/selectionEnums.xml @@ -0,0 +1,8 @@ +<lcgdict> + + <enum pattern="LArG4::*"/> + <variable pattern="LArG4::*"/> + <class name="LArG4::ROOT6_NamespaceAutoloadHook_WheelCalc" /> + +</lcgdict> + diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/cmt/requirements b/DetectorDescription/GeoModel/GeoSpecialShapes/cmt/requirements index 99679894a837..c6bfb396cd88 100755 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/cmt/requirements +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/cmt/requirements @@ -32,3 +32,5 @@ apply_tag ROOTMathLibs # Make dict for LArGeoChecker use AtlasReflex AtlasReflex-* External -no_auto_imports apply_pattern lcgdict dict=LArGeoChecker selectionfile=selection.xml headerfiles="../GeoSpecialShapes/LArGeoCheckerDict.h" +apply_pattern lcgdict dict=LArWheelEnums selectionfile=selectionEnums.xml headerfiles="../GeoSpecialShapes/LArWheelCalculatorEnums.h" + diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArCustomShape.cxx b/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArCustomShape.cxx index a7d23228bb55..a59d6a08f005 100644 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArCustomShape.cxx +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArCustomShape.cxx @@ -13,53 +13,53 @@ const std::string LArCustomShape::s_classType = "CustomShape"; const ShapeType LArCustomShape::s_classTypeID = 500; const LArCustomShape::ShapeCalc_typemap LArCustomShape::s_calculatorTypes = { - { "LAr::EMEC::InnerWheel::Absorber", {LArWheelCalculator::InnerAbsorberWheel, 1} }, - { "LAr::EMEC::Pos::InnerWheel::Absorber", {LArWheelCalculator::InnerAbsorberWheel, 1} }, + { "LAr::EMEC::InnerWheel::Absorber", {LArG4::InnerAbsorberWheel, 1} }, + { "LAr::EMEC::Pos::InnerWheel::Absorber", {LArG4::InnerAbsorberWheel, 1} }, - { "LAr::EMEC::OuterWheel::Absorber", {LArWheelCalculator::OuterAbsorberWheel, 1} }, - { "LAr::EMEC::Pos::OuterWheel::Absorber", {LArWheelCalculator::OuterAbsorberWheel, 1} }, + { "LAr::EMEC::OuterWheel::Absorber", {LArG4::OuterAbsorberWheel, 1} }, + { "LAr::EMEC::Pos::OuterWheel::Absorber", {LArG4::OuterAbsorberWheel, 1} }, - { "LAr::EMEC::InnerWheel::Electrode", {LArWheelCalculator::InnerElectrodWheel, 1} }, - { "LAr::EMEC::Pos::InnerWheel::Electrode", {LArWheelCalculator::InnerElectrodWheel, 1} }, + { "LAr::EMEC::InnerWheel::Electrode", {LArG4::InnerElectrodWheel, 1} }, + { "LAr::EMEC::Pos::InnerWheel::Electrode", {LArG4::InnerElectrodWheel, 1} }, - { "LAr::EMEC::OuterWheel::Electrode", {LArWheelCalculator::OuterElectrodWheel, 1} }, - { "LAr::EMEC::Pos::OuterWheel::Electrode", {LArWheelCalculator::OuterElectrodWheel, 1} }, + { "LAr::EMEC::OuterWheel::Electrode", {LArG4::OuterElectrodWheel, 1} }, + { "LAr::EMEC::Pos::OuterWheel::Electrode", {LArG4::OuterElectrodWheel, 1} }, - { "LAr::EMEC::Neg::InnerWheel::Absorber", {LArWheelCalculator::InnerAbsorberWheel, -1} }, + { "LAr::EMEC::Neg::InnerWheel::Absorber", {LArG4::InnerAbsorberWheel, -1} }, - { "LAr::EMEC::Neg::OuterWheel::Absorber", {LArWheelCalculator::OuterAbsorberWheel, -1} }, + { "LAr::EMEC::Neg::OuterWheel::Absorber", {LArG4::OuterAbsorberWheel, -1} }, - { "LAr::EMEC::Neg::InnerWheel::Electrode", {LArWheelCalculator::InnerElectrodWheel, -1} }, + { "LAr::EMEC::Neg::InnerWheel::Electrode", {LArG4::InnerElectrodWheel, -1} }, - { "LAr::EMEC::Neg::OuterWheel::Electrode", {LArWheelCalculator::OuterElectrodWheel, -1} }, + { "LAr::EMEC::Neg::OuterWheel::Electrode", {LArG4::OuterElectrodWheel, -1} }, - { "LAr::EMEC::InnerModule::Absorber", {LArWheelCalculator::InnerAbsorberModule, 1} }, + { "LAr::EMEC::InnerModule::Absorber", {LArG4::InnerAbsorberModule, 1} }, - { "LAr::EMEC::OuterModule::Absorber", {LArWheelCalculator::OuterAbsorberModule, 1} }, + { "LAr::EMEC::OuterModule::Absorber", {LArG4::OuterAbsorberModule, 1} }, - { "LAr::EMEC::InnerModule::Electrode", {LArWheelCalculator::InnerElectrodModule, 1} }, + { "LAr::EMEC::InnerModule::Electrode", {LArG4::InnerElectrodModule, 1} }, - { "LAr::EMEC::OuterModule::Electrode", {LArWheelCalculator::OuterElectrodModule, 1} }, + { "LAr::EMEC::OuterModule::Electrode", {LArG4::OuterElectrodModule, 1} }, - { "LAr::EMEC::InnerWheel::Glue", {LArWheelCalculator::InnerGlueWheel, 1} }, - { "LAr::EMEC::Pos::InnerWheel::Glue", {LArWheelCalculator::InnerGlueWheel, 1} }, + { "LAr::EMEC::InnerWheel::Glue", {LArG4::InnerGlueWheel, 1} }, + { "LAr::EMEC::Pos::InnerWheel::Glue", {LArG4::InnerGlueWheel, 1} }, - { "LAr::EMEC::InnerWheel::Lead", {LArWheelCalculator::InnerLeadWheel, 1} }, - { "LAr::EMEC::Pos::InnerWheel::Lead", {LArWheelCalculator::InnerLeadWheel, 1} }, + { "LAr::EMEC::InnerWheel::Lead", {LArG4::InnerLeadWheel, 1} }, + { "LAr::EMEC::Pos::InnerWheel::Lead", {LArG4::InnerLeadWheel, 1} }, - { "LAr::EMEC::OuterWheel::Glue", {LArWheelCalculator::OuterGlueWheel, 1} }, - { "LAr::EMEC::Pos::OuterWheel::Glue", {LArWheelCalculator::OuterGlueWheel, 1} }, + { "LAr::EMEC::OuterWheel::Glue", {LArG4::OuterGlueWheel, 1} }, + { "LAr::EMEC::Pos::OuterWheel::Glue", {LArG4::OuterGlueWheel, 1} }, - { "LAr::EMEC::OuterWheel::Lead", {LArWheelCalculator::OuterLeadWheel, 1} }, - { "LAr::EMEC::Pos::OuterWheel::Lead", {LArWheelCalculator::OuterLeadWheel, 1} }, + { "LAr::EMEC::OuterWheel::Lead", {LArG4::OuterLeadWheel, 1} }, + { "LAr::EMEC::Pos::OuterWheel::Lead", {LArG4::OuterLeadWheel, 1} }, - { "LAr::EMEC::Neg::InnerWheel::Glue", {LArWheelCalculator::InnerGlueWheel, -1} }, + { "LAr::EMEC::Neg::InnerWheel::Glue", {LArG4::InnerGlueWheel, -1} }, - { "LAr::EMEC::Neg::OuterWheel::Glue", {LArWheelCalculator::OuterGlueWheel, -1} }, + { "LAr::EMEC::Neg::OuterWheel::Glue", {LArG4::OuterGlueWheel, -1} }, - { "LAr::EMEC::Neg::InnerWheel::Lead", {LArWheelCalculator::InnerLeadWheel, -1} }, + { "LAr::EMEC::Neg::InnerWheel::Lead", {LArG4::InnerLeadWheel, -1} }, - { "LAr::EMEC::Neg::OuterWheel::Lead", {LArWheelCalculator::OuterLeadWheel, -1} } + { "LAr::EMEC::Neg::OuterWheel::Lead", {LArG4::OuterLeadWheel, -1} } }; LArCustomShape::LArCustomShape(const std::string& a_shapeName) @@ -69,79 +69,79 @@ LArCustomShape::LArCustomShape(const std::string& a_shapeName) { // if(a_shapeName == "LAr::EMEC::InnerWheel::Absorber" || a_shapeName == "LAr::EMEC::Pos::InnerWheel::Absorber"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerAbsorberWheel, 1); +// new LArWheelCalculator(LArG4::InnerAbsorberWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::OuterWheel::Absorber" || a_shapeName == "LAr::EMEC::Pos::OuterWheel::Absorber"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterAbsorberWheel, 1); +// new LArWheelCalculator(LArG4::OuterAbsorberWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::InnerWheel::Electrode" || a_shapeName == "LAr::EMEC::Pos::InnerWheel::Electrode"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerElectrodWheel, 1); +// new LArWheelCalculator(LArG4::InnerElectrodWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::OuterWheel::Electrode"|| a_shapeName == "LAr::EMEC::Pos::OuterWheel::Electrode"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterElectrodWheel, 1); +// new LArWheelCalculator(LArG4::OuterElectrodWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::Neg::InnerWheel::Absorber"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerAbsorberWheel, -1); +// new LArWheelCalculator(LArG4::InnerAbsorberWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::Neg::OuterWheel::Absorber"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterAbsorberWheel, -1); +// new LArWheelCalculator(LArG4::OuterAbsorberWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::Neg::InnerWheel::Electrode"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerElectrodWheel, -1); +// new LArWheelCalculator(LArG4::InnerElectrodWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::Neg::OuterWheel::Electrode"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterElectrodWheel, -1); +// new LArWheelCalculator(LArG4::OuterElectrodWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::InnerModule::Absorber"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerAbsorberModule, 1); +// new LArWheelCalculator(LArG4::InnerAbsorberModule, 1); // } // else if(a_shapeName == "LAr::EMEC::OuterModule::Absorber"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterAbsorberModule, 1); +// new LArWheelCalculator(LArG4::OuterAbsorberModule, 1); // } // else if(a_shapeName == "LAr::EMEC::InnerModule::Electrode"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerElectrodModule, 1); +// new LArWheelCalculator(LArG4::InnerElectrodModule, 1); // } // else if(a_shapeName == "LAr::EMEC::OuterModule::Electrode"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterElectrodModule, 1); +// new LArWheelCalculator(LArG4::OuterElectrodModule, 1); // } // else if(a_shapeName == "LAr::EMEC::InnerWheel::Glue" || a_shapeName == "LAr::EMEC::Pos::InnerWheel::Glue"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerGlueWheel, 1); +// new LArWheelCalculator(LArG4::InnerGlueWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::InnerWheel::Lead" || a_shapeName == "LAr::EMEC::Pos::InnerWheel::Lead"){ // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerLeadWheel, 1); +// new LArWheelCalculator(LArG4::InnerLeadWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::OuterWheel::Glue" || a_shapeName == "LAr::EMEC::Pos::OuterWheel::Glue"){ -// m_calculator = new LArWheelCalculator(LArWheelCalculator::OuterGlueWheel, 1); +// m_calculator = new LArWheelCalculator(LArG4::OuterGlueWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::OuterWheel::Lead" || a_shapeName == "LAr::EMEC::Pos::OuterWheel::Lead"){ -// m_calculator = new LArWheelCalculator(LArWheelCalculator::OuterLeadWheel, 1); +// m_calculator = new LArWheelCalculator(LArG4::OuterLeadWheel, 1); // } // else if(a_shapeName == "LAr::EMEC::Neg::InnerWheel::Glue") { // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::InnerGlueWheel, -1); +// new LArWheelCalculator(LArG4::InnerGlueWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::Neg::OuterWheel::Glue" ) { // m_calculator = -// new LArWheelCalculator(LArWheelCalculator::OuterGlueWheel, -1); +// new LArWheelCalculator(LArG4::OuterGlueWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::Neg::InnerWheel::Lead") { -// m_calculator = new LArWheelCalculator(LArWheelCalculator::InnerLeadWheel, -1); +// m_calculator = new LArWheelCalculator(LArG4::InnerLeadWheel, -1); // } // else if(a_shapeName == "LAr::EMEC::Neg::OuterWheel::Lead") { -// m_calculator = new LArWheelCalculator(LArWheelCalculator::OuterLeadWheel, -1); +// m_calculator = new LArWheelCalculator(LArG4::OuterLeadWheel, -1); // } else { // std::string error = "Unknown name "; // error += a_shapeName; @@ -162,8 +162,8 @@ LArCustomShape::~LArCustomShape() //delete m_calculator; } -StatusCode LArCustomShape::createCalculator(const CalcDef_t & cdef) { // LArWheelCalculator::LArWheelCalculator_t wheelType, int zside - LArWheelCalculator::LArWheelCalculator_t wheelType = cdef.first; +StatusCode LArCustomShape::createCalculator(const CalcDef_t & cdef) { // LArG4::LArWheelCalculator_t wheelType, int zside + LArG4::LArWheelCalculator_t wheelType = cdef.first; int zside = cdef.second; m_calculator = new LArWheelCalculator(wheelType, zside); diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator.cxx b/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator.cxx index c28b89609b40..93e4c704bb8b 100644 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator.cxx +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator.cxx @@ -70,29 +70,29 @@ static const double default_slant_parametrization[2][5] = { { -34.254, 0.15528, -0.11670E-03, 0.45018E-07, -0.68473E-11 } //outer }; -const char *LArWheelCalculator::LArWheelCalculatorTypeString(LArWheelCalculator_t type) +const char *LArWheelCalculator::LArWheelCalculatorTypeString(LArG4::LArWheelCalculator_t type) { switch(type){ - case InnerAbsorberWheel: return("InnerAbsorberWheel"); - case OuterAbsorberWheel: return("OuterAbsorberWheel"); - case InnerElectrodWheel: return("InnerElectrodWheel"); - case OuterElectrodWheel: return("OuterElectrodWheel"); - case InnerAbsorberModule: return("InnerAbsorberModule"); - case OuterAbsorberModule: return("OuterAbsorberModule"); - case InnerElectrodModule: return("InnerElectrodModule"); - case OuterElectrodModule: return("OuterElectrodModule"); - case BackOuterBarretteWheel: return("BackOuterBarretteWheel"); - case BackInnerBarretteWheel: return("BackInnerBarretteWheel"); - case BackOuterBarretteModule: return("BackOuterBarretteModule"); - case BackInnerBarretteModule: return("BackInnerBarretteModule"); - case BackOuterBarretteWheelCalib: return("BackOuterBarretteWheelCalib"); - case BackInnerBarretteWheelCalib: return("BackInnerBarretteWheelCalib"); - case BackOuterBarretteModuleCalib: return("BackOuterBarretteModuleCalib"); - case BackInnerBarretteModuleCalib: return("BackInnerBarretteModuleCalib"); - case InnerGlueWheel: return("InnerGlueWheel"); - case InnerLeadWheel: return("InnerLeadWheel"); - case OuterGlueWheel: return("OuterGlueWheel"); - case OuterLeadWheel: return("OuterLeadWheel"); + case LArG4::InnerAbsorberWheel: return("InnerAbsorberWheel"); + case LArG4::OuterAbsorberWheel: return("OuterAbsorberWheel"); + case LArG4::InnerElectrodWheel: return("InnerElectrodWheel"); + case LArG4::OuterElectrodWheel: return("OuterElectrodWheel"); + case LArG4::InnerAbsorberModule: return("InnerAbsorberModule"); + case LArG4::OuterAbsorberModule: return("OuterAbsorberModule"); + case LArG4::InnerElectrodModule: return("InnerElectrodModule"); + case LArG4::OuterElectrodModule: return("OuterElectrodModule"); + case LArG4::BackOuterBarretteWheel: return("BackOuterBarretteWheel"); + case LArG4::BackInnerBarretteWheel: return("BackInnerBarretteWheel"); + case LArG4::BackOuterBarretteModule: return("BackOuterBarretteModule"); + case LArG4::BackInnerBarretteModule: return("BackInnerBarretteModule"); + case LArG4::BackOuterBarretteWheelCalib: return("BackOuterBarretteWheelCalib"); + case LArG4::BackInnerBarretteWheelCalib: return("BackInnerBarretteWheelCalib"); + case LArG4::BackOuterBarretteModuleCalib: return("BackOuterBarretteModuleCalib"); + case LArG4::BackInnerBarretteModuleCalib: return("BackInnerBarretteModuleCalib"); + case LArG4::InnerGlueWheel: return("InnerGlueWheel"); + case LArG4::InnerLeadWheel: return("InnerLeadWheel"); + case LArG4::OuterGlueWheel: return("OuterGlueWheel"); + case LArG4::OuterLeadWheel: return("OuterLeadWheel"); } return("unknown"); } @@ -104,7 +104,7 @@ LArWheelCalculator::~LArWheelCalculator() { m_fanCalcImpl = 0; } -LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zside) : +LArWheelCalculator::LArWheelCalculator(LArG4::LArWheelCalculator_t a_wheelType, int zside) : m_type(a_wheelType), m_AtlasZside(zside), m_distanceCalcImpl(0), @@ -120,15 +120,15 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi MsgStream msg(msgSvc, "LArWheelCalculator"); msg << MSG::VERBOSE << "LArWheelCalculator constructor at " << this << " (type " << LArWheelCalculatorTypeString(m_type) - << "):" << endreq; + << "):" << endmsg; #ifdef LARWC_DTNF_NEW - msg << MSG::VERBOSE << "compiled with new DTNF" << endreq; + msg << MSG::VERBOSE << "compiled with new DTNF" << endmsg; #endif // Access source of detector parameters. msg << MSG::VERBOSE - << "initializing data members from DB..." << endreq; + << "initializing data members from DB..." << endmsg; IGeoModelSvc *geoModel; IRDBAccessSvc* rdbAccess; @@ -204,11 +204,11 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi << "m_zShift : " << m_zShift / cm << " [cm]" << std::endl << "Phi rotation : " << (m_phiRotation? "true": "false") << std::endl << "eta wheels limits : " << m_eta_low << ", " << m_eta_mid << ", " << m_eta_hi - << endreq; + << endmsg; msg << MSG::VERBOSE << "hardcoded constants: " << std::endl << "m_WheelThickness : " << m_WheelThickness / cm << " [cm]" << std::endl << "m_dWRPtoFrontFace : " << m_dWRPtoFrontFace / cm << " [cm]" - << endreq; + << endmsg; // Constructor initializes the geometry. @@ -221,78 +221,78 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi m_LastFan = 0; switch(m_type){ - case BackInnerBarretteWheelCalib: - m_isBarretteCalib = true; - case BackInnerBarretteWheel: - m_isBarrette = true; - m_type = InnerAbsorberWheel; - case InnerAbsorberWheel: - case InnerGlueWheel: - case InnerLeadWheel: - inner_wheel_init(EmecWheelParameters_recs); - m_ZeroFanPhi = m_FanStepOnPhi * 0.5; - if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; - break; - case BackOuterBarretteWheelCalib: - m_isBarretteCalib = true; - case BackOuterBarretteWheel: - m_isBarrette = true; - m_type = OuterAbsorberWheel; - case OuterAbsorberWheel: - case OuterGlueWheel: - case OuterLeadWheel: - outer_wheel_init(EmecWheelParameters_recs); - m_ZeroFanPhi = m_FanStepOnPhi * 0.5; - if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; - break; - case InnerElectrodWheel: - inner_wheel_init(EmecWheelParameters_recs); - m_ZeroFanPhi = 0; - if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; - m_isElectrode = true; - break; - case OuterElectrodWheel: - outer_wheel_init(EmecWheelParameters_recs); - m_ZeroFanPhi = 0; - if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; - m_isElectrode = true; - break; - case BackInnerBarretteModuleCalib: - m_isBarretteCalib = true; - case BackInnerBarretteModule: - m_isBarrette = true; - m_type = InnerAbsorberModule; - case InnerAbsorberModule: - inner_wheel_init(EmecWheelParameters_recs); - module_init(); - m_ZeroFanPhi += m_FanStepOnPhi * 0.5; - // later for all? m_ZeroFanPhi_ForDetNeaFan = m_ZeroFanPhi - m_FanStepOnPhi * 0.5; - break; - case BackOuterBarretteModuleCalib: - m_isBarretteCalib = true; - case BackOuterBarretteModule: - m_isBarrette = true; - m_type = OuterAbsorberModule; - case OuterAbsorberModule: - outer_wheel_init(EmecWheelParameters_recs); - module_init(); - m_ZeroFanPhi += m_FanStepOnPhi * 0.5; - // later for all? m_ZeroFanPhi_ForDetNeaFan = m_ZeroFanPhi - m_FanStepOnPhi * 0.5; - break; - case InnerElectrodModule: - inner_wheel_init(EmecWheelParameters_recs); - module_init(); - m_FirstFan ++; - m_isElectrode = true; - break; - case OuterElectrodModule: - outer_wheel_init(EmecWheelParameters_recs); - module_init(); - m_FirstFan ++; - m_isElectrode = true; - break; - default: - throw std::runtime_error("LArWheelCalculator constructor:unknown LArWheelCalculator_t"); + case LArG4::BackInnerBarretteWheelCalib: + m_isBarretteCalib = true; + case LArG4::BackInnerBarretteWheel: + m_isBarrette = true; + m_type = LArG4::InnerAbsorberWheel; + case LArG4::InnerAbsorberWheel: + case LArG4::InnerGlueWheel: + case LArG4::InnerLeadWheel: + inner_wheel_init(EmecWheelParameters_recs); + m_ZeroFanPhi = m_FanStepOnPhi * 0.5; + if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; + break; + case LArG4::BackOuterBarretteWheelCalib: + m_isBarretteCalib = true; + case LArG4::BackOuterBarretteWheel: + m_isBarrette = true; + m_type = LArG4::OuterAbsorberWheel; + case LArG4::OuterAbsorberWheel: + case LArG4::OuterGlueWheel: + case LArG4::OuterLeadWheel: + outer_wheel_init(EmecWheelParameters_recs); + m_ZeroFanPhi = m_FanStepOnPhi * 0.5; + if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; + break; + case LArG4::InnerElectrodWheel: + inner_wheel_init(EmecWheelParameters_recs); + m_ZeroFanPhi = 0; + if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; + m_isElectrode = true; + break; + case LArG4::OuterElectrodWheel: + outer_wheel_init(EmecWheelParameters_recs); + m_ZeroFanPhi = 0; + if(m_phiRotation) m_ZeroFanPhi += m_FanStepOnPhi * 0.5; + m_isElectrode = true; + break; + case LArG4::BackInnerBarretteModuleCalib: + m_isBarretteCalib = true; + case LArG4::BackInnerBarretteModule: + m_isBarrette = true; + m_type = LArG4::InnerAbsorberModule; + case LArG4::InnerAbsorberModule: + inner_wheel_init(EmecWheelParameters_recs); + module_init(); + m_ZeroFanPhi += m_FanStepOnPhi * 0.5; + // later for all? m_ZeroFanPhi_ForDetNeaFan = m_ZeroFanPhi - m_FanStepOnPhi * 0.5; + break; + case LArG4::BackOuterBarretteModuleCalib: + m_isBarretteCalib = true; + case LArG4::BackOuterBarretteModule: + m_isBarrette = true; + m_type = LArG4::OuterAbsorberModule; + case LArG4::OuterAbsorberModule: + outer_wheel_init(EmecWheelParameters_recs); + module_init(); + m_ZeroFanPhi += m_FanStepOnPhi * 0.5; + // later for all? m_ZeroFanPhi_ForDetNeaFan = m_ZeroFanPhi - m_FanStepOnPhi * 0.5; + break; + case LArG4::InnerElectrodModule: + inner_wheel_init(EmecWheelParameters_recs); + module_init(); + m_FirstFan ++; + m_isElectrode = true; + break; + case LArG4::OuterElectrodModule: + outer_wheel_init(EmecWheelParameters_recs); + module_init(); + m_FirstFan ++; + m_isElectrode = true; + break; + default: + throw std::runtime_error("LArWheelCalculator constructor:unknown LArWheelCalculator_t"); } m_ZeroFanPhi_ForDetNeaFan = m_ZeroFanPhi - m_FanStepOnPhi * 0.5; m_NumberOfHalfWaves = m_NumberOfWaves * 2; @@ -305,16 +305,16 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi // value read above // std::string sagging_opt_value = (*DB_EMECParams)[0]->getString("SAGGING"); - msg << MSG::VERBOSE << "SAGGING value = " << sagging_opt_value << endreq; + msg << MSG::VERBOSE << "SAGGING value = " << sagging_opt_value << endmsg; // the same condition is in DistanceCalculatorFactory::Create m_SaggingOn = (sagging_opt_value != "" && sagging_opt_value != "off")? true: false; m_distanceCalcImpl = LArWheelCalculator_Impl::DistanceCalculatorFactory::Create(sagging_opt_value, this, rdbAccess, larVersionKey); if (m_SaggingOn) { - msg << MSG::VERBOSE << "Creating DistanceCalculatorSaggingOn = " << this << ',' << m_distanceCalcImpl << endreq; + msg << MSG::VERBOSE << "Creating DistanceCalculatorSaggingOn = " << this << ',' << m_distanceCalcImpl << endmsg; } else { - msg << MSG::VERBOSE << "Creating DistanceCalculatorSaggingOff = " << this << ',' << m_distanceCalcImpl << endreq; + msg << MSG::VERBOSE << "Creating DistanceCalculatorSaggingOff = " << this << ',' << m_distanceCalcImpl << endmsg; } m_fanCalcImpl = LArWheelCalculator_Impl::FanCalculatorFactory::Create(m_SaggingOn, m_isModule, this, rdbAccess, larVersionKey); @@ -334,7 +334,7 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi EMECParams_recs.param(slant_params, "OUTERSLANTPARAM"); } - msg << (m_isInner?" InnerWheel ":" OuterWheel ") << slant_params << endreq; + msg << (m_isInner?" InnerWheel ":" OuterWheel ") << slant_params << endmsg; if(slant_params != "" && slant_params != "default"){ double a, b, c, d, e; @@ -343,7 +343,7 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi << "LArWheelCalculator: ERROR: wrong value(s) " << "for EMEC slant angle parameters: " << slant_params << ", " - << "defaults are used" << endreq; + << "defaults are used" << endmsg; } else { m_slant_parametrization[0] = a; m_slant_parametrization[1] = b; @@ -356,7 +356,7 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi fill_sincos_parameterization(); // initialize sin&cos parameterization - msg << MSG::VERBOSE << "All params initialized. Print some internal variables" << endreq; + msg << MSG::VERBOSE << "All params initialized. Print some internal variables" << endmsg; msg << MSG::VERBOSE << "Data members:" << std::endl << "m_AtlasZside = " << m_AtlasZside << std::endl @@ -372,14 +372,14 @@ LArWheelCalculator::LArWheelCalculator(LArWheelCalculator_t a_wheelType, int zsi << "SaggingOn = " << (m_SaggingOn? "true": "false") << std::endl << "Slant parameters : "; for(int i = 0; i < 5; i ++) msg << " " << m_slant_parametrization[i]; - msg << endreq; + msg << endmsg; if(m_isModule){ msg << MSG::VERBOSE << "module_init: FirstFan = " << m_FirstFan << ", LastFan = " << m_LastFan << ", ZeroFanPhi = " << m_ZeroFanPhi - << endreq; + << endmsg; } //m_fan_number = -1000; @@ -448,41 +448,41 @@ void LArWheelCalculator::outer_wheel_init(const RDBParamRecords & EmecWheelParam } -double LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator_t t) +double LArWheelCalculator::GetFanHalfThickness(LArG4::LArWheelCalculator_t t) { switch(t){ - case BackInnerBarretteWheelCalib: - case BackInnerBarretteModuleCalib: - case BackInnerBarretteWheel: - case BackInnerBarretteModule: - case InnerAbsorberWheel: - case InnerAbsorberModule: - // return (2.2 / 2 + 0.2 + 0.15) * mm; - return (2.2 / 2 + 0.2 + 0.1)*0.997 * mm; // new values, 02.11.06 J.T. with contraction in cold - // lead / 2 + steel + glue - case InnerGlueWheel: - return (2.2 / 2 + 0.1)*0.997 * mm; - case InnerLeadWheel: - return 2.2 / 2 * 0.997 * mm; - - case BackOuterBarretteWheelCalib: - case BackOuterBarretteModuleCalib: - case BackOuterBarretteWheel: - case BackOuterBarretteModule: - case OuterAbsorberWheel: - case OuterAbsorberModule: - //return (1.7 / 2 + 0.2 + 0.15) * mm; - return (1.69 / 2 + 0.2 + 0.1)*0.997 * mm; // new values, 02.11.06 J.T. - case OuterGlueWheel: - return (1.69 / 2 + 0.1)*0.997 * mm; - case OuterLeadWheel: - return 1.69 / 2 * 0.997 * mm; - - case InnerElectrodWheel: - case OuterElectrodWheel: - case InnerElectrodModule: - case OuterElectrodModule: - return 0.275/1.0036256 *mm * 0.5; //new values, 02.11.06 J.T + case LArG4::BackInnerBarretteWheelCalib: + case LArG4::BackInnerBarretteModuleCalib: + case LArG4::BackInnerBarretteWheel: + case LArG4::BackInnerBarretteModule: + case LArG4::InnerAbsorberWheel: + case LArG4::InnerAbsorberModule: + // return (2.2 / 2 + 0.2 + 0.15) * mm; + return (2.2 / 2 + 0.2 + 0.1)*0.997 * mm; // new values, 02.11.06 J.T. with contraction in cold + // lead / 2 + steel + glue + case LArG4::InnerGlueWheel: + return (2.2 / 2 + 0.1)*0.997 * mm; + case LArG4::InnerLeadWheel: + return 2.2 / 2 * 0.997 * mm; + + case LArG4::BackOuterBarretteWheelCalib: + case LArG4::BackOuterBarretteModuleCalib: + case LArG4::BackOuterBarretteWheel: + case LArG4::BackOuterBarretteModule: + case LArG4::OuterAbsorberWheel: + case LArG4::OuterAbsorberModule: + //return (1.7 / 2 + 0.2 + 0.15) * mm; + return (1.69 / 2 + 0.2 + 0.1)*0.997 * mm; // new values, 02.11.06 J.T. + case LArG4::OuterGlueWheel: + return (1.69 / 2 + 0.1)*0.997 * mm; + case LArG4::OuterLeadWheel: + return 1.69 / 2 * 0.997 * mm; + + case LArG4::InnerElectrodWheel: + case LArG4::OuterElectrodWheel: + case LArG4::InnerElectrodModule: + case LArG4::OuterElectrodModule: + return 0.275/1.0036256 *mm * 0.5; //new values, 02.11.06 J.T } throw std::runtime_error("LArWheelCalculator::GetFanHalfThickness: wrong wheel type"); } diff --git a/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx b/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx index 4dc78e76a89e..3ea2bdb4a90b 100644 --- a/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx +++ b/DetectorDescription/GeoModel/GeoSpecialShapes/src/LArWheelCalculator_Impl/DistanceCalculatorSaggingOn.cxx @@ -53,13 +53,13 @@ namespace LArWheelCalculator_Impl { std::string sag_file = sagging_opt_value.substr(5); msg << MSG::DEBUG << "geting sagging parameters from file " - << sag_file << " ..." << endreq; + << sag_file << " ..." << endmsg; FILE *F = fopen(sag_file.c_str(), "r"); if(F == 0){ msg << MSG::FATAL << "cannot open EMEC sagging parameters file " << sag_file - << endreq; + << endmsg; throw std::runtime_error("LArWheelCalculator: read sagging parameters from file"); } int s, w, t, n; @@ -81,7 +81,7 @@ namespace LArWheelCalculator_Impl { msg << MSG::VERBOSE << "sagging for " << s << " " << w << " " << t << " " << n << ": " << p0 << " " << p1 << " " - << p2 << " " << p3 << endreq; + << p2 << " " << p3 << endmsg; } } fclose(F); @@ -91,7 +91,7 @@ namespace LArWheelCalculator_Impl { msg << MSG::ERROR << "wrong value(s) " << " for EMEC sagging parameters: " - << sagging_opt_value << ", defaults are used" << endreq; + << sagging_opt_value << ", defaults are used" << endmsg; } else { for(int j = 0; j < lwc()->m_NumberOfFans; j ++){ if(lwc()->m_isInner){ @@ -106,7 +106,7 @@ namespace LArWheelCalculator_Impl { } // } msg << MSG::INFO << "Sagging parameters : " << m_sagging_parameter[0][0] << " " << m_sagging_parameter[0][1] << std::endl - << "Sagging parameters : " << m_sagging_parameter[1][0] << " " << m_sagging_parameter[1][1] << endreq; + << "Sagging parameters : " << m_sagging_parameter[1][0] << " " << m_sagging_parameter[1][1] << endmsg; } // Represents aproximate, probably underestimate, distance to the // neutral fibre of the vertical fan. Sign of return value means diff --git a/LArCalorimeter/LArG4/LArG4Barrel/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4Barrel/CMakeLists.txt index 680a9fdfa2f3..3235bc9a50ec 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4Barrel/CMakeLists.txt @@ -6,15 +6,13 @@ atlas_subdir( LArG4Barrel ) # Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC +atlas_depends_on_subdirs( PRIVATE Calorimeter/CaloG4Sim - LArCalorimeter/LArG4/LArG4Code - PRIVATE Control/AthenaKernel Control/CxxUtils Control/StoreGate GaudiKernel - LArCalorimeter/LArG4/LArG4RunControl + LArCalorimeter/LArG4/LArG4Code LArCalorimeter/LArGeoModel/LArHV Tools/PathResolver ) @@ -24,11 +22,11 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_library( LArG4Barrel - src/*.cc - PUBLIC_HEADERS LArG4Barrel +atlas_add_component( LArG4Barrel + src/*.cxx src/components/*.cxx INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} LArG4Code CaloG4SimLib StoreGateLib SGtests PRIVATE_LINK_LIBRARIES AthenaKernel CxxUtils GaudiKernel LArG4RunControl LArHV PathResolver ) +atlas_install_python_modules( python/*.py ) diff --git a/LArCalorimeter/LArG4/LArG4Barrel/GNUmakefile b/LArCalorimeter/LArG4/LArG4Barrel/GNUmakefile deleted file mode 100644 index 4d005538772c..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/GNUmakefile +++ /dev/null @@ -1,27 +0,0 @@ -# -------------------------------------------------------------- -# GNUmakefile for Barrel code within LArG4 -# -------------------------------------------------------------- - -name := LArG4Barrel -G4TARGET := $(name) -G4EXLIB := true - -# Note that we're only compiling a library; this GNUmakefile cannot -# create a binary on its own. - -.PHONY: all -all: lib - -# Standard G4 architecture. -include $(G4INSTALL)/config/architecture.gmk - -CPPFLAGS += $(LARG4CFLAGS) - -# Standard G4 compilation process. -include $(G4INSTALL)/config/binmake.gmk - -# Include a "realclean" to get rid of excess baggage. -.PHONY: realclean -realclean: - @echo "Also deleting old Barrel code backups..." - @rm -f *~ *.bak LArG4Barrel/*~ LArG4Barrel/*.bak src/*~ src/*.bak diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/AccMap.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/AccMap.h deleted file mode 100644 index fa4f5b0083be..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/AccMap.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef AccMap_h -#define AccMap_h - -#include "LArG4Barrel/CurrMap.h" - -#include <map> -#include <vector> -#include <string> - -typedef std::map<int, CurrMap*> curr_map; - -class AccMap { - public: - ~AccMap(); - static AccMap* GetAccMap(); - void SetDirectory(std::string dir); - void Reset(); - int Region(int region, int sampling, int eta); - void SetMap(int ifold, int ielecregion); - void SetMap(int ifold, int region, int sampling, int eta); - CurrMap* Map() {return m_curr;} - float GetXmin(int ifold) { - if (ifold<m_nmax && ifold >=0) return m_xmin[ifold]; - else return -999.;} - float GetXmax(int ifold) { - if (ifold<m_nmax && ifold >=0) return m_xmax[ifold]; - else return -999.;} - float GetYmin(int ifold) { - if (ifold<m_nmax && ifold >=0) return m_ymin[ifold]; - else return -999.;} - float GetYmax(int ifold) { - if (ifold<m_nmax && ifold >=0) return m_ymax[ifold]; - else return -999.;} - private: - AccMap(); - static AccMap* s_thePointer; - curr_map m_theMap; - std::string m_directory; -// current map info - CurrMap* m_curr; - int m_fold; - int m_region; - int m_eta; - int m_sampling; - int m_elecregion; - int m_nmax; - std::vector<float> m_xmin; - std::vector<float> m_xmax; - std::vector<float> m_ymin; - std::vector<float> m_ymax; -}; -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CurrMap.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CurrMap.h deleted file mode 100644 index d3b8361214f4..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CurrMap.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef CurrMap_h -#define CurrMap_h - -#include <string> - -class CurrMap { - public: - CurrMap(std::string filename, double xnorm); - ~CurrMap(); - int GetNx() { return m_nx;} - float GetXmin() { return m_xmin;} - float GetXmax() { return m_xmax;} - float GetDx() { return m_dx;} - int GetNy() { return m_ny;} - float GetYmin() { return m_ymin;} - float GetYmax() { return m_ymax;} - float GetDy() { return m_dy;} - float GetGap(int ix,int iy) {return m_gap[iy*m_nx+ix];} - float GetCurr0(int ix,int iy) {return m_curr0[iy*m_nx+ix];} - float GetCurr1(int ix,int iy) {return m_curr1[iy*m_nx+ix];} - float GetCurr2(int ix,int iy) {return m_curr2[iy*m_nx+ix];} - void GetAll(double x, double y, double* gap, double* curr0,double* curr1,double* curr2); - private: - CurrMap(const CurrMap&);//coverity issue fix. Declared, but not implemented - CurrMap& operator=(const CurrMap&);//coverity issue fix. Declared, but not implemented - int m_nx,m_ny; - float m_xmin,m_xmax,m_dx,m_ymin,m_ymax,m_dy; - float *m_gap,*m_curr0,*m_curr1,*m_curr2; - float m_norm; - -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalculator.h deleted file mode 100644 index 5362de5d0f31..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalculator.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArBarrelCalculator.hh -// The Cell Identifier for the EM Barrel readout cells - -// Adapted from code written by Gaston Parrour -// Adaptation by Sylvain Negroni - -// 12-Jul-2002 WGS: Added LArG4Identifier. - -// 18-03-2005 G.Unal: major revision to include new current maps -class LArG4BirksLaw; -#ifndef LARBARRELCALCULATOR_H -#define LARBARRELCALCULATOR_H - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include "LArG4Barrel/LArBarrelGeometry.h" - -#include <stdexcept> -#include <vector> -#include <string> -#include <memory> - -class G4Step; -class AccMap; -class MapEta; - -class LArBarrelCalculator : public LArVCalculator -{ -public: - - // Accessor method for singleton pattern. - static LArBarrelCalculator* GetCalculator(); - - // Destructor - ~LArBarrelCalculator(); - - LArBarrelCalculator (const LArBarrelCalculator&) = delete; - LArBarrelCalculator& operator= (const LArBarrelCalculator&) = delete; - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata); - - // - // get functions: - // - virtual G4float OOTcut() const { return m_OOTcut; } - - virtual int getNumHits() const {return m_nhits;} - virtual const LArG4Identifier& identifier(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - if(static_cast<int>(m_hdata.size())<=i) throw std::range_error("No such hit yet"); - return m_hdata[i].id; } - virtual G4double time(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - if(static_cast<int>(m_hdata.size())<=i) throw std::range_error("No such hit yet"); - return m_hdata[i].time; } - virtual G4double energy(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - if(static_cast<int>(m_hdata.size())<=i) throw std::range_error("No such hit yet"); - return m_hdata[i].energy; }; - virtual G4bool isInTime(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - return m_isInTime[i]; } - virtual G4bool isOutOfTime(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - return ( ! m_isInTime[i] ); } - - inline void detectorName(std::string name) { m_detectorName=name; } - -protected: - // The constructor is protected according to the 'singleton' design - // pattern. - LArBarrelCalculator(); - -private: - - static LArBarrelCalculator* m_instance; - - LArVG4DetectorParameters* m_parameters; - LArG4::Barrel::Geometry* m_geometry; - AccMap* m_accmap; - std::unique_ptr<MapEta> m_etamap1; - std::unique_ptr<MapEta> m_etamap2; - std::unique_ptr<MapEta> m_etamap3; - - G4float m_OOTcut; - - // RUN Options - bool m_IflCur; - bool m_IflMapTrans; - bool m_IflXtalk; - - double m_dstep; - - const LArG4BirksLaw *m_birksLaw; - bool m_doHV; - - - // detector name, for translated geometry - std::string m_detectorName; - - // global EMBarrel dimensions - double m_etaMaxBarrel; - double m_zMinBarrel; - double m_zMaxBarrel; - // global Accordion dimensions - double m_rMinAccordion; - double m_rMaxAccordion; - // half thickness of absorber and electrode - double m_ThickAbs; - double m_ThickEle; - // GU 11/06/2003 total number of cells in phi - int m_NCellTot; - int m_NCellMax; - // to handle small difference (mostly phi wrapping and +-z symmetry) - // between atlas and test beam - bool m_testbeam; - - // The results of the Process calculation: - int m_nhits; // number of hits - //std::vector<LArG4Identifier> m_identifier; // hit identifier - //std::vector<G4double> m_energy; // energy (or current) - //std::vector<G4double> m_time; // time - std::vector<LArHitData> m_hdata; - - std::vector<G4bool> m_isInTime; // hit in time ? - LArG4Identifier m_identifier2; - LArG4Identifier m_identifier_xt1; - LArG4Identifier m_identifier_xt2; - -// Hv values -// 0,1 = positive/negative barrel -// 0->1023 = electrode number -// 0->6 = eta region number (0.2 granularity) (1.2 to 1.475 in same eta bin) -// 0,1 = below, above the electrode (according to phi in global Atlas frame) - - double m_hv[2][1024][7][2]; - - G4bool FiducialCuts(G4double,G4double,G4double); - - void InitHV(); - double ScaleHV(double, double, double, double); - -}; - -#endif // LARBARRELCALCULATOR_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelGeometry.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelGeometry.h deleted file mode 100644 index 81b2e70a25f7..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelGeometry.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArBarrelGeometry.hh - -#ifndef LARBARRELGEOMETRY_H -#define LARBARRELGEOMETRY_H - -//#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include "G4ThreeVector.hh" -#include "G4StepPoint.hh" -#include "G4Step.hh" -#include "G4LogicalVolume.hh" -#include "G4LogicalVolumeStore.hh" -#include "G4TouchableHistory.hh" - -#include <string> - -// Forward declarations. -class LArG4Identifier; -class G4Step; -class LArCoudeElectrodes; -class LArCoudeAbsorbers; -class LArStraightAbsorbers; -class LArStraightElectrodes; - -namespace LArG4 { - -namespace Barrel { - -class Geometry { - - public: - - // Accessor method for singleton pattern. - static Geometry* GetInstance(); - - virtual ~Geometry(); - -// Full identifier computation from a G4 step - LArG4Identifier CalculateIdentifier( const G4Step* ,std::string strDetector=""); - LArG4Identifier CalculateECAMIdentifier( const G4Step* , const G4int indEcam, std::string strDetector="",const bool inSTAC=true,int zside=1); - -// Get geometry informations (filled with findCell) -// cellID = 1 valid, 0 invalid -// sampling = sampling number (1 to 3) -// region = 0 (eta<1.) or 1 (1.4<eta<1.475) -// etaBin = cell number in eta -// phiBin = cell number in phi -// phiGap = gap number in phi (0 to 1023) -// nstraight = straight section number (0 to 13) -// nfold = closest fold number (0 to 14) -// distElec = distance to electode (signed) -// distAbs = distance to absorber (signed) -// x0,y0 = local coordinates in first cell frame (to be used for current maps) - int cellID() { return m_cellID;}; - G4int sampling() { return m_sampling;}; - G4int region() { return m_region;}; - G4int etaBin() { return m_etaBin;}; - G4int phiBin() { return m_phiBin;}; - G4int phiGap() { return m_phiGap;}; - G4int nstraight() {return m_nstraight;}; - G4int nfold() {return m_nfold;}; - G4double distElec() { return m_distElec;}; - G4double distAbs() { return m_distAbs;}; - G4double x0() {return m_x0;}; - G4double y0() {return m_y0;}; - G4double xl() {return m_xl;}; - G4int etaMap() {return m_etaMap;}; - G4int sampMap() {return m_sampMap;}; - - // Given a point compute all quantities (cell number, distance to electrode, etc...) - void findCell( const double & x, const double & y, const double & z, - const double & r, const double & eta, const double & phi, const bool detail, - std::string strDetector=""); - - bool CheckLArIdentifier(int sampling,int region, int eta,int phi); - bool CheckDMIdentifier(int type, int sampling, int region, int eta, int phi); - - - private: - - //copy constructor - Geometry(const Geometry& );//coverity issue fix. Declared, but not implemented - Geometry& operator=(const Geometry&);//coverity issue fix. Declared, but not implemented - - static Geometry* m_instance; - - bool m_FIRST; - - // global EMBarrel dimensions - double m_rMinAccordion; - double m_rMaxAccordion; - double m_zMinBarrel; - double m_zMaxBarrel; - double m_etaMaxBarrel; - - // GU 11/06/2003 total number of cells in phi - int m_NCellTot; // either 64 or 1024 for TestBeam or Atlas - int m_NCellMax; // 1024 - - // Accordion parameters - int m_Nbrt; // number of straight sections (=14) - int m_Nbrt1; // number of folds (=15) - - // Accordion parameters, refering to the neutral fibre - double m_gam0 ; //phi position for the first absorber neutral fiber - double m_rint_eleFib ; //2.78 - double *m_rc, *m_phic, *m_xc, *m_yc, *m_delta;// double m_rc[15] ; // R and - int m_parity; - //double m_phic[15] ; // phi positions of center of fold for first absorber - // double m_xc[15]; // corresponding x,y values - // double m_yc[15]; - //double m_delta[15]; // zig-zag angles - // to access G4 geometry - LArCoudeElectrodes* m_coudeelec; - LArCoudeAbsorbers* m_coudeabs; - LArStraightElectrodes* m_electrode; - LArStraightAbsorbers* m_absorber; - - // to handle small difference (mostly phi wrapping and +-z symmetry) - // between atlas and test beam - bool m_testbeam; - - // output of computations (everything in half barrel frame except m_zSide) - int m_cellID; // 0 if not valid cell - G4int m_sampling; // sampling number (1 to 3) - G4int m_region; // region number (0 or 1) - G4int m_etaBin; // cell number in eta - G4int m_phiBin; // cell number in phi - G4int m_zSide; // side (+-1 for +-z) - G4int m_phiGap; // number (0 to 1024) of closest electrode - G4int m_nstraight; // number of straight section (0 to 13) - G4int m_nfold; // number of closest fold (0 to 14) - G4double m_distElec; // algebric distance to electrode - G4double m_distAbs; // algebric distance to absorber - G4double m_xl; // normalized lenght along electrode - G4double m_x0; // - G4double m_y0; // coordinates in local cell frame (down absorber with phi=0) - G4int m_sampMap; // sampling number not taking into account readout strips - G4int m_etaMap; // eta number not taking into account readout strips - - bool m_iflSAG; - - // intermediate values for phi cell computation - G4int m_NRphi; - G4double m_Rmin; - G4double m_Rmax; - G4double m_Rphi[5000]; - G4double m_dR; - double m_2pi; - -// function to compute distance to electrode - double Distance_Ele(const double &x, const double &y, - const int &PhiC, int &Num_Straight, const int &Num_Coude, - double &xl); - // function to compute distance to absorber - double Distance_Abs(const double &x, const double &y, - const int &nabs, const int &Num_Straight, const int &Num_Coude); - -// longitudinal and eta segmentation of electrodes - G4int SampSeg(G4double,G4double,G4double,G4int&,G4int&,G4int&,G4int&,G4int&); - -// phi vs r of first absorber in nominal geometry - void GetRphi(); - G4double Phi0(G4double); - G4int PhiGap(const double &, const double &, const double &); - - protected: - - Geometry(); - - -} ; - -} //end of Barrel namespace - -} // end of LArG4 namespace - -#endif // LARBARRELGEOMETRY_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerCalculator.h deleted file mode 100644 index 918c3fabc684..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerCalculator.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArBarrelPresamplerCalculator.hh -// Prepared 05-Dec-2002 Bill Seligman - -// A first pass at determing hit cell ID in the LAr barrel presampler. - -#ifndef LARG4BARREL_LARBARRELPRESAMPLERCALCULATOR_H -#define LARG4BARREL_LARBARRELPRESAMPLERCALCULATOR_H - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" - -#include "globals.hh" -#include <stdexcept> -// Forward declarations. -class G4Step; -class PsMap; -class LArG4BirksLaw; - -namespace LArG4 { - namespace BarrelPresampler { - // Forward declaration - class Geometry; - } -} - -class LArBarrelPresamplerCalculator : public LArVCalculator { - -public: - - // Accessor for pointer to the singleton. - static LArBarrelPresamplerCalculator* GetCalculator(); - ~LArBarrelPresamplerCalculator(); - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata); - - virtual int getNumHits() const {return m_nhits;} - virtual const LArG4Identifier& identifier(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - if(static_cast<int>(m_hdata.size())<=i) throw std::range_error("No such hit yet"); - return m_hdata[i].id; } - virtual G4double time(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - if(static_cast<int>(m_hdata.size())<=i) throw std::range_error("No such hit yet"); - return m_hdata[i].time; } - virtual G4double energy(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - if(static_cast<int>(m_hdata.size())<=i) throw std::range_error("No such hit yet"); - return m_hdata[i].energy; }; - virtual G4bool isInTime(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - return m_isInTime[i]; } - virtual G4bool isOutOfTime(int i=0) const { - if (i<0||i>=m_nhits) throw std::range_error("Hit asked is out of range"); - return ( ! m_isInTime[i] ); } - - inline void detectorName(std::string name) { m_detectorName=name; } - -protected: - // The constructor is protected according to the singleton design - // pattern. - LArBarrelPresamplerCalculator(); - -private: - - //copy constructor - LArBarrelPresamplerCalculator(const LArBarrelPresamplerCalculator&);//coverity issue fix. Declared, but not implemented - LArBarrelPresamplerCalculator& operator=(const LArBarrelPresamplerCalculator&);//coverity issue fix. Declared, but not implemented - static LArBarrelPresamplerCalculator* m_instance; - - // Pointer to detector parameters routine. - LArVG4DetectorParameters* m_parameters; - - // Class for calculating the identifier. - LArG4::BarrelPresampler::Geometry* m_geometry; - - PsMap* m_psmap; - - // RUN Options - bool m_IflCur; - - const LArG4BirksLaw *m_birksLaw; - - // Store the out-of-time cut from the description: - G4float m_OOTcut; - - // The results of the Process calculation: - int m_nhits; // number of hits - //std::vector<LArG4Identifier> m_identifier; // hit identifier - //std::vector<G4double> m_energy; // energy (or current) - //std::vector<G4double> m_time; // time - std::vector<LArHitData> m_hdata; - - std::vector<G4bool> m_isInTime; // hit in time ? - LArG4Identifier m_identifier2; - - // detector name, for translated geometry - std::string m_detectorName; - - bool m_testbeam; - -}; - -#endif // __LArBarrelPresamplerCalculator_H__ diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerGeometry.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerGeometry.h deleted file mode 100644 index 87ecc77e34c7..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelPresamplerGeometry.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArBarrelPresamplerGeometry.hh - -#ifndef LARBARRELPRESAMPLERGEOMETRY_H -#define LARBARRELPRESAMPLERGEOMETRY_H - -//#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVG4DetectorParameters.h" - -#include "globals.hh" - - -// Forward declarations. -class LArG4Identifier; -class G4Step; - -namespace LArG4 { - -namespace BarrelPresampler { - -class Geometry { - - public: - - // Accessor method for singleton pattern. - static Geometry* GetInstance(); - virtual ~Geometry(); - - G4int itb; - - private: -#include "LArG4Barrel/PresParameterDef.h" - static Geometry* m_instance; - - // end z of the various modules - G4double m_end_module[8]; - G4double m_zminPS; - G4double m_zpres; - G4double m_cat_th; - // z of first cathode in each module - G4double m_first_cathod[8]; - // tilt of electrodes - G4double m_tilt[8]; - // number of gaps per cell - G4int m_ngap_cell[8]; - // pitch in z of gaps - G4double m_pitch[8]; - // number of cells per modules - G4int m_ncell_module[8]; - // total LAr thickness - G4double m_halfThickLAr; - - // Pointer to detector parameters routine. - LArVG4DetectorParameters* m_parameters; - - G4int m_sampling; - G4int m_region; - G4int m_etaBin; - G4int m_phiBin; - G4int m_gap; - G4int m_module; - G4double m_distElec; - G4double m_xElec; - G4double m_dist; - - protected: - - Geometry(); - - public: - - LArG4Identifier CalculateIdentifier( const G4Step*, std::string strDetector="" ); - LArG4Identifier CalculatePSActiveIdentifier( const G4Step* , const G4int indPS , const G4int itb ); - LArG4Identifier CalculatePS_DMIdentifier( const G4Step* , const G4int indPS , const G4int itb); - bool findCell(G4double,G4double,G4double); - G4int etaBin() {return m_etaBin;}; - G4int phiBin() {return m_phiBin;}; - G4int sampling() {return m_sampling;}; - G4int region() {return m_region;}; - G4int module() {return m_module;}; - G4int gap() {return m_gap;}; - G4double distElec() {return m_distElec;}; - G4double xElec() {return m_xElec;}; - G4double dtrans() {return m_dist;}; - -} ; - -} //end of Barrel namespace - -} // end of LArG4 namespace - -#endif // LARBARRELGEOMETRY_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeAbsorbers.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeAbsorbers.h deleted file mode 100644 index 9dd790a286d8..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeAbsorbers.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArCoudeAbsorbers_H -#define LArCoudeAbsorbers_H - -#include "LArG4Barrel/PhysicalVolumeAccessor.h" -#include <string> - -class LArCoudeAbsorbers { -private: - static PhysicalVolumeAccessor* s_theCoudes; - double m_xcent[1024][15]; - double m_ycent[1024][15]; - double m_phirot[1024][15]; - bool m_filled; - static LArCoudeAbsorbers* s_instance; -public: - static LArCoudeAbsorbers* GetInstance(std::string strDetector="") ; - double XCentCoude(int stackid, int cellid) ; - double YCentCoude(int stackid, int cellid) ; - double PhiRot(int stackid, int cellid); -protected: - LArCoudeAbsorbers(std::string strDetector="") ; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeElectrodes.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeElectrodes.h deleted file mode 100644 index e5c837eabd36..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudeElectrodes.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArCoudeElectrodes_H -#define LArCoudeElectrodes_H - -#include "LArG4Barrel/PhysicalVolumeAccessor.h" -#include <string> - -class LArCoudeElectrodes { -private: - static PhysicalVolumeAccessor* s_theCoudes; - double m_xcent[1024][15]; - double m_ycent[1024][15]; - double m_phirot[1024][15]; - bool m_filled; - static LArCoudeElectrodes* s_instance; -public: - static LArCoudeElectrodes* GetInstance(std::string strDetector="") ; - double XCentCoude(int stackid, int cellid) ; - double YCentCoude(int stackid, int cellid) ; - double PhiRot(int stackid, int cellid); -protected: - LArCoudeElectrodes(std::string strDetector="") ; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudes.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudes.h deleted file mode 100644 index 1f4a27106043..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArCoudes.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArCoudes_H -#define LArCoudes_H - -#include "LArG4Barrel/PhysicalVolumeAccessor.h" - -class LArCoudes { -private: - static PhysicalVolumeAccessor* s_theCoudes; -public: - LArCoudes(std::string strDetector="") ; - double XCentCoude(int stackid, int cellid) ; - double YCentCoude(int stackid, int cellid) ; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightAbsorbers.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightAbsorbers.h deleted file mode 100644 index f7430c0d9ca0..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightAbsorbers.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArStraightAbsorbers_H -#define LArStraightAbsorbers_H - -#include "LArG4Barrel/PhysicalVolumeAccessor.h" -#include <string> - -class LArStraightAbsorbers { -private: - static PhysicalVolumeAccessor* s_theAbsorbers; - double m_xcent[1024][14]; - double m_ycent[1024][14]; - double m_cosu[1024][14]; - double m_sinu[1024][14]; - double m_halflength[1024][14]; - bool m_filled; - static LArStraightAbsorbers* s_instance; - int m_parity; -public: - static LArStraightAbsorbers* GetInstance(std::string strDetector="") ; - double XCentAbs(int stackid, int cellid) ; - double YCentAbs(int stackid, int cellid) ; - double SlantAbs(int stackid, int cellid) ; - double HalfLength(int stackid, int cellid); - double Cosu(int stackid, int cellid); - double Sinu(int stackid, int cellid); -protected: - LArStraightAbsorbers(std::string strDetector="") ; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightElectrodes.h b/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightElectrodes.h deleted file mode 100644 index d515f981bc30..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArStraightElectrodes.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArStraightElectrodes_H -#define LArStraightElectrodes_H - -#include "LArG4Barrel/PhysicalVolumeAccessor.h" -#include <string> - -class LArStraightElectrodes { -private: - static PhysicalVolumeAccessor* s_theElectrodes; - double m_xcent[1024][14]; - double m_ycent[1024][14]; - double m_cosu[1024][14]; - double m_sinu[1024][14]; - double m_halflength[1024][14]; - bool m_filled; - static LArStraightElectrodes* s_instance; - int m_parity; -public: - static LArStraightElectrodes* GetInstance(std::string strDetector="") ; - double XCentEle(int stackid, int cellid) ; - double YCentEle(int stackid, int cellid) ; - double SlantEle(int stackid, int cellid) ; - double HalfLength(int stackid, int cellid); - double Cosu(int stackid, int cellid); - double Sinu(int stackid, int cellid); -protected: - LArStraightElectrodes(std::string strDetector="") ; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/cmt/requirements b/LArCalorimeter/LArG4/LArG4Barrel/cmt/requirements deleted file mode 100644 index 24c48b6a18d9..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/cmt/requirements +++ /dev/null @@ -1,31 +0,0 @@ -package LArG4Barrel - -author Gaston Parrour <gaston.parrour@cern.ch> -author William Seligman <seligman@nevis.columbia.edu> -author Mikhail Leltchouk <lelchuk@nevis.columbia.edu> - -# This package defines the geometry and hit processing for the ATLAS -# liquid-argon barrel cryostat, pre-sampler, and calorimeter. - -use AtlasPolicy AtlasPolicy-* -use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use CaloG4Sim CaloG4Sim-* Calorimeter -use Geant4 Geant4-* External - -# For reading the e-field files for charge collection. - - -# Build the library (and export the headers) -library LArG4Barrel *.cc -apply_pattern installed_library -#macro_append cppflags " -g -O0 " -#macro_append LArG4Barrel_cppflags " -DLARG4NOROOT -O -Wno-unused" - -private -use CxxUtils CxxUtils-* Control -use AthenaKernel AthenaKernel-* Control -use StoreGate StoreGate-* Control -use GaudiInterface GaudiInterface-* External -use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 -use LArHV LArHV-* LArCalorimeter/LArGeoModel -use PathResolver PathResolver-* Tools diff --git a/LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfig.py b/LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfig.py new file mode 100644 index 000000000000..bd212a1cfdd0 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfig.py @@ -0,0 +1,33 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr + +def getBarrelCryostatCalibrationCalculator(name="BarrelCryostatCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__BarrelCryostat__CalibrationCalculator(name, **kwargs) + +def getBarrelCryostatCalibrationLArCalculator(name="BarrelCryostatCalibrationLArCalculator", **kwargs): + return CfgMgr.LArG4__BarrelCryostat__CalibrationLArCalculator(name, **kwargs) + +def getBarrelCryostatCalibrationMixedCalculator(name="BarrelCryostatCalibrationMixedCalculator", **kwargs): + return CfgMgr.LArG4__BarrelCryostat__CalibrationMixedCalculator(name, **kwargs) + +def getDMCalibrationCalculator(name="DMCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__DM__CalibrationCalculator(name, **kwargs) + +def getBarrelCalibrationCalculator(name="BarrelCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__Barrel__CalibrationCalculator(name, **kwargs) + +def getBarrelPresamplerCalibrationCalculator(name="BarrelPresamplerCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__BarrelPresampler__CalibrationCalculator(name, **kwargs) + +def getEMBCalculator(name="EMBCalculator", **kwargs): + return CfgMgr.LArBarrelCalculator(name, **kwargs) + +def getEMBPresamplerCalculator(name="EMBPresamplerCalculator", **kwargs): + return CfgMgr.LArBarrelPresamplerCalculator(name, **kwargs) + +def getLArBarrelGeometry(name="LArBarrelGeometry", **kwargs): + return CfgMgr.LArG4__Barrel__Geometry(name, **kwargs) + +def getLArBarrelPresamplerGeometry(name="LArBarrelPresamplerGeometry", **kwargs): + return CfgMgr.LArG4__BarrelPresampler__Geometry(name, **kwargs) diff --git a/LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfigDb.py b/LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfigDb.py new file mode 100644 index 000000000000..6eee3d3da7f1 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/python/LArG4BarrelConfigDb.py @@ -0,0 +1,15 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addService + +addService("LArG4Barrel.LArG4BarrelConfig.getBarrelCryostatCalibrationCalculator","BarrelCryostatCalibrationCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getBarrelCryostatCalibrationLArCalculator","BarrelCryostatCalibrationLArCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getBarrelCryostatCalibrationMixedCalculator","BarrelCryostatCalibrationMixedCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getDMCalibrationCalculator","DMCalibrationCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getBarrelCalibrationCalculator","BarrelCalibrationCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getBarrelPresamplerCalibrationCalculator","BarrelPresamplerCalibrationCalculator") + +addService("LArG4Barrel.LArG4BarrelConfig.getEMBCalculator","EMBCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getEMBPresamplerCalculator","EMBPresamplerCalculator") +addService("LArG4Barrel.LArG4BarrelConfig.getLArBarrelGeometry", "LArBarrelGeometry") +addService("LArG4Barrel.LArG4BarrelConfig.getLArBarrelPresamplerGeometry", "LArBarrelPresamplerGeometry") diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cc deleted file mode 100644 index d089e10b51c3..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cc +++ /dev/null @@ -1,156 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/AccMap.h" -#include <iostream> -#include <sstream> -#ifndef LARG4_STAND_ALONE -#include "PathResolver/PathResolver.h" -#endif - -AccMap* AccMap::s_thePointer=0; - -AccMap::AccMap() -{ - int i1[10]={0,0,3,2,9,12,10,9,0,2}; // first fold - int i2[10]={2,1,12,12,13,13,13,13,1,4}; // last fold for 10 electronic regions - m_curr=0; - m_elecregion=-1; - m_eta=-1; - m_sampling=-1; - m_fold=-1; - m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; - m_region=-1; - - m_nmax=14; - m_xmin.resize(m_nmax); - m_xmax.resize(m_nmax); - m_ymin.resize(m_nmax); - m_ymax.resize(m_nmax); - - double xnorm=14.1591; // nA/MeV normalisation for accordion maps - -#ifndef LARG4_STAND_ALONE - //std::string larLocation = PathResolver::find_directory("lar","DATAPATH"); - std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA"); -#endif - - for (int iregion=0;iregion<10;iregion++) { -// accordion folds - for (int ifold=i1[iregion]; ifold<=i2[iregion]; ifold++) { - std::ostringstream fn; - fn << "fold"<<ifold<<"_region"<<iregion<<".map"; - std::string filename = fn.str(); - std::string fileLocation; -#ifdef LARG4_STAND_ALONE - fileLocation=m_directory+"/"+filename; -#else - //fileLocation=larLocation+"/calo_data/"+filename; - fileLocation=larLocation+"/"+filename; -#endif -// std::cout << " try to open map " << fileLocation << std::endl; - CurrMap* cm = new CurrMap(fileLocation,xnorm); - int code=10*ifold+iregion; - m_theMap[code]=cm; - -// add some rounding safety in edges of map - m_xmin[ifold]=cm->GetXmin()+0.1; - m_xmax[ifold]=cm->GetXmax()-0.1; - m_ymin[ifold]=cm->GetYmin()+0.1; - m_ymax[ifold]=cm->GetYmax()-0.1; - } -// straight section - for (int istr=1; istr<=2; istr++) { - std::ostringstream fn; - fn << "straight"<<istr<<"_region"<<iregion<<".map"; - std::string filename = fn.str(); - std::string fileLocation; -#ifdef LARG4_STAND_ALONE - fileLocation=m_directory+"/"+filename; -#else - //fileLocation=larLocation+"/calo_data/"+filename; - fileLocation=larLocation+"/"+filename; -#endif -// std::cout << " try to open map " << fileLocation << std::endl; - CurrMap* cm = new CurrMap(fileLocation,xnorm); - int code=10*(20+istr)+iregion; - m_theMap[code]=cm; - } - } - -} - -AccMap* AccMap::GetAccMap() -{ - if (s_thePointer==0) s_thePointer=new AccMap(); - return s_thePointer; -} - -void AccMap::Reset() -{ - curr_map::iterator it = m_theMap.begin(); - while (it != m_theMap.end()) { - delete (*it).second; - m_theMap.erase(it++); - } -} - -void AccMap::SetMap(int ifold, int region, int sampling, int eta) -{ - if (m_eta==eta && m_sampling==sampling && m_fold==ifold && m_region==region) return; - SetMap(ifold,Region(region,sampling,eta)); -// std::cout << "after SetMap " << region << " " << eta << " " << sampling -// << " " << " elecregion is " << m_elecregion << std::endl; - m_eta=eta; - m_sampling=sampling; - m_fold=ifold; - m_region=region; -} - -void AccMap::SetMap(int ifold, int ielecregion) -{ - if (m_fold==ifold && m_elecregion==ielecregion) return; - m_fold=ifold; - m_elecregion=ielecregion; - int code=10*ifold+ielecregion; -// std::cout << " code is " << code << std::endl; - if (m_theMap.find(code) != m_theMap.end()) - m_curr = m_theMap[code]; - else { - std::cout << " Code " << code << " not found in map ..." << std::endl; - m_curr=0; - } -} - -int AccMap::Region(int region, int sampling, int eta) -{ - int elecregion=0; -// logic to compute region vs eta and sampling... - if (region==0) { - if (sampling==1) { - if (eta<256) elecregion=0; - else elecregion=1; - } - else if (sampling==2) { - if (eta<32) elecregion=2; - else elecregion=3; - } - else { - if (eta<9 || eta==26) elecregion=4; - if ((eta>8 && eta<13) || (eta>15 && eta<19)) elecregion=5; - if ((eta>12 && eta < 16) || (eta>18 && eta<21)) elecregion=6; - if ((eta>20 && eta < 26)) elecregion=7; - } - } - else { - if (sampling==1) elecregion=8; - else elecregion=9; - } - return elecregion; -} - -void AccMap::SetDirectory(std::string dir) -{ - m_directory=dir; -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx new file mode 100644 index 000000000000..479ce1c36b02 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.cxx @@ -0,0 +1,141 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "AccMap.h" +#include <iostream> +#include <sstream> +#ifndef LARG4_STAND_ALONE +#include "PathResolver/PathResolver.h" +#endif + +AccMap* AccMap::s_thePointer=nullptr; + +AccMap::AccMap() +{ + int i1[10]={0,0,3,2,9,12,10,9,0,2}; // first fold + int i2[10]={2,1,12,12,13,13,13,13,1,4}; // last fold for 10 electronic regions + m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; + + m_nmax=14; + m_xmin.resize(m_nmax); + m_xmax.resize(m_nmax); + m_ymin.resize(m_nmax); + m_ymax.resize(m_nmax); + + double xnorm=14.1591; // nA/MeV normalisation for accordion maps + +#ifndef LARG4_STAND_ALONE + //std::string larLocation = PathResolver::find_directory("lar","DATAPATH"); + std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA"); +#endif + + for (int iregion=0;iregion<10;iregion++) { + // accordion folds + for (int ifold=i1[iregion]; ifold<=i2[iregion]; ifold++) { + std::ostringstream fn; + fn << "fold"<<ifold<<"_region"<<iregion<<".map"; + std::string filename = fn.str(); + std::string fileLocation; +#ifdef LARG4_STAND_ALONE + fileLocation=m_directory+"/"+filename; +#else + //fileLocation=larLocation+"/calo_data/"+filename; + fileLocation=larLocation+"/"+filename; +#endif + // std::cout << " try to open map " << fileLocation << std::endl; + CurrMap* cm = new CurrMap(fileLocation,xnorm); + int code=10*ifold+iregion; + m_theMap[code]=cm; + + // add some rounding safety in edges of map + m_xmin[ifold]=cm->GetXmin()+0.1; + m_xmax[ifold]=cm->GetXmax()-0.1; + m_ymin[ifold]=cm->GetYmin()+0.1; + m_ymax[ifold]=cm->GetYmax()-0.1; + } + // straight section + for (int istr=1; istr<=2; istr++) { + std::ostringstream fn; + fn << "straight"<<istr<<"_region"<<iregion<<".map"; + std::string filename = fn.str(); + std::string fileLocation; +#ifdef LARG4_STAND_ALONE + fileLocation=m_directory+"/"+filename; +#else + //fileLocation=larLocation+"/calo_data/"+filename; + fileLocation=larLocation+"/"+filename; +#endif + // std::cout << " try to open map " << fileLocation << std::endl; + CurrMap* cm = new CurrMap(fileLocation,xnorm); + int code=10*(20+istr)+iregion; + m_theMap[code]=cm; + } + } + +} + +AccMap* AccMap::GetAccMap() +{ + if (s_thePointer==nullptr) s_thePointer=new AccMap(); + return s_thePointer; +} + +void AccMap::Reset() +{ + curr_map::iterator it = m_theMap.begin(); + while (it != m_theMap.end()) { + delete (*it).second; + m_theMap.erase(it++); + } +} + +CurrMap* AccMap::GetMap(int ifold, int region, int sampling, int eta) const +{ + return this->GetMap(ifold,this->Region(region,sampling,eta)); +} + +CurrMap* AccMap::GetMap(int ifold, int ielecregion) const +{ + const int code=10*ifold+ielecregion; + // std::cout << " code is " << code << std::endl; + const auto mapIter = m_theMap.find(code); + if (mapIter != m_theMap.end()) + return mapIter->second; + else { + std::cout << " Code " << code << " not found in map ..." << std::endl; + return nullptr; + } +} + +int AccMap::Region(int region, int sampling, int eta) const +{ + int elecregion=0; + // logic to compute region vs eta and sampling... + if (region==0) { + if (sampling==1) { + if (eta<256) elecregion=0; + else elecregion=1; + } + else if (sampling==2) { + if (eta<32) elecregion=2; + else elecregion=3; + } + else { + if (eta<9 || eta==26) elecregion=4; + if ((eta>8 && eta<13) || (eta>15 && eta<19)) elecregion=5; + if ((eta>12 && eta < 16) || (eta>18 && eta<21)) elecregion=6; + if ((eta>20 && eta < 26)) elecregion=7; + } + } + else { + if (sampling==1) elecregion=8; + else elecregion=9; + } + return elecregion; +} + +void AccMap::SetDirectory(std::string dir) +{ + m_directory=dir; +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.h b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.h new file mode 100644 index 000000000000..f9ccc077f3ad --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/AccMap.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef AccMap_h +#define AccMap_h + +#include "CurrMap.h" + +#include <map> +#include <vector> +#include <string> + +typedef std::map<int, CurrMap*> curr_map; + +class AccMap { +public: + ~AccMap(); + static AccMap* GetAccMap(); + void SetDirectory(std::string dir); + void Reset(); + int Region(int region, int sampling, int eta) const; + CurrMap* GetMap(int ifold, int ielecregion) const; + CurrMap* GetMap(int ifold, int region, int sampling, int eta) const; + float GetXmin(int ifold) const { + if (ifold<m_nmax && ifold >=0) return m_xmin[ifold]; + else return -999.;} + float GetXmax(int ifold) const { + if (ifold<m_nmax && ifold >=0) return m_xmax[ifold]; + else return -999.;} + float GetYmin(int ifold) const { + if (ifold<m_nmax && ifold >=0) return m_ymin[ifold]; + else return -999.;} + float GetYmax(int ifold) const { + if (ifold<m_nmax && ifold >=0) return m_ymax[ifold]; + else return -999.;} +private: + AccMap(); + static AccMap* s_thePointer; + curr_map m_theMap; + std::string m_directory; + int m_nmax; + std::vector<float> m_xmin; + std::vector<float> m_xmax; + std::vector<float> m_ymin; + std::vector<float> m_ymax; +}; +#endif diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cc deleted file mode 100644 index 8a6014ed2ed3..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cc +++ /dev/null @@ -1,675 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::BarrelCryostat::CalibrationCalculator -// Prepared 06-Jul-2004 Bill Seligman - -// This class calculates the values needed for calibration hits in the -// simulation. -// -// -// G. Pospelov (8-Fev-2006) ==> -// In 11.0.X geometry of barrel cryostat was changed: -// "Many of the individual cylinders and cones which were separate logical -// volumes have become one single piece." (c) J. Boudreau. -// Names of volumes were changed also. So original code was changed to adopt -// calculator to the new geometry. It's temporary solution, somedays db -// oriented version will be written. -// -// This calculator is intended to apply to the following volumes -// LArMgr::LAr::Barrel::Cryostat::Cylinder::* -// LArMgr::LAr::Barrel::Cryostat::InnerWall -// LArMgr::LAr::Barrel::Cryostat::Sector::* - - -#define DEBUG_VOLUMES -#undef DEBUG_HITS -#undef DEBUG_MAPS - -#include "LArG4Barrel/CryostatCalibrationCalculator.h" -#include "LArG4Barrel/CryostatCalibrationLArCalculator.h" - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" - -#include "G4Step.hh" -#include "G4StepPoint.hh" -#include "G4VPhysicalVolume.hh" -#include "G4ThreeVector.hh" -#include "globals.hh" - -#include <map> -#include <algorithm> -#include <cmath> - -namespace LArG4 { - - namespace BarrelCryostat { - - VCalibrationCalculator* CalibrationCalculator::m_backupCalculator = 0; - - /////////////////////////////////////////////////////////// - // Tables - /////////////////////////////////////////////////////////// - - // There are two ways to implement a routine like this: - - // 1) Lots and lots of "if" statements. - - // 2) Try to encapsulate the decision-making process in tables. - - // I chose the latter approach. The advantage of (2) is that it - // formalizes a lot of rules into a relatively small set of - // tables; the disadvantage is that the code can be complicated. - // (The class CryostatCalibrationLArCalculator demonstrates the - // type (1) approach.) - - // One day, the following information may in some sort of - // database. For now, it's hard-coded into this routine. - - // The information needed to determine the dead-material - // identifier is stored as a "map of a map". The structure looks - // something like this: - - // Volume name -- the named defined in the barrel-cryostat - // detector-construction routine (make sure these names match the - // values in LArBarrelCryostatVisualConsultant) - - // Copy number -- assigned in the barrel-cryostat - // detector-construction routine - - // Identifier information record -- the values needed to - // construct the identifier for the volume. - - // Region information record -- many large dead volumes - // span more than one region. This record gives the - // region-specific values. - - - typedef struct { - G4int regionNumber; - G4double etaMin; - G4double etaMax; - G4double deltaEta; - G4double deltaPhi; - } RegionInfo_t; - - typedef struct { - G4int detector; - G4int subdet; - G4int type; - G4int sampling; - G4int numberOfRegions; - const RegionInfo_t* regionInfoArray; - } IdentifierInfo_t; - - typedef struct { - G4int copyNumberLow; - G4int copyNumberHigh; - IdentifierInfo_t identifierInfo; - } CopyNumberInfo_t; - - typedef struct { - G4String volumeName; - G4int numberOfCopies; - const CopyNumberInfo_t* copyInfo; - } VolumeInfo_t; - - // Please forgive the dull names, but it saves quite a lot on - // typing. Note how the structured hierarchy continues: there can - // be many regions associated with one sampling (equivalent to a - // range of copy numbers); there can be many ranges of copy - // numbers associated with the same volume name. - - // Region definitions - - // ========== Sampling 1 ============= - static const RegionInfo_t region010[] = - // inner warm wall and solenoid - // region etamin etamax deta dphi - { { 0, 0.0, 1.5, 0.1, M_PI/32. }, - { 4, 1.5, 1.6, 0.1, M_PI/32. }, - { 5, 1.5, 1.8, 0.1, M_PI/32. }, - { 6, 1.3, 3.2, 0.1, M_PI/32. } }; - -#if 0 - static const RegionInfo_t region011[] = - // inner cold wall - // region etamin etamax deta dphi - { { 1, 0.0, 1.5, 0.1, M_PI/32. }, - { 4, 1.5, 1.6, 0.1, M_PI/32. }, - { 5, 1.5, 1.8, 0.1, M_PI/32. } }; -#endif - - static const RegionInfo_t region012[] = - // inner warm wall, cones, cables and services in front of EMEC - // region etamin etamax deta dphi - { { 4, 1.5, 1.6, 0.1, M_PI/32. }, - { 5, 1.5, 1.8, 0.1, M_PI/32. }, - { 6, 1.3, 3.2, 0.1, M_PI/32. } }; - - // ========== Sampling 2 ============= - static const RegionInfo_t region020[] = - // outer warm and cold walls in front of Tile-barrel - // region etamin etamax deta dphi - { { 0, 0.0, 1.0, 0.1, M_PI/32. }, - { 2, 1.0, 1.5, 0.1, M_PI/32. } }; - - static const RegionInfo_t region021[] = - // outer warm and cold walls behind of Tile-barrel but - // in front of Tile-extended-barrel, cables and services - // region etamin etamax deta dphi - { { 1, 0.0, 1.0, 0.1, M_PI/32. }, - { 2, 1.0, 1.5, 0.1, M_PI/32. } }; - - // Region->Volume, based on a range of copy numbers. Note that - // some "ranges" of copy numbers contain only one volume. - - static const CopyNumberInfo_t info1[] = - { - // ------------- region inner warm wall and solenoid ------------ - // copy number range (low, high) -// { 1, 1, -// // Det Sub Typ Sam -// { 10, 4, 1, 1, -// sizeof(region010)/sizeof(RegionInfo_t), -// region010 } -// }, - // copy number range (low, high) - { 56, 60, - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region010)/sizeof(RegionInfo_t), - region010 } - }, - // ------------------ region inner cold wall, Cyl ----------------- - // copy number range (low, high) -// { 4, 5, -// // Det Sub Typ Sam -// { 10, 4, 1, 1, -// sizeof(region011)/sizeof(RegionInfo_t), -// region011 } -// }, - // copy number range (low, high) -// { 55, 55, -// // Det Sub Typ Sam -// { 10, 4, 1, 1, -// sizeof(region011)/sizeof(RegionInfo_t), -// region011 } -// }, - // copy number range (low, high) -// { 61, 61, -// // Det Sub Typ Sam -// { 10, 4, 1, 1, -// sizeof(region011)/sizeof(RegionInfo_t), -// region011 } -// // 84 bolts inside this cylinder have the same name -// // and the same copy#=61 => Edeposits in bolts are collected -// -// }, - // --- region: inner warm walls, cables and services in front of EMEC - // copy number range (low, high) -// { 17, 19, -// // Det Sub Typ Sam -// { 10, 4, 1, 1, -// sizeof(region012)/sizeof(RegionInfo_t), -// region012 } -// }, -// { 50, 52, -// // Det Sub Typ Sam -// { 10, 4, 1, 1, -// sizeof(region012)/sizeof(RegionInfo_t), -// region012 } -// }, - - // ---------------- outer warm and cold walls, cables and services - // copy number range (low, high) -// { 3, 3, -// // Det Sub Typ Sam -// { 10, 4, 1, 2, -// sizeof(region021)/sizeof(RegionInfo_t), -// region021 } -// }, - { 6, 6, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region020)/sizeof(RegionInfo_t), - region020 } - }, - { 7, 10, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region021)/sizeof(RegionInfo_t), - region021 } - }, - { 11, 11, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region020)/sizeof(RegionInfo_t), - region020 } - }, - { 12, 12, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region021)/sizeof(RegionInfo_t), - region021 } - }, - { 14, 16, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region021)/sizeof(RegionInfo_t), - region021 } - }, -// { 48, 48, -// // Det Sub Typ Sam -// { 10, 4, 1, 2, -// sizeof(region021)/sizeof(RegionInfo_t), -// region021 } -// }, - // --------------- Half::Cylinder (Old name, info4 was moved to here) - // --- placed inside LAr of each Half Barrel ------ - // copy number range (low, high) - { 20, 20, // outer of acco in the center - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region020)/sizeof(RegionInfo_t), - region020 } - }, - { 24, 44, // 24 - 44 outer support-rings - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region020)/sizeof(RegionInfo_t), - region020 } - }, - }; - - static const CopyNumberInfo_t info2[] = - { - //----region: inner wall --------------------- - { 1, 1, - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region010)/sizeof(RegionInfo_t), - region010 } - }, - }; - - static const CopyNumberInfo_t info3[] = - { - // ---------------Sectors ----------------- - // copy number range (low, high) - { 12, 12, // legs - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region021)/sizeof(RegionInfo_t), - region021 } - }, - { 7, 7, // ears - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region021)/sizeof(RegionInfo_t), - region021 } - }, - { 1, 1, // Ti blocks 11 - 34 (copy number arbitrary) - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region012)/sizeof(RegionInfo_t), - region012 } - }, - }; - -// static const CopyNumberInfo_t info4[] = -// { -// // --------------- Half::Cylinder ----------------- -// // --- placed inside LAr of each Half Barrel ------ -// // copy number range (low, high) -// { 20, 20, // outer of acco in the center -// // Det Sub Typ Sam -// { 10, 4, 1, 2, -// sizeof(region020)/sizeof(RegionInfo_t), -// region020 } -// }, -// { 24, 44, // 24 - 44 outer support-rings -// // Det Sub Typ Sam -// { 10, 4, 1, 2, -// sizeof(region020)/sizeof(RegionInfo_t), -// region020 } -// }, -// }; - - // Copy number range->Volume, based on name - - static const VolumeInfo_t volume1 = - { "LAr::Barrel::Cryostat::Cylinder", - sizeof(info1) / sizeof(CopyNumberInfo_t), - info1 - }; - -// static const VolumeInfo_t volume2 = -// { "LAr::Barrel::Cryostat::Cone", -// sizeof(info2) / sizeof(CopyNumberInfo_t), -// info2 -// }; - static const VolumeInfo_t volume2 = - { "LAr::Barrel::Cryostat::InnerWall", - sizeof(info2) / sizeof(CopyNumberInfo_t), - info2 - }; - - static const VolumeInfo_t volume3 = - { "LAr::Barrel::Cryostat::Sector", - sizeof(info3) / sizeof(CopyNumberInfo_t), - info3 - }; - -// static const VolumeInfo_t volume4 = -// { "LAr::Barrel::Cryostat::Half::Cylinder", -// sizeof(info4) / sizeof(CopyNumberInfo_t), -// info4 -// }; - - static const VolumeInfo_t volumes[] = { volume1, volume2, volume3}; - static const G4int numberOfVolumes = sizeof(volumes) / sizeof(VolumeInfo_t); - - typedef std::map < G4int, const IdentifierInfo_t* > identifierMap_t; - typedef identifierMap_t::iterator identifierMap_ptr_t; - typedef std::map < G4String, identifierMap_t > volumeMap_t; - typedef volumeMap_t::iterator volumeMap_ptr_t; - static volumeMap_t volumeMap; - - static G4bool notInitialized = true; - - /////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////// - - CalibrationCalculator::CalibrationCalculator() - { - // Get the "backup" calculator. - if ( m_backupCalculator == 0) - m_backupCalculator = new CalibrationLArCalculator(); - -#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " - << " notInitialized=" - << notInitialized - << ", numberOfVolumes=" << numberOfVolumes - << ", sizeof(volumes)=" << sizeof(volumes) - << ", sizeof(VolumeInfo_t)=" << sizeof(VolumeInfo_t) - << G4endl; -#endif - - // Intialize the maps. - if ( notInitialized ) - { - notInitialized = false; - - // For each volume managed by this calculator... - for (G4int v = 0; v != numberOfVolumes; v++) - { - const VolumeInfo_t& volume = volumes[v]; - -#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " - << " volume '" - << volume.volumeName - << "' has number of entries=" << volume.numberOfCopies - << G4endl; -#endif - - identifierMap_t identifierMap; - const CopyNumberInfo_t* copyInfo = volume.copyInfo; - - // For each range copy numbers that can be found in a volume with this name... - for (G4int c = 0; c != volume.numberOfCopies; c++, copyInfo++) - { - // For each copy in the range of copy numbers - for (G4int copy = copyInfo->copyNumberLow; - copy <= copyInfo->copyNumberHigh; - copy++) - { -#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " - << " adding copy=" << copy - << " to identifierMap" - << G4endl; -#endif - // Add to the map that's based on copy number. - identifierMap[copy] = &(copyInfo->identifierInfo); - } - } - - // Add to the map that's based on volume name; it - // contains maps based on copy number. - volumeMap[volume.volumeName] = identifierMap; - -#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " - << " volume '" - << volume.volumeName - << "' added to map." - << G4endl; -#endif - - } - } // if not initialized - -#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " - << G4endl - << " initialization complete; map size=" - << volumeMap.size() - << G4endl; -#endif - - } - - - CalibrationCalculator::~CalibrationCalculator() - { - // Cleanup pointers. - delete m_backupCalculator; - m_backupCalculator = 0; - } - - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - // First, find the physical volume copy number, and the - // logical volume name. - - G4VPhysicalVolume* physical = a_step->GetPreStepPoint()->GetPhysicalVolume(); - G4int copyNumber = physical->GetCopyNo(); - G4String volumeName = physical->GetLogicalVolume()->GetName(); - -#ifdef DEBUG_HITS - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - " - << G4endl - << " searching for volume '" - << volumeName - << "' copyNumber=" - << copyNumber - << G4endl; -#endif - - if(volumeName.index("LArMgr::") == 0) volumeName.erase(0,8); - if(volumeName.index("LAr::Barrel::Cryostat::Sector")==0) { // ears, legs, Ti blocks - volumeName = "LAr::Barrel::Cryostat::Sector"; - if(copyNumber != 7 && copyNumber !=12) copyNumber=1; // assignment arbitrary copyNumber to Ti block - }else if(volumeName.index("LAr::Barrel::Cryostat::Cylinder")==0){ - volumeName = "LAr::Barrel::Cryostat::Cylinder"; - }else if(volumeName.index("LAr::Barrel::Cryostat::InnerWall")==0){ - volumeName = "LAr::Barrel::Cryostat::InnerWall"; - copyNumber = 1; // assignment arbitrary copyNumber - } - - // Search the maps for this volume/copy number combination. - volumeMap_ptr_t v = volumeMap.find( volumeName ); - if ( v != volumeMap.end() ) - { - - // Recall that maps are made from pair <key,value>, and - // you access a pair with the "first" and "second" - // members. In this case, "second" is a map. We don't - // need to copy the entire map; it's enough to get its - // reference. - - identifierMap_t& identifierMap = (*v).second; - identifierMap_ptr_t i = identifierMap.find( copyNumber ); - - if ( i != identifierMap.end() ) - { - const IdentifierInfo_t* info = (*i).second; - - // Find our (x,y,z) location from the G4Step. - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - // Determine the geometric eta and phi. Note that we do not - // adjust for any endcap shifts; the values are assigned to - // the volumes based on their design positions. - - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - // For this calculation, we need 0<phi<2*PI. (The - // official ATLAS standard of -PI<phi<PI is - // meaningless here.) - if ( phi < 0 ) phi += 2*M_PI; - - // The region can depend on eta. Search through the - // list of regions within this IdentifierInfo record - // to find which one has etaMin<eta<etaMax. - - G4int regions = info->numberOfRegions; - const RegionInfo_t* region = info->regionInfoArray; - -#ifdef DEBUG_HITS - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - " - << G4endl - << " found volume, number of regions=" - << regions - << " eta=" << eta << " phi=" << phi - << G4endl; -#endif - - G4int r; - for ( r = 0; r < regions; r++, region++ ) - { - if ( eta > region->etaMin && - eta < region->etaMax ) - break; - } - - // If the following statement is not true, we're in - // trouble. It means that the eta of our energy - // deposit is outside the assumed eta limits of the - // volume. - - if ( r < regions ) - { - // Convert eta and phi to their integer equivalents for the - // identifier. - - G4int etaInteger = G4int( (eta - region->etaMin) / region->deltaEta ); - G4int phiInteger = G4int( phi / region->deltaPhi ); -// phiInteger should be less than 64 - if (phiInteger > 63) phiInteger = 0; - -#ifdef DEBUG_HITS - G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - " - << G4endl - << " found region=" - << region->regionNumber - << " eta bin=" << etaInteger << " phi bin=" << phiInteger - << G4endl; -#endif - - // The sign of subdet will depend on whether z is positive - // or negative. - G4int subDetSign = 1; - if ( p.z() < 0 ) subDetSign = -1; - - // A quick check against a bad value of etaMin. - if ( etaInteger >= 0 ) - { - // Build the full identifier. - m_identifier << info->detector - << info->subdet * subDetSign - << info->type - << info->sampling - << region->regionNumber - << etaInteger - << phiInteger; - - } // etaInteger valid - } // eta valid - } // copy number valid - } // volume name valid - - // If a volume is not found on one of the above tables, try - // the "backup identifier" calculator. - - if ( m_identifier == LArG4Identifier() ) - { -#if defined (DEBUG_HITS) || defined (DEBUG_VOLUMES) - std::cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process" - << std::endl - << " volume '" - << volumeName - << "' copy# " - << copyNumber - << " not found on tables, using backup calculator" - << std::endl; -#endif - m_backupCalculator->Process(a_step, kOnlyID); - m_identifier = m_backupCalculator->identifier(); - } - } // calculate identifier - -#ifdef DEBUG_HITS - //G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process" - << " vName " << a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName() - << " ID=" << std::string(m_identifier) -// << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - - } // namespace BarrelCryostat - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cxx new file mode 100644 index 000000000000..462c93386a1e --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cxx @@ -0,0 +1,676 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4::BarrelCryostat::CalibrationCalculator +// Prepared 06-Jul-2004 Bill Seligman + +// This class calculates the values needed for calibration hits in the +// simulation. +// +// +// G. Pospelov (8-Fev-2006) ==> +// In 11.0.X geometry of barrel cryostat was changed: +// "Many of the individual cylinders and cones which were separate logical +// volumes have become one single piece." (c) J. Boudreau. +// Names of volumes were changed also. So original code was changed to adopt +// calculator to the new geometry. It's temporary solution, somedays db +// oriented version will be written. +// +// This calculator is intended to apply to the following volumes +// LArMgr::LAr::Barrel::Cryostat::Cylinder::* +// LArMgr::LAr::Barrel::Cryostat::InnerWall +// LArMgr::LAr::Barrel::Cryostat::Sector::* + + +#define DEBUG_VOLUMES +#undef DEBUG_HITS +#undef DEBUG_MAPS + +#include "CryostatCalibrationCalculator.h" +#include "CryostatCalibrationLArCalculator.h" + +#include "LArG4Code/LArG4Identifier.h" + +#include "G4Step.hh" +#include "G4StepPoint.hh" +#include "G4VPhysicalVolume.hh" +#include "G4ThreeVector.hh" +#include "globals.hh" + +#include <map> +#include <algorithm> +#include <cmath> + +namespace LArG4 { + + namespace BarrelCryostat { + + /////////////////////////////////////////////////////////// + // Tables + /////////////////////////////////////////////////////////// + + // There are two ways to implement a routine like this: + + // 1) Lots and lots of "if" statements. + + // 2) Try to encapsulate the decision-making process in tables. + + // I chose the latter approach. The advantage of (2) is that it + // formalizes a lot of rules into a relatively small set of + // tables; the disadvantage is that the code can be complicated. + // (The class CryostatCalibrationLArCalculator demonstrates the + // type (1) approach.) + + // One day, the following information may in some sort of + // database. For now, it's hard-coded into this routine. + + // The information needed to determine the dead-material + // identifier is stored as a "map of a map". The structure looks + // something like this: + + // Volume name -- the named defined in the barrel-cryostat + // detector-construction routine (make sure these names match the + // values in LArBarrelCryostatVisualConsultant) + + // Copy number -- assigned in the barrel-cryostat + // detector-construction routine + + // Identifier information record -- the values needed to + // construct the identifier for the volume. + + // Region information record -- many large dead volumes + // span more than one region. This record gives the + // region-specific values. + + + typedef struct { + G4int regionNumber; + G4double etaMin; + G4double etaMax; + G4double deltaEta; + G4double deltaPhi; + } RegionInfo_t; + + typedef struct { + G4int detector; + G4int subdet; + G4int type; + G4int sampling; + G4int numberOfRegions; + const RegionInfo_t* regionInfoArray; + } IdentifierInfo_t; + + typedef struct { + G4int copyNumberLow; + G4int copyNumberHigh; + IdentifierInfo_t identifierInfo; + } CopyNumberInfo_t; + + typedef struct { + G4String volumeName; + G4int numberOfCopies; + const CopyNumberInfo_t* copyInfo; + } VolumeInfo_t; + + // Please forgive the dull names, but it saves quite a lot on + // typing. Note how the structured hierarchy continues: there can + // be many regions associated with one sampling (equivalent to a + // range of copy numbers); there can be many ranges of copy + // numbers associated with the same volume name. + + // Region definitions + + // ========== Sampling 1 ============= + static const RegionInfo_t region010[] = + // inner warm wall and solenoid + // region etamin etamax deta dphi + { { 0, 0.0, 1.5, 0.1, M_PI/32. }, + { 4, 1.5, 1.6, 0.1, M_PI/32. }, + { 5, 1.5, 1.8, 0.1, M_PI/32. }, + { 6, 1.3, 3.2, 0.1, M_PI/32. } }; + +#if 0 + static const RegionInfo_t region011[] = + // inner cold wall + // region etamin etamax deta dphi + { { 1, 0.0, 1.5, 0.1, M_PI/32. }, + { 4, 1.5, 1.6, 0.1, M_PI/32. }, + { 5, 1.5, 1.8, 0.1, M_PI/32. } }; +#endif + + static const RegionInfo_t region012[] = + // inner warm wall, cones, cables and services in front of EMEC + // region etamin etamax deta dphi + { { 4, 1.5, 1.6, 0.1, M_PI/32. }, + { 5, 1.5, 1.8, 0.1, M_PI/32. }, + { 6, 1.3, 3.2, 0.1, M_PI/32. } }; + + // ========== Sampling 2 ============= + static const RegionInfo_t region020[] = + // outer warm and cold walls in front of Tile-barrel + // region etamin etamax deta dphi + { { 0, 0.0, 1.0, 0.1, M_PI/32. }, + { 2, 1.0, 1.5, 0.1, M_PI/32. } }; + + static const RegionInfo_t region021[] = + // outer warm and cold walls behind of Tile-barrel but + // in front of Tile-extended-barrel, cables and services + // region etamin etamax deta dphi + { { 1, 0.0, 1.0, 0.1, M_PI/32. }, + { 2, 1.0, 1.5, 0.1, M_PI/32. } }; + + // Region->Volume, based on a range of copy numbers. Note that + // some "ranges" of copy numbers contain only one volume. + + static const CopyNumberInfo_t info1[] = + { + // ------------- region inner warm wall and solenoid ------------ + // copy number range (low, high) + // { 1, 1, + // // Det Sub Typ Sam + // { 10, 4, 1, 1, + // sizeof(region010)/sizeof(RegionInfo_t), + // region010 } + // }, + // copy number range (low, high) + { 56, 60, + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region010)/sizeof(RegionInfo_t), + region010 } + }, + // ------------------ region inner cold wall, Cyl ----------------- + // copy number range (low, high) + // { 4, 5, + // // Det Sub Typ Sam + // { 10, 4, 1, 1, + // sizeof(region011)/sizeof(RegionInfo_t), + // region011 } + // }, + // copy number range (low, high) + // { 55, 55, + // // Det Sub Typ Sam + // { 10, 4, 1, 1, + // sizeof(region011)/sizeof(RegionInfo_t), + // region011 } + // }, + // copy number range (low, high) + // { 61, 61, + // // Det Sub Typ Sam + // { 10, 4, 1, 1, + // sizeof(region011)/sizeof(RegionInfo_t), + // region011 } + // // 84 bolts inside this cylinder have the same name + // // and the same copy#=61 => Edeposits in bolts are collected + // + // }, + // --- region: inner warm walls, cables and services in front of EMEC + // copy number range (low, high) + // { 17, 19, + // // Det Sub Typ Sam + // { 10, 4, 1, 1, + // sizeof(region012)/sizeof(RegionInfo_t), + // region012 } + // }, + // { 50, 52, + // // Det Sub Typ Sam + // { 10, 4, 1, 1, + // sizeof(region012)/sizeof(RegionInfo_t), + // region012 } + // }, + + // ---------------- outer warm and cold walls, cables and services + // copy number range (low, high) + // { 3, 3, + // // Det Sub Typ Sam + // { 10, 4, 1, 2, + // sizeof(region021)/sizeof(RegionInfo_t), + // region021 } + // }, + { 6, 6, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region020)/sizeof(RegionInfo_t), + region020 } + }, + { 7, 10, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region021)/sizeof(RegionInfo_t), + region021 } + }, + { 11, 11, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region020)/sizeof(RegionInfo_t), + region020 } + }, + { 12, 12, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region021)/sizeof(RegionInfo_t), + region021 } + }, + { 14, 16, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region021)/sizeof(RegionInfo_t), + region021 } + }, + // { 48, 48, + // // Det Sub Typ Sam + // { 10, 4, 1, 2, + // sizeof(region021)/sizeof(RegionInfo_t), + // region021 } + // }, + // --------------- Half::Cylinder (Old name, info4 was moved to here) + // --- placed inside LAr of each Half Barrel ------ + // copy number range (low, high) + { 20, 20, // outer of acco in the center + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region020)/sizeof(RegionInfo_t), + region020 } + }, + { 24, 44, // 24 - 44 outer support-rings + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region020)/sizeof(RegionInfo_t), + region020 } + }, + }; + + static const CopyNumberInfo_t info2[] = + { + //----region: inner wall --------------------- + { 1, 1, + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region010)/sizeof(RegionInfo_t), + region010 } + }, + }; + + static const CopyNumberInfo_t info3[] = + { + // ---------------Sectors ----------------- + // copy number range (low, high) + { 12, 12, // legs + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region021)/sizeof(RegionInfo_t), + region021 } + }, + { 7, 7, // ears + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region021)/sizeof(RegionInfo_t), + region021 } + }, + { 1, 1, // Ti blocks 11 - 34 (copy number arbitrary) + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region012)/sizeof(RegionInfo_t), + region012 } + }, + }; + + // static const CopyNumberInfo_t info4[] = + // { + // // --------------- Half::Cylinder ----------------- + // // --- placed inside LAr of each Half Barrel ------ + // // copy number range (low, high) + // { 20, 20, // outer of acco in the center + // // Det Sub Typ Sam + // { 10, 4, 1, 2, + // sizeof(region020)/sizeof(RegionInfo_t), + // region020 } + // }, + // { 24, 44, // 24 - 44 outer support-rings + // // Det Sub Typ Sam + // { 10, 4, 1, 2, + // sizeof(region020)/sizeof(RegionInfo_t), + // region020 } + // }, + // }; + + // Copy number range->Volume, based on name + + static const VolumeInfo_t volume1 = + { "LAr::Barrel::Cryostat::Cylinder", + sizeof(info1) / sizeof(CopyNumberInfo_t), + info1 + }; + + // static const VolumeInfo_t volume2 = + // { "LAr::Barrel::Cryostat::Cone", + // sizeof(info2) / sizeof(CopyNumberInfo_t), + // info2 + // }; + static const VolumeInfo_t volume2 = + { "LAr::Barrel::Cryostat::InnerWall", + sizeof(info2) / sizeof(CopyNumberInfo_t), + info2 + }; + + static const VolumeInfo_t volume3 = + { "LAr::Barrel::Cryostat::Sector", + sizeof(info3) / sizeof(CopyNumberInfo_t), + info3 + }; + + // static const VolumeInfo_t volume4 = + // { "LAr::Barrel::Cryostat::Half::Cylinder", + // sizeof(info4) / sizeof(CopyNumberInfo_t), + // info4 + // }; + + static const VolumeInfo_t volumes[] = { volume1, volume2, volume3}; + static const G4int numberOfVolumes = sizeof(volumes) / sizeof(VolumeInfo_t); + + typedef std::map < G4int, const IdentifierInfo_t* > identifierMap_t; + typedef identifierMap_t::iterator identifierMap_ptr_t; + typedef std::map < G4String, identifierMap_t > volumeMap_t; + typedef volumeMap_t::iterator volumeMap_ptr_t; + static volumeMap_t volumeMap; + + static G4bool notInitialized = true; + + /////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////// + + CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_backupCalculator("BarrelCryostatCalibrationLArCalculator",name) + { + declareProperty("BackupCalculator",m_backupCalculator); + } + + StatusCode CalibrationCalculator::initialize(){ + // Get the "backup" calculator. + ATH_CHECK(m_backupCalculator.retrieve()); + +#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " + << " notInitialized=" + << notInitialized + << ", numberOfVolumes=" << numberOfVolumes + << ", sizeof(volumes)=" << sizeof(volumes) + << ", sizeof(VolumeInfo_t)=" << sizeof(VolumeInfo_t) + << G4endl; +#endif + + // Intialize the maps. + if ( notInitialized ) + { + notInitialized = false; + + // For each volume managed by this calculator... + for (G4int v = 0; v != numberOfVolumes; v++) + { + const VolumeInfo_t& volume = volumes[v]; + +#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " + << " volume '" + << volume.volumeName + << "' has number of entries=" << volume.numberOfCopies + << G4endl; +#endif + + identifierMap_t identifierMap; + const CopyNumberInfo_t* copyInfo = volume.copyInfo; + + // For each range copy numbers that can be found in a volume with this name... + for (G4int c = 0; c != volume.numberOfCopies; c++, copyInfo++) + { + // For each copy in the range of copy numbers + for (G4int copy = copyInfo->copyNumberLow; + copy <= copyInfo->copyNumberHigh; + copy++) + { +#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " + << " adding copy=" << copy + << " to identifierMap" + << G4endl; +#endif + // Add to the map that's based on copy number. + identifierMap[copy] = &(copyInfo->identifierInfo); + } + } + + // Add to the map that's based on volume name; it + // contains maps based on copy number. + volumeMap[volume.volumeName] = identifierMap; + +#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " + << " volume '" + << volume.volumeName + << "' added to map." + << G4endl; +#endif + + } + } // if not initialized + +#if defined (DEBUG_HITS) || defined (DEBUG_MAPS) + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::CalibrationCalculator - " + << G4endl + << " initialization complete; map size=" + << volumeMap.size() + << G4endl; +#endif + + return StatusCode::SUCCESS; + } + + + CalibrationCalculator::~CalibrationCalculator() + { + // Cleanup pointers. + //delete m_backupCalculator; + //m_backupCalculator = 0; + } + + G4bool CalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { + m_energyCalculator.Energies( step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + identifier.clear(); + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + + // First, find the physical volume copy number, and the + // logical volume name. + + G4VPhysicalVolume* physical = step->GetPreStepPoint()->GetPhysicalVolume(); + G4int copyNumber = physical->GetCopyNo(); + G4String volumeName = physical->GetLogicalVolume()->GetName(); + +#ifdef DEBUG_HITS + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - " + << G4endl + << " searching for volume '" + << volumeName + << "' copyNumber=" + << copyNumber + << G4endl; +#endif + + if(volumeName.index("LArMgr::") == 0) volumeName.erase(0,8); + if(volumeName.index("LAr::Barrel::Cryostat::Sector")==0) { // ears, legs, Ti blocks + volumeName = "LAr::Barrel::Cryostat::Sector"; + if(copyNumber != 7 && copyNumber !=12) copyNumber=1; // assignment arbitrary copyNumber to Ti block + }else if(volumeName.index("LAr::Barrel::Cryostat::Cylinder")==0){ + volumeName = "LAr::Barrel::Cryostat::Cylinder"; + }else if(volumeName.index("LAr::Barrel::Cryostat::InnerWall")==0){ + volumeName = "LAr::Barrel::Cryostat::InnerWall"; + copyNumber = 1; // assignment arbitrary copyNumber + } + + // Search the maps for this volume/copy number combination. + volumeMap_ptr_t v = volumeMap.find( volumeName ); + if ( v != volumeMap.end() ) + { + + // Recall that maps are made from pair <key,value>, and + // you access a pair with the "first" and "second" + // members. In this case, "second" is a map. We don't + // need to copy the entire map; it's enough to get its + // reference. + + identifierMap_t& identifierMap = (*v).second; + identifierMap_ptr_t i = identifierMap.find( copyNumber ); + + if ( i != identifierMap.end() ) + { + const IdentifierInfo_t* info = (*i).second; + + // Find our (x,y,z) location from the G4Step. + + G4StepPoint* pre_step_point = step->GetPreStepPoint(); + G4StepPoint* post_step_point = step->GetPostStepPoint(); + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + // Determine the geometric eta and phi. Note that we do not + // adjust for any endcap shifts; the values are assigned to + // the volumes based on their design positions. + + G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + // For this calculation, we need 0<phi<2*PI. (The + // official ATLAS standard of -PI<phi<PI is + // meaningless here.) + if ( phi < 0 ) phi += 2*M_PI; + + // The region can depend on eta. Search through the + // list of regions within this IdentifierInfo record + // to find which one has etaMin<eta<etaMax. + + G4int regions = info->numberOfRegions; + const RegionInfo_t* region = info->regionInfoArray; + +#ifdef DEBUG_HITS + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - " + << G4endl + << " found volume, number of regions=" + << regions + << " eta=" << eta << " phi=" << phi + << G4endl; +#endif + + G4int r; + for ( r = 0; r < regions; r++, region++ ) + { + if ( eta > region->etaMin && + eta < region->etaMax ) + break; + } + + // If the following statement is not true, we're in + // trouble. It means that the eta of our energy + // deposit is outside the assumed eta limits of the + // volume. + + if ( r < regions ) + { + // Convert eta and phi to their integer equivalents for the + // identifier. + + G4int etaInteger = G4int( (eta - region->etaMin) / region->deltaEta ); + G4int phiInteger = G4int( phi / region->deltaPhi ); + // phiInteger should be less than 64 + if (phiInteger > 63) phiInteger = 0; + +#ifdef DEBUG_HITS + G4cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process - " + << G4endl + << " found region=" + << region->regionNumber + << " eta bin=" << etaInteger << " phi bin=" << phiInteger + << G4endl; +#endif + + // The sign of subdet will depend on whether z is positive + // or negative. + G4int subDetSign = 1; + if ( p.z() < 0 ) subDetSign = -1; + + // A quick check against a bad value of etaMin. + if ( etaInteger >= 0 ) + { + // Build the full identifier. + identifier << info->detector + << info->subdet * subDetSign + << info->type + << info->sampling + << region->regionNumber + << etaInteger + << phiInteger; + + } // etaInteger valid + } // eta valid + } // copy number valid + } // volume name valid + + // If a volume is not found on one of the above tables, try + // the "backup identifier" calculator. + + if ( identifier == LArG4Identifier() ) + { +#if defined (DEBUG_HITS) || defined (DEBUG_VOLUMES) + std::cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process" + << std::endl + << " volume '" + << volumeName + << "' copy# " + << copyNumber + << " not found on tables, using backup calculator" + << std::endl; +#endif + m_backupCalculator->Process(step, identifier, energies, process); + } + } // calculate identifier + +#ifdef DEBUG_HITS + //G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "LArG4::BarrelCryostat::CalibrationCalculator::Process" + << " vName " << step->GetPreStepPoint()->GetPhysicalVolume()->GetName() + << " ID=" << std::string(identifier) + // << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; +#endif + + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; + + return true; + } + + } // namespace BarrelCryostat + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.h similarity index 73% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.h index f841bf25dff7..6e1ce58a556a 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.h @@ -6,7 +6,7 @@ // Prepared 24-Feb-2004 Bill Seligman // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -22,7 +22,7 @@ #ifndef LArG4_BarrelCryostat_CalibrationCalculator_H #define LArG4_BarrelCryostat_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -42,12 +42,13 @@ namespace LArG4 { namespace BarrelCryostat { - class CalibrationCalculator : public VCalibrationCalculator { + class CalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationCalculator(); + + CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -59,28 +60,18 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } - private: - - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + private: // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; // If we can't find the volume in this calculator, try a // "backup" calculator. - static VCalibrationCalculator* m_backupCalculator; + ServiceHandle<ILArCalibCalculatorSvc> m_backupCalculator; }; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cc deleted file mode 100644 index aac4cd3dce64..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::BarrelCryostat::CalibrationLArCalculator -// Prepared 06-Jul-2004 Bill Seligman -// 16-Jul-2004 M.Leltchouk - extended for LAr::Barrel::MotherVolume - -// This class calculates the values needed for calibration hits in the -// simulation. - -#undef DEBUG_HITS -#define DEBUG_VOLUMES - -#include "LArG4Barrel/CryostatCalibrationLArCalculator.h" - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4Code/CalibrationDefaultCalculator.h" - -#include "G4Step.hh" -#include "G4StepPoint.hh" -#include "G4VPhysicalVolume.hh" -#include "G4ThreeVector.hh" -#include "globals.hh" - -#include <map> -#include <algorithm> -#include <cmath> -#include <climits> - -namespace LArG4 { - - namespace BarrelCryostat { - - VCalibrationCalculator* CalibrationLArCalculator::m_defaultCalculator = 0; - - /////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////// - - CalibrationLArCalculator::CalibrationLArCalculator() - { - // Get the default calculator (hopefully a temporary piece of code): - if ( m_defaultCalculator == 0) - m_defaultCalculator = new CalibrationDefaultCalculator(); - - // Access source of detector parameters. - m_parameters = LArVG4DetectorParameters::GetInstance(); - - } - - - CalibrationLArCalculator::~CalibrationLArCalculator() - { - // Cleanup pointers. - delete m_defaultCalculator; - m_defaultCalculator = 0; - } - - - G4bool CalibrationLArCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - // Note: - // LArG4::BarrelCryostat::CryostatCalibrationCalculator uses - // a table-based approach to determine the identifier. The - // following code uses an "if-statement" approach. - - // The fixed parameters (only a couple of which are readily - // accessible from the database): - - // static ? - static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. - static const double oneOverDphi = 32./M_PI; // 1/Dphi - - static const double rhoMinPresamplerMother = 1385.*CLHEP::mm; - static const double rhoMiddlePresampler = (1385.*CLHEP::mm + 1447.*CLHEP::mm)/2.; - // from PresParameterDef.icc - // rMinPresamplerMother = 1385*CLHEP::mm; - // rMaxPresamplerMother = 1447*CLHEP::mm - 0.001*CLHEP::mm; - - static const double rhoAlignmentSafety = 10.*CLHEP::mm; - static const double rhoInFrontOfColdWall = rhoMinPresamplerMother - rhoAlignmentSafety; - static double RIN_AC = INT_MIN; - if ( RIN_AC < 0.) - RIN_AC = m_parameters->GetValue("LArEMBRadiusInnerAccordion"); // 1500.024*CLHEP::mm; from ACCG - static const double RCUT12 = 1593.9*CLHEP::mm; - static const double RCUT23 = 1866.1*CLHEP::mm; - static double ROUT_AC = INT_MIN; - if ( ROUT_AC < 0. ) - ROUT_AC = m_parameters->GetValue("LArEMBRadiusOuterAccordion"); // 1960.*CLHEP::mm; - static const double rhoOuterAccordionWithSafety = ROUT_AC - rhoAlignmentSafety; - static double LArEMBZmax = INT_MIN; - if ( LArEMBZmax < 0. ) - LArEMBZmax = m_parameters->GetValue("LArEMBZmax"); // 3165.*CLHEP::mm - - const double zMaxAccordionWithSafety = LArEMBZmax - 10.*CLHEP::mm; - - - // Calculate the mid-point of the step, and the simple geometry variables. - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - G4double rho = p.perp(); - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation - - // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate - G4int subdet = ( p.z() > 0.) ? 4 : -4; - G4int phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>63) phiBin=0; - - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int type = INT_MIN; - G4int sampling = INT_MIN; - G4int region = INT_MIN; - G4int etaBin = INT_MIN; - - - if(std::fabs(p.z())< 10 && eta < 0.1 && rho > rhoMinPresamplerMother && rho < ROUT_AC ) - { - // type = 2 dead materials in "internal" cracks: - // real crack for nominal geometry at this level is +-3mm - // add some margin to allow for misalignement - - type = 2; - - // sampling = 0,1,2,3 (follow the corresponding calorimeter structure) - if ( rho < RIN_AC ) { sampling = 0; } - else if ( rho < RCUT12 ) { sampling = 1; } - else if ( rho < RCUT23 ) { sampling = 2; } - else { sampling = 3; } - - // region = 0 - between two halves of EMB, - region = 0; - etaBin = 0; - } - else - { - // type = 1 dead materials outside accordion and active presampler layers - type = 1; - - if( eta < 1.5 ) - { - if ( rho < rhoInFrontOfColdWall ) // and in LAr::Barrel::MotherVolume - - // The region is defined correctly for a radial mis-alignments - // up to 10mm because ColdWallThickness >= 20mm and - // rhoAlignmentSafety = 10.*mm; - // The E-deposit in the Cold Wall itself is handled by - // another calculator. - { - sampling = 1; - region = 0; - etaBin = (int) ( eta * oneOverDeta ); - } - else if ( rho < rhoMiddlePresampler ) - // The region is defined correctly for a radial mis-alignments - // up to (1447.*mm - 1385.*mm)/2 - // The E-deposit in the Presampler itself is handled by - // other calculator. - { - sampling = 1; - region = 2; - etaBin = (int) ( eta * oneOverDeta ); - } - else if ( rho < rhoOuterAccordionWithSafety && - fabs( p.z()) < zMaxAccordionWithSafety ) - // The region is defined correctly for a radial mis-alignments - // up to 10mm because rhoAlignmentSafety = 10.*mm; - // The E-deposit in the Barrel Accordion itself is handled by - // other calculator. - { - sampling = 1; - region = 3; - etaBin = (int) ( eta * oneOverDeta ); - } - else // rho > ROUT_AC or |z| >= zMaxAccordionWithSafety - { - sampling = 2; - - if( eta < 1.0 ) - { - region = 0; - etaBin = (int) ( eta * oneOverDeta ); - } - else // 1.0 <= eta < 1.5 - { - region = 2; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - } - } - } - else if ( eta < 1.6 ) - { - sampling = 1; - region = 4; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } - else if ( eta < 1.8 ) - { - sampling = 1; - region = 5; - etaBin = (int) ( (eta-1.6) * oneOverDeta ); - } - else if ( eta < 3.2 ) - { - sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.8) * oneOverDeta ); - } - } - - // This is a "quick fix" for a complex issue: We're still - // developing code for the cryostat. What if, somehow, we have - // a G4Step in a LAr volume that isn't handled by the above - // code? Answer: Use the default calibration calculator (the - // same one used for volumes without sensitive detectors) to get - // the identifier. - - if ( type == INT_MIN || - region == INT_MIN || - sampling == INT_MIN || - etaBin == INT_MIN || - phiBin < 0 ) - { -#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) - static const G4int messageMax = 10; - static G4int messageCount = 0; - if ( messageCount++ < messageMax ) - { - std::cout << "LArG4::BarrelCryostat::CalibrationLArCalculator::Process" - << " (error " << messageCount << " of " << messageMax << " max displayed)" - << std::endl - << " G4Step in LAr at unexpected place: (x,y,z) [mm] = (" - << p.x()/CLHEP::mm << "," - << p.y()/CLHEP::mm << "," - << p.z()/CLHEP::mm - << "); eta=" << eta - << ", phi=" << phi << std::endl - << " using default calculator" - << std::endl; - } -#endif - m_defaultCalculator->Process(a_step, kOnlyID); - m_identifier = m_defaultCalculator->identifier(); - } - else - { - // Append the cell ID to the (empty) identifier. - m_identifier << 10 // Calorimeter - << subdet // LAr +/-4 where "+" or " -" according to - // the sign of Z in World coorinate - << type - << sampling - << region - << etaBin - << phiBin; - } - } - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::BarrelCryostat::CalibrationLArCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - - } // namespace BarrelCryostat - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cxx new file mode 100644 index 000000000000..6f8f533d72dc --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.cxx @@ -0,0 +1,310 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4::BarrelCryostat::CalibrationLArCalculator +// Prepared 06-Jul-2004 Bill Seligman +// 16-Jul-2004 M.Leltchouk - extended for LAr::Barrel::MotherVolume + +// This class calculates the values needed for calibration hits in the +// simulation. + +#undef DEBUG_HITS +#define DEBUG_VOLUMES + +#include "CryostatCalibrationLArCalculator.h" + +#include "LArG4Code/LArG4Identifier.h" +//#include "LArG4Code/CalibrationDefaultCalculator.h" + +#include "G4Step.hh" +#include "G4StepPoint.hh" +#include "G4VPhysicalVolume.hh" +#include "G4ThreeVector.hh" +#include "globals.hh" + +#include <map> +#include <algorithm> +#include <cmath> +#include <climits> + +namespace LArG4 { + + namespace BarrelCryostat { + + /////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////// + + CalibrationLArCalculator::CalibrationLArCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_parameters(nullptr) + , m_defaultCalculator("CalibrationDefaultCalculator",name) + { + declareProperty("DefaultCalculator",m_defaultCalculator); + } + + StatusCode CalibrationLArCalculator::initialize(){ + // Get the default calculator (hopefully a temporary piece of code): + ATH_CHECK(m_defaultCalculator.retrieve()); + + // Access source of detector parameters. + m_parameters = LArVG4DetectorParameters::GetInstance(); + return StatusCode::SUCCESS; + } + + + CalibrationLArCalculator::~CalibrationLArCalculator() + { + // Cleanup pointers. + //delete m_defaultCalculator; + //m_defaultCalculator = 0; + } + + G4bool CalibrationLArCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { + m_energyCalculator.Energies( step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + identifier.clear(); + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + + // Note: + // LArG4::BarrelCryostat::CryostatCalibrationCalculator uses + // a table-based approach to determine the identifier. The + // following code uses an "if-statement" approach. + + // The fixed parameters (only a couple of which are readily + // accessible from the database): + + // static ? + static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. + static const double oneOverDphi = 32./M_PI; // 1/Dphi + + static const double rhoMinPresamplerMother = 1385.*CLHEP::mm; + static const double rhoMiddlePresampler = (1385.*CLHEP::mm + 1447.*CLHEP::mm)/2.; + // from PresParameterDef.icc + // rMinPresamplerMother = 1385*CLHEP::mm; + // rMaxPresamplerMother = 1447*CLHEP::mm - 0.001*CLHEP::mm; + + static const double rhoAlignmentSafety = 10.*CLHEP::mm; + static const double rhoInFrontOfColdWall = rhoMinPresamplerMother - rhoAlignmentSafety; + static double RIN_AC = INT_MIN; + if ( RIN_AC < 0.) + RIN_AC = m_parameters->GetValue("LArEMBRadiusInnerAccordion"); // 1500.024*CLHEP::mm; from ACCG + static const double RCUT12 = 1593.9*CLHEP::mm; + static const double RCUT23 = 1866.1*CLHEP::mm; + static double ROUT_AC = INT_MIN; + if ( ROUT_AC < 0. ) + ROUT_AC = m_parameters->GetValue("LArEMBRadiusOuterAccordion"); // 1960.*CLHEP::mm; + static const double rhoOuterAccordionWithSafety = ROUT_AC - rhoAlignmentSafety; + static double LArEMBZmax = INT_MIN; + if ( LArEMBZmax < 0. ) + LArEMBZmax = m_parameters->GetValue("LArEMBZmax"); // 3165.*CLHEP::mm + + const double zMaxAccordionWithSafety = LArEMBZmax - 10.*CLHEP::mm; + + + // Calculate the mid-point of the step, and the simple geometry variables. + + G4StepPoint* pre_step_point = step->GetPreStepPoint(); + G4StepPoint* post_step_point = step->GetPostStepPoint(); + + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + G4double rho = p.perp(); + G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation + + // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate + G4int subdet = ( p.z() > 0.) ? 4 : -4; + G4int phiBin = (int) ( phi * oneOverDphi ); + if (phiBin>63) phiBin=0; + + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int type = INT_MIN; + G4int sampling = INT_MIN; + G4int region = INT_MIN; + G4int etaBin = INT_MIN; + + + if(std::fabs(p.z())< 10 && eta < 0.1 && rho > rhoMinPresamplerMother && rho < ROUT_AC ) + { + // type = 2 dead materials in "internal" cracks: + // real crack for nominal geometry at this level is +-3mm + // add some margin to allow for misalignement + + type = 2; + + // sampling = 0,1,2,3 (follow the corresponding calorimeter structure) + if ( rho < RIN_AC ) { sampling = 0; } + else if ( rho < RCUT12 ) { sampling = 1; } + else if ( rho < RCUT23 ) { sampling = 2; } + else { sampling = 3; } + + // region = 0 - between two halves of EMB, + region = 0; + etaBin = 0; + } + else + { + // type = 1 dead materials outside accordion and active presampler layers + type = 1; + + if( eta < 1.5 ) + { + if ( rho < rhoInFrontOfColdWall ) // and in LAr::Barrel::MotherVolume + + // The region is defined correctly for a radial mis-alignments + // up to 10mm because ColdWallThickness >= 20mm and + // rhoAlignmentSafety = 10.*mm; + // The E-deposit in the Cold Wall itself is handled by + // another calculator. + { + sampling = 1; + region = 0; + etaBin = (int) ( eta * oneOverDeta ); + } + else if ( rho < rhoMiddlePresampler ) + // The region is defined correctly for a radial mis-alignments + // up to (1447.*mm - 1385.*mm)/2 + // The E-deposit in the Presampler itself is handled by + // other calculator. + { + sampling = 1; + region = 2; + etaBin = (int) ( eta * oneOverDeta ); + } + else if ( rho < rhoOuterAccordionWithSafety && + fabs( p.z()) < zMaxAccordionWithSafety ) + // The region is defined correctly for a radial mis-alignments + // up to 10mm because rhoAlignmentSafety = 10.*mm; + // The E-deposit in the Barrel Accordion itself is handled by + // other calculator. + { + sampling = 1; + region = 3; + etaBin = (int) ( eta * oneOverDeta ); + } + else // rho > ROUT_AC or |z| >= zMaxAccordionWithSafety + { + sampling = 2; + + if( eta < 1.0 ) + { + region = 0; + etaBin = (int) ( eta * oneOverDeta ); + } + else // 1.0 <= eta < 1.5 + { + region = 2; + etaBin = (int) ( (eta-1.) * oneOverDeta ); + } + } + } + else if ( eta < 1.6 ) + { + sampling = 1; + region = 4; + etaBin = (int) ( (eta-1.5) * oneOverDeta ); + } + else if ( eta < 1.8 ) + { + sampling = 1; + region = 5; + etaBin = (int) ( (eta-1.6) * oneOverDeta ); + } + else if ( eta < 3.2 ) + { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.8) * oneOverDeta ); + } + } + + // This is a "quick fix" for a complex issue: We're still + // developing code for the cryostat. What if, somehow, we have + // a G4Step in a LAr volume that isn't handled by the above + // code? Answer: Use the default calibration calculator (the + // same one used for volumes without sensitive detectors) to get + // the identifier. + + if ( type == INT_MIN || + region == INT_MIN || + sampling == INT_MIN || + etaBin == INT_MIN || + phiBin < 0 ) + { +#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) + static const G4int messageMax = 10; + static G4int messageCount = 0; + if ( messageCount++ < messageMax ) + { + std::cout << "LArG4::BarrelCryostat::CalibrationLArCalculator::Process" + << " (error " << messageCount << " of " << messageMax << " max displayed)" + << std::endl + << " G4Step in LAr at unexpected place: (x,y,z) [mm] = (" + << p.x()/CLHEP::mm << "," + << p.y()/CLHEP::mm << "," + << p.z()/CLHEP::mm + << "); eta=" << eta + << ", phi=" << phi << std::endl + << " using default calculator" + << std::endl; + } +#endif + m_defaultCalculator->Process(step, identifier, energies, process); + } + else + { + // Append the cell ID to the (empty) identifier. + identifier << 10 // Calorimeter + << subdet // LAr +/-4 where "+" or " -" according to + // the sign of Z in World coorinate + << type + << sampling + << region + << etaBin + << phiBin; + } + } + +#ifdef DEBUG_HITS + G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "LArG4::BarrelCryostat::CalibrationLArCalculator::Process" + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; +#endif + + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; + + return true; + } + + } // namespace BarrelCryostat + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationLArCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.h similarity index 71% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationLArCalculator.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.h index 512e56cb422e..a034ae12ee80 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationLArCalculator.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationLArCalculator.h @@ -6,7 +6,7 @@ // Prepared 13-Aug-2004 Bill Seligman // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -21,7 +21,7 @@ #ifndef LArG4_BarrelCryostat_CalibrationLArCalculator_H #define LArG4_BarrelCryostat_CalibrationLArCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "LArG4Code/LArVG4DetectorParameters.h" @@ -43,12 +43,13 @@ namespace LArG4 { namespace BarrelCryostat { - class CalibrationLArCalculator : public VCalibrationCalculator { + class CalibrationLArCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationLArCalculator(); + + CalibrationLArCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationLArCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -59,31 +60,18 @@ namespace LArG4 { // escaped energy), or only the energy (no known application // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; private: - - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; // Access to parameters. LArVG4DetectorParameters* m_parameters; - // For the default calculator (hopefully temporary). - static VCalibrationCalculator* m_defaultCalculator; + ServiceHandle<ILArCalibCalculatorSvc> m_defaultCalculator; }; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cc deleted file mode 100644 index 2b05a10bd8dc..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cc +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::BarrelCryostat::CalibrationMixedCalculator -// Prepared 24-Aug-2004 William Seligman -// from code prepared by Mikhail Leltchouk - -// This class calculates the values needed for calibration hits in the -// simulation. - -#undef DEBUG_HITS -#define DEBUG_VOLUMES - -#include "LArG4Barrel/CryostatCalibrationMixedCalculator.h" -#include "LArG4Barrel/CryostatCalibrationLArCalculator.h" - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" - -#include "G4Step.hh" -#include "G4StepPoint.hh" -#include "G4VPhysicalVolume.hh" -#include "G4ThreeVector.hh" -#include "globals.hh" - -#include <map> -#include <algorithm> -#include <cmath> -#include <climits> - -namespace LArG4 { - - namespace BarrelCryostat { - - VCalibrationCalculator* CalibrationMixedCalculator::m_backupCalculator = 0; - - /////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////// - - CalibrationMixedCalculator::CalibrationMixedCalculator() - { - // Get a "backup" calculator. - if ( m_backupCalculator == 0) - m_backupCalculator = new CalibrationLArCalculator(); - - // Access source of detector parameters. - m_parameters = LArVG4DetectorParameters::GetInstance(); - - } - - - CalibrationMixedCalculator::~CalibrationMixedCalculator() - { - // Cleanup pointers. - delete m_backupCalculator; - m_backupCalculator = 0; - } - - // This calculator is intended to apply to the following volumes that have "mixed" identifiers: - // volumeName "LAr::Barrel::Cryostat::Cylinder::Mixed" - // copy number 2, 47, 49, - // - // volumeName "LAr::Barrel::Cryostat::Cone::Mixed" - // copy number 8, 9, - // - // volumeName "LAr::Barrel::Cryostat::Half::Cylinder::Mixed" - // copy number 21 - // - // G. Pospelov (8-Fev-2006) - // Actually, this calculator is intended to apply to the following volumes - // LArMgr::LAr::Barrel::Cryostat::Mixed::Cylinder::* - // LArMgr::LAr::Barrel::Cryostat::OuterWall - // LArMgr::LAr::Barrel::Cryostat::InnerEndWall - // See also Simulation/G4Atlas/G4AtlasApps/python/atlas_calo.py and - // LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cxx - - G4bool CalibrationMixedCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - // Note: - // LArG4::BarrelCryostat::CryostatCalibrationCalculator uses - // a table-based approach to determine the identifier. The - // following code uses an "if-statement" approach. - - // The fixed parameters (only a couple of which are readily - // accessible from the database): - - static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. - static const double oneOverDphi = 32./M_PI; // 1/Dphi - - // Calculate the mid-point of the step, and the simple geometry variables. - G4VPhysicalVolume* physical = a_step->GetPreStepPoint()->GetPhysicalVolume(); - //G4int copyNumber = physical->GetCopyNo(); - G4String volumeName = physical->GetLogicalVolume()->GetName(); - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - G4double rho = p.perp(); - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation - - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int sampling = INT_MIN; - G4int region = INT_MIN; - G4int etaBin = INT_MIN; - // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate - G4int subdet = ( p.z() > 0.) ? 4 : -4; - G4int type = 1; - G4int phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>63) phiBin=0; - - static double rho12 = 1386.+10.; // use old hardcoded 1386 for Sampling 1-2 transition - // and add 10mm for safety (misalignment) - - if ( eta < 1.0 ) - { - if ( rho < rho12) // LAr::Barrel::Cryostat::OuterWall - { - sampling = 1; - region = 1; - etaBin = (int) ( eta * oneOverDeta ); - } - else - { - sampling = 2; - region = 0; - etaBin = (int) ( eta * oneOverDeta ); - } - } - else if ( eta < 1.5 ) - { - if ( rho < rho12) // LAr::Barrel::Cryostat::OuterWall - { - sampling = 1; - region = 1; - etaBin = (int) ( eta * oneOverDeta ); - } - else - { - sampling = 2; - region = 2; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - } - } - else if ( eta < 1.6 ) - { - sampling = 1; - region = 4; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } - else if ( eta < 1.8 ) - { - sampling = 1; - region = 5; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } - else - { - sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.3) * oneOverDeta ); - } - - // What if we have a G4Step that isn't handled by the above - // code? Answer: Use a "backup" calculator to try to - // process the step. - - if ( type == INT_MIN || - region == INT_MIN || - sampling == INT_MIN || - etaBin == INT_MIN || - phiBin < 0 ) - { -#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) - static const G4int messageMax = 10; - static G4int messageCount = 0; - if ( messageCount++ < messageMax ) - { - std::cout << "LArG4::BarrelCryostat::CalibrationMixedCalculator::Process" - << " (error " << messageCount << " of " << messageMax << " max displayed)" - << std::endl - << " G4Step in '" - << a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName() - << "', using backup calculator" - << std::endl; - } -#endif - m_backupCalculator->Process(a_step, kOnlyID); - m_identifier = m_backupCalculator->identifier(); - } - else - { - // Append the cell ID to the (empty) identifier. - m_identifier << 10 // Calorimeter - << subdet // LAr +/-4 where "+" or " -" according to - // the sign of Z in World coorinate - << type - << sampling - << region - << etaBin - << phiBin; - } - } - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::BarrelCryostat::CalibrationMixedCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - - } // namespace BarrelCryostat - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cxx new file mode 100644 index 000000000000..e667b12826d7 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.cxx @@ -0,0 +1,252 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4::BarrelCryostat::CalibrationMixedCalculator +// Prepared 24-Aug-2004 William Seligman +// from code prepared by Mikhail Leltchouk + +// This class calculates the values needed for calibration hits in the +// simulation. + +#undef DEBUG_HITS +#define DEBUG_VOLUMES + +#include "CryostatCalibrationMixedCalculator.h" +#include "CryostatCalibrationLArCalculator.h" + +#include "LArG4Code/LArG4Identifier.h" + +#include "G4Step.hh" +#include "G4StepPoint.hh" +#include "G4VPhysicalVolume.hh" +#include "G4ThreeVector.hh" +#include "globals.hh" + +#include <map> +#include <algorithm> +#include <cmath> +#include <climits> + +namespace LArG4 { + + namespace BarrelCryostat { + + /////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////// + + CalibrationMixedCalculator::CalibrationMixedCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_backupCalculator("BarrelCryostatCalibrationLArCalculator",name) + { + declareProperty("BackupCalculator", m_backupCalculator); + } + + StatusCode CalibrationMixedCalculator::initialize() { + // Get a "backup" calculator. + ATH_CHECK(m_backupCalculator.retrieve()); + + return StatusCode::SUCCESS; + } + + + CalibrationMixedCalculator::~CalibrationMixedCalculator() + { + // Cleanup pointers. + //delete m_backupCalculator; + //m_backupCalculator = 0; + } + + // This calculator is intended to apply to the following volumes that have "mixed" identifiers: + // volumeName "LAr::Barrel::Cryostat::Cylinder::Mixed" + // copy number 2, 47, 49, + // + // volumeName "LAr::Barrel::Cryostat::Cone::Mixed" + // copy number 8, 9, + // + // volumeName "LAr::Barrel::Cryostat::Half::Cylinder::Mixed" + // copy number 21 + // + // G. Pospelov (8-Fev-2006) + // Actually, this calculator is intended to apply to the following volumes + // LArMgr::LAr::Barrel::Cryostat::Mixed::Cylinder::* + // LArMgr::LAr::Barrel::Cryostat::OuterWall + // LArMgr::LAr::Barrel::Cryostat::InnerEndWall + // See also Simulation/G4Atlas/G4AtlasApps/python/atlas_calo.py and + // LArG4/LArG4Barrel/src/CryostatCalibrationCalculator.cxx + + G4bool CalibrationMixedCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { + m_energyCalculator.Energies( step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + identifier.clear(); + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + + // Note: + // LArG4::BarrelCryostat::CryostatCalibrationCalculator uses + // a table-based approach to determine the identifier. The + // following code uses an "if-statement" approach. + + // The fixed parameters (only a couple of which are readily + // accessible from the database): + + static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. + static const double oneOverDphi = 32./M_PI; // 1/Dphi + + // Calculate the mid-point of the step, and the simple geometry variables. + G4VPhysicalVolume* physical = step->GetPreStepPoint()->GetPhysicalVolume(); + //G4int copyNumber = physical->GetCopyNo(); + G4String volumeName = physical->GetLogicalVolume()->GetName(); + + G4StepPoint* pre_step_point = step->GetPreStepPoint(); + G4StepPoint* post_step_point = step->GetPostStepPoint(); + + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + G4double rho = p.perp(); + G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation + + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int sampling = INT_MIN; + G4int region = INT_MIN; + G4int etaBin = INT_MIN; + // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate + G4int subdet = ( p.z() > 0.) ? 4 : -4; + G4int type = 1; + G4int phiBin = (int) ( phi * oneOverDphi ); + if (phiBin>63) phiBin=0; + + static double rho12 = 1386.+10.; // use old hardcoded 1386 for Sampling 1-2 transition + // and add 10mm for safety (misalignment) + + if ( eta < 1.0 ) + { + if ( rho < rho12) // LAr::Barrel::Cryostat::OuterWall + { + sampling = 1; + region = 1; + etaBin = (int) ( eta * oneOverDeta ); + } + else + { + sampling = 2; + region = 0; + etaBin = (int) ( eta * oneOverDeta ); + } + } + else if ( eta < 1.5 ) + { + if ( rho < rho12) // LAr::Barrel::Cryostat::OuterWall + { + sampling = 1; + region = 1; + etaBin = (int) ( eta * oneOverDeta ); + } + else + { + sampling = 2; + region = 2; + etaBin = (int) ( (eta-1.) * oneOverDeta ); + } + } + else if ( eta < 1.6 ) + { + sampling = 1; + region = 4; + etaBin = (int) ( (eta-1.5) * oneOverDeta ); + } + else if ( eta < 1.8 ) + { + sampling = 1; + region = 5; + etaBin = (int) ( (eta-1.5) * oneOverDeta ); + } + else + { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.3) * oneOverDeta ); + } + + // What if we have a G4Step that isn't handled by the above + // code? Answer: Use a "backup" calculator to try to + // process the step. + + if ( type == INT_MIN || + region == INT_MIN || + sampling == INT_MIN || + etaBin == INT_MIN || + phiBin < 0 ) + { +#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) + static const G4int messageMax = 10; + static G4int messageCount = 0; + if ( messageCount++ < messageMax ) + { + std::cout << "LArG4::BarrelCryostat::CalibrationMixedCalculator::Process" + << " (error " << messageCount << " of " << messageMax << " max displayed)" + << std::endl + << " G4Step in '" + << step->GetPreStepPoint()->GetPhysicalVolume()->GetName() + << "', using backup calculator" + << std::endl; + } +#endif + m_backupCalculator->Process(step, identifier, energies, process); + } + else + { + // Append the cell ID to the (empty) identifier. + identifier << 10 // Calorimeter + << subdet // LAr +/-4 where "+" or " -" according to + // the sign of Z in World coorinate + << type + << sampling + << region + << etaBin + << phiBin; + } + } + +#ifdef DEBUG_HITS + G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "LArG4::BarrelCryostat::CalibrationMixedCalculator::Process" + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; +#endif + + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; + + return true; + } + + } // namespace BarrelCryostat + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationMixedCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.h similarity index 67% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationMixedCalculator.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.h index 0f433750f253..f796b9271d0b 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/CryostatCalibrationMixedCalculator.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CryostatCalibrationMixedCalculator.h @@ -6,7 +6,7 @@ // Prepared 13-Aug-2004 Bill Seligman // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -21,9 +21,8 @@ #ifndef LArG4_BarrelCryostat_CalibrationMixedCalculator_H #define LArG4_BarrelCryostat_CalibrationMixedCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVG4DetectorParameters.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -42,12 +41,13 @@ namespace LArG4 { namespace BarrelCryostat { - class CalibrationMixedCalculator : public VCalibrationCalculator { + class CalibrationMixedCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationMixedCalculator(); + + CalibrationMixedCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationMixedCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -58,32 +58,15 @@ namespace LArG4 { // escaped energy), or only the energy (no known application // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; private: - - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; - // Access to parameters. - LArVG4DetectorParameters* m_parameters; - - // Define a "backup" calculator. - static VCalibrationCalculator* m_backupCalculator; - + ServiceHandle<ILArCalibCalculatorSvc> m_backupCalculator; }; } // namespace BarrelCryostat diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cc deleted file mode 100644 index acbbe17d8731..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/CurrMap.h" -#include <stdlib.h> -#include <iostream> -#include <stdio.h> - -CurrMap::CurrMap(std::string filename,double xnorm) -{ -// normalisation to convert nA from the map back to MeV -// use average in straight section: -// this assumes that the electronic calibration is such -// that Sum ai*(ADC-PED) gives the initial current for a triangular -// signal of drift time ~475 ns - m_norm = xnorm; - m_nx=0; - m_ny=0; - m_xmin=0.; - m_xmax=0.; - m_dx=0.; - m_ymin=0.; - m_ymax=0.; - m_dy=0.; - - m_gap=0; - m_curr0=0; - m_curr1=0; - m_curr2=0; - - - FILE * fp = fopen(filename.c_str(),"r"); - if(fp){ - char line[81]; - fgets(line,80,fp); - sscanf(&line[0],"%d%f%f%d%f%f",&m_nx,&m_xmin,&m_xmax,&m_ny,&m_ymin,&m_ymax); - - if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000) {//coverity issue. This is a tainted variable protection, 10000 can be changed if required. - m_dx = (m_xmax-m_xmin)/((float) m_nx); - m_dy = (m_ymax-m_ymin)/((float) m_ny); - //std::cout << " nx,xmin,xmax,ny,ymin,ymax " << m_nx << " " << m_xmin << " " << m_xmax << " " - // << m_ny << " " << m_ymin << " " << m_ymax << std::endl; - - m_gap = new float[m_nx*m_ny]; - m_curr0 = new float[m_nx*m_ny]; - m_curr1 = new float[m_nx*m_ny]; - m_curr2 = new float[m_nx*m_ny]; - - for (int i=0; i<m_nx;i++) - { - for (int j=0; j<m_ny;j++) { - m_gap[j*m_nx+i]=0.; - m_curr0[j*m_nx+i]=0; - m_curr1[j*m_nx+i]=0; - m_curr2[j*m_nx+i]=0; - } - } - - int ix,iy; - float gap,cur1,cur2,cur3; - while (fgets(line,80,fp)) { - sscanf(&line[0],"%d%d%f%f%f%f",&ix,&iy,&gap,&cur1,&cur2,&cur3); - if(ix >= 0 && ix < m_nx && iy >= 0 && iy < m_ny){ - m_gap[iy*m_nx+ix]=gap; - m_curr0[iy*m_nx+ix]=cur1/m_norm; - m_curr1[iy*m_nx+ix]=cur2/m_norm; - m_curr2[iy*m_nx+ix]=cur3/m_norm; - // std::cout << "read " << ix << " " << iy << " " << m_curr0[iy*m_nx+ix] << std::endl; - } - } - } - else{ - std::cout << "Error in CurrMap::CurrMap: nx or ny out of limits." << std::endl; - } - fclose(fp); - } - else{ - - std::cout << "Error in CurrMap::CurrMap: The file could not be open." << std::endl; - } - - -} - - -CurrMap::~CurrMap() -{ - if (m_gap) delete [] m_gap; - if (m_curr0) delete [] m_curr0; - if (m_curr1) delete [] m_curr1; - if (m_curr2) delete [] m_curr2; -} - - -void CurrMap::GetAll(double x, double y, double* gap, double* curr0, double* curr1, double* curr2) -{ - *gap=0; - *curr0=0; - *curr1=0; - *curr2=0; - - if (m_nx==0 || m_ny ==0) return; - if (x<m_xmin ) x=m_xmin; - if (x>=m_xmax ) x=m_xmax-0.0001; - if (y<m_ymin ) y=m_ymin; - if (y>=m_ymax ) y=m_ymax-0.0001; - - int ix,iy; - ix = (int) ((x-m_xmin)/m_dx); - iy = (int) ((y-m_ymin)/m_dy); - - if ( (ix+1) < m_nx && (iy+1) < m_ny) { - float x0 = ((float) ix)*m_dx+m_xmin; - float x1 = x0+m_dx; - float y0 = ((float) iy)*m_dy+m_ymin; - float y1 = y0+m_dy; - float w[4]; - w[0]=(x1-x)*(y1-y); - w[1]=(x-x0)*(y1-y); - w[2]=(x1-x)*(y-y0); - w[3]=(x-x0)*(y-y0); - - float sumw=0.; - for (int i=0;i<2;i++) { - for (int j=0;j<2;j++) { - int n=ix+i+(iy+j)*m_nx; - if (m_curr0[n]>0) { - int m=i+2*j; - sumw +=w[m]; - *gap += m_gap[n]*w[m]; - *curr0 += m_curr0[n]*w[m]; - *curr1 += m_curr1[n]*w[m]; - *curr2 += m_curr2[n]*w[m]; - } - } - } - if (sumw>0.) { - *gap = *gap/sumw; - *curr0 = *curr0/sumw; - *curr1 = *curr1/sumw; - *curr2 = *curr2/sumw; - } - else { -// try to recover a non zero current by moving in the map - int jy=-1; - int jx=-1; - int idistm=100; - for (int iiy=iy-7;iiy<iy+8;iiy++) { - for (int iix=ix-7;iix<ix+8;iix++) { - if (iiy>=0 && iiy<m_ny && iix>=0 && iix<m_nx) { - if (m_curr0[iix+iiy*m_nx]>0) { - int idist=(iix-ix)*(iix-ix)+(iiy-iy)*(iiy-iy); - if(idist<idistm) { - idistm=idist; - jx=iix; - jy=iiy; - } - } - } - } - } - if (idistm<100 && jx>=0 && jy>=0) { - *gap = m_gap[jx+jy*m_nx]; - *curr0 = m_curr0[jx+jy*m_nx]; - *curr1 = m_curr1[jx+jy*m_nx]; - *curr2 = m_curr2[jx+jy*m_nx]; - } else { - *gap=0; - *curr0=0; - *curr1=0; - *curr2=0; - } - } - } - else { -// on the edges of the map, no linear interpolation - int n=ix+iy*m_nx; - if (m_curr0[n]<1e-6 && (ix+1) <m_nx) n=ix+1 +iy*m_nx; - if (m_curr0[n]<1e-6 && (ix-1) >0 ) n=ix-1 +iy*m_nx; - if (m_curr0[n]<1e-6 && (iy+1) <m_ny) n=ix+(iy+1)*m_nx; - if (m_curr0[n]<1e-6 && (iy-1) <0) n=ix+(iy-1)*m_nx; - if (m_curr0[n]<1e-6 && (ix+1) < m_nx && (iy+1) < m_ny) n=ix+1+(iy+1)*m_nx; - if (m_curr0[n]<1e-6 && (ix-1) >0 && (iy+1) < m_ny) n=ix-1+(iy+1)*m_nx; - if (m_curr0[n]<1e-6 && (ix+1) < m_nx && (iy-1) >0 ) n=ix+1+(iy-1)*m_nx; - if (m_curr0[n]<1e-6 && (ix-1) >0 && (iy-1) >0 ) n=ix-1+(iy-1)*m_nx; - *gap = m_gap[n]; - *curr0 = m_curr0[n]; - *curr1 = m_curr1[n]; - *curr2 = m_curr2[n]; - } -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx new file mode 100644 index 000000000000..8279a740dc65 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.cxx @@ -0,0 +1,192 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "CurrMap.h" +#include <stdlib.h> +#include <iostream> +#include <stdio.h> + +CurrMap::CurrMap(std::string filename,double xnorm) +{ + // normalisation to convert nA from the map back to MeV + // use average in straight section: + // this assumes that the electronic calibration is such + // that Sum ai*(ADC-PED) gives the initial current for a triangular + // signal of drift time ~475 ns + m_norm = xnorm; + m_nx=0; + m_ny=0; + m_xmin=0.; + m_xmax=0.; + m_dx=0.; + m_ymin=0.; + m_ymax=0.; + m_dy=0.; + + m_gap=0; + m_curr0=0; + m_curr1=0; + m_curr2=0; + + + FILE * fp = fopen(filename.c_str(),"r"); + if(fp){ + char line[81]; + fgets(line,80,fp); + sscanf(&line[0],"%d%f%f%d%f%f",&m_nx,&m_xmin,&m_xmax,&m_ny,&m_ymin,&m_ymax); + + if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000) {//coverity issue. This is a tainted variable protection, 10000 can be changed if required. + m_dx = (m_xmax-m_xmin)/((float) m_nx); + m_dy = (m_ymax-m_ymin)/((float) m_ny); + //std::cout << " nx,xmin,xmax,ny,ymin,ymax " << m_nx << " " << m_xmin << " " << m_xmax << " " + // << m_ny << " " << m_ymin << " " << m_ymax << std::endl; + + m_gap = new float[m_nx*m_ny]; + m_curr0 = new float[m_nx*m_ny]; + m_curr1 = new float[m_nx*m_ny]; + m_curr2 = new float[m_nx*m_ny]; + + for (int i=0; i<m_nx;i++) + { + for (int j=0; j<m_ny;j++) { + m_gap[j*m_nx+i]=0.; + m_curr0[j*m_nx+i]=0; + m_curr1[j*m_nx+i]=0; + m_curr2[j*m_nx+i]=0; + } + } + + int ix,iy; + float gap,cur1,cur2,cur3; + while (fgets(line,80,fp)) { + sscanf(&line[0],"%d%d%f%f%f%f",&ix,&iy,&gap,&cur1,&cur2,&cur3); + if(ix >= 0 && ix < m_nx && iy >= 0 && iy < m_ny){ + m_gap[iy*m_nx+ix]=gap; + m_curr0[iy*m_nx+ix]=cur1/m_norm; + m_curr1[iy*m_nx+ix]=cur2/m_norm; + m_curr2[iy*m_nx+ix]=cur3/m_norm; + // std::cout << "read " << ix << " " << iy << " " << m_curr0[iy*m_nx+ix] << std::endl; + } + } + } + else{ + std::cout << "Error in CurrMap::CurrMap: nx or ny out of limits." << std::endl; + } + fclose(fp); + } + else{ + + std::cout << "Error in CurrMap::CurrMap: The file could not be open." << std::endl; + } + + +} + + +CurrMap::~CurrMap() +{ + if (m_gap) delete [] m_gap; + if (m_curr0) delete [] m_curr0; + if (m_curr1) delete [] m_curr1; + if (m_curr2) delete [] m_curr2; +} + + +void CurrMap::GetAll(double x, double y, double* gap, double* curr0, double* curr1, double* curr2) const +{ + *gap=0; + *curr0=0; + *curr1=0; + *curr2=0; + + if (m_nx==0 || m_ny ==0) return; + if (x<m_xmin ) x=m_xmin; + if (x>=m_xmax ) x=m_xmax-0.0001; + if (y<m_ymin ) y=m_ymin; + if (y>=m_ymax ) y=m_ymax-0.0001; + + int ix,iy; + ix = (int) ((x-m_xmin)/m_dx); + iy = (int) ((y-m_ymin)/m_dy); + + if ( (ix+1) < m_nx && (iy+1) < m_ny) { + float x0 = ((float) ix)*m_dx+m_xmin; + float x1 = x0+m_dx; + float y0 = ((float) iy)*m_dy+m_ymin; + float y1 = y0+m_dy; + float w[4]; + w[0]=(x1-x)*(y1-y); + w[1]=(x-x0)*(y1-y); + w[2]=(x1-x)*(y-y0); + w[3]=(x-x0)*(y-y0); + + float sumw=0.; + for (int i=0;i<2;i++) { + for (int j=0;j<2;j++) { + int n=ix+i+(iy+j)*m_nx; + if (m_curr0[n]>0) { + int m=i+2*j; + sumw +=w[m]; + *gap += m_gap[n]*w[m]; + *curr0 += m_curr0[n]*w[m]; + *curr1 += m_curr1[n]*w[m]; + *curr2 += m_curr2[n]*w[m]; + } + } + } + if (sumw>0.) { + *gap = *gap/sumw; + *curr0 = *curr0/sumw; + *curr1 = *curr1/sumw; + *curr2 = *curr2/sumw; + } + else { + // try to recover a non zero current by moving in the map + int jy=-1; + int jx=-1; + int idistm=100; + for (int iiy=iy-7;iiy<iy+8;iiy++) { + for (int iix=ix-7;iix<ix+8;iix++) { + if (iiy>=0 && iiy<m_ny && iix>=0 && iix<m_nx) { + if (m_curr0[iix+iiy*m_nx]>0) { + int idist=(iix-ix)*(iix-ix)+(iiy-iy)*(iiy-iy); + if(idist<idistm) { + idistm=idist; + jx=iix; + jy=iiy; + } + } + } + } + } + if (idistm<100 && jx>=0 && jy>=0) { + *gap = m_gap[jx+jy*m_nx]; + *curr0 = m_curr0[jx+jy*m_nx]; + *curr1 = m_curr1[jx+jy*m_nx]; + *curr2 = m_curr2[jx+jy*m_nx]; + } else { + *gap=0; + *curr0=0; + *curr1=0; + *curr2=0; + } + } + } + else { + // on the edges of the map, no linear interpolation + int n=ix+iy*m_nx; + if (m_curr0[n]<1e-6 && (ix+1) <m_nx) n=ix+1 +iy*m_nx; + if (m_curr0[n]<1e-6 && (ix-1) >0 ) n=ix-1 +iy*m_nx; + if (m_curr0[n]<1e-6 && (iy+1) <m_ny) n=ix+(iy+1)*m_nx; + if (m_curr0[n]<1e-6 && (iy-1) <0) n=ix+(iy-1)*m_nx; + if (m_curr0[n]<1e-6 && (ix+1) < m_nx && (iy+1) < m_ny) n=ix+1+(iy+1)*m_nx; + if (m_curr0[n]<1e-6 && (ix-1) >0 && (iy+1) < m_ny) n=ix-1+(iy+1)*m_nx; + if (m_curr0[n]<1e-6 && (ix+1) < m_nx && (iy-1) >0 ) n=ix+1+(iy-1)*m_nx; + if (m_curr0[n]<1e-6 && (ix-1) >0 && (iy-1) >0 ) n=ix-1+(iy-1)*m_nx; + *gap = m_gap[n]; + *curr0 = m_curr0[n]; + *curr1 = m_curr1[n]; + *curr2 = m_curr2[n]; + } +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.h b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.h new file mode 100644 index 000000000000..bdaafd4ca24c --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/CurrMap.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4BARREL_CurrMap_h +#define LARG4BARREL_CurrMap_h + +#include <string> + +class CurrMap { + public: + CurrMap(std::string filename, double xnorm); + ~CurrMap(); + int GetNx() const { return m_nx;} + float GetXmin() const { return m_xmin;} + float GetXmax() const { return m_xmax;} + float GetDx() const { return m_dx;} + int GetNy() const { return m_ny;} + float GetYmin() const { return m_ymin;} + float GetYmax() const { return m_ymax;} + float GetDy() const { return m_dy;} + float GetGap(int ix,int iy) const {return m_gap[iy*m_nx+ix];} + float GetCurr0(int ix,int iy) const {return m_curr0[iy*m_nx+ix];} + float GetCurr1(int ix,int iy) const {return m_curr1[iy*m_nx+ix];} + float GetCurr2(int ix,int iy) const {return m_curr2[iy*m_nx+ix];} + void GetAll(double x, double y, double* gap, double* curr0,double* curr1,double* curr2) const; + private: + CurrMap(const CurrMap&);//coverity issue fix. Declared, but not implemented + CurrMap& operator=(const CurrMap&);//coverity issue fix. Declared, but not implemented + int m_nx,m_ny; + float m_xmin,m_xmax,m_dx,m_ymin,m_ymax,m_dy; + float *m_gap,*m_curr0,*m_curr1,*m_curr2; + float m_norm; + +}; + +#endif // LARG4BARREL_CurrMap_h diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cc deleted file mode 100644 index 7b82eb0b5f80..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cc +++ /dev/null @@ -1,166 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::DM:CalibrationCalculator -// Prepared 11-apr-2006 G.Unal - -// This class calculates the values needed for calibration hits in the -// simulation for steps in the Dead Matter between Barrel and End-Cap cryostats - -// #define DEBUG_HITS - -#include "LArG4Barrel/DMCalibrationCalculator.h" - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" - -#include "G4Step.hh" -#include "G4StepPoint.hh" -#include "G4VPhysicalVolume.hh" -#include "G4ThreeVector.hh" -#include "globals.hh" - -#include <map> -#include <algorithm> -#include <cmath> -#include <climits> - -namespace LArG4 { - - namespace DM { - - /////////////////////////////////////////////////////////// - // Methods - /////////////////////////////////////////////////////////// - - CalibrationCalculator::CalibrationCalculator() - { - } - - - CalibrationCalculator::~CalibrationCalculator() - { - } - - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { -// Calculate the identifier. - -// static ? - static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. - static const double oneOverDphi = 32./M_PI; // 1/Dphi - -// Calculate the mid-point of the step, and the simple geometry variables. - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - //G4double rho = p.perp(); - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation - -#ifdef DEBUG_HITS - std::cout << " DMCalibrationCalculator rho,eta,phi " << p.perp() << " " << eta << " " << phi << std::endl; -#endif - - // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate - G4int subdet = ( p.z() > 0.) ? 4 : -4; - G4int phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>63) phiBin=63; - G4int type = 1; - - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int sampling = INT_MIN; - G4int region = INT_MIN; - G4int etaBin = INT_MIN; - - if (eta < 1.0) { - sampling = 2; - region = 1; - etaBin = (int) ( eta * oneOverDeta ); - } - else if (eta < 1.5) { - sampling = 2; - region = 2; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - } - else if (eta < 1.6) { - sampling = 1; - region = 4; - etaBin = 0; - } - else if (eta < 1.8) { - sampling = 1; - region = 5; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } - else if (eta < 3.2) { - sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.3) * oneOverDeta ); - } - else { - std::cout << " DM::CalibrationCalculator hit above 3.2 in eta !!! " << std::endl; - return false; - } - - -// Append the cell ID to the (empty) identifier. - m_identifier << 10 // Calorimeter - << subdet // LAr +/-4 where "+" or " -" according to - // the sign of Z in World coorinate - << type - << sampling - << region - << etaBin - << phiBin; - - } - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::DM::CalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - - } // namespace DM - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cxx new file mode 100644 index 000000000000..121232716fc2 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.cxx @@ -0,0 +1,164 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4::DM:CalibrationCalculator +// Prepared 11-apr-2006 G.Unal + +// This class calculates the values needed for calibration hits in the +// simulation for steps in the Dead Matter between Barrel and End-Cap cryostats + +// #define DEBUG_HITS + +#include "DMCalibrationCalculator.h" + +#include "LArG4Code/LArG4Identifier.h" + +#include "G4Step.hh" +#include "G4StepPoint.hh" +#include "G4VPhysicalVolume.hh" +#include "G4ThreeVector.hh" +#include "globals.hh" + +#include <map> +#include <algorithm> +#include <cmath> +#include <climits> + +namespace LArG4 { + + namespace DM { + + /////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////// + + CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name,pSvcLocator) + { + } + + + CalibrationCalculator::~CalibrationCalculator() + { + } + + G4bool CalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { + m_energyCalculator.Energies( step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + identifier.clear(); + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + + // static ? + static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. + static const double oneOverDphi = 32./M_PI; // 1/Dphi + + // Calculate the mid-point of the step, and the simple geometry variables. + + G4StepPoint* pre_step_point = step->GetPreStepPoint(); + G4StepPoint* post_step_point = step->GetPostStepPoint(); + + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + //G4double rho = p.perp(); + G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation + +#ifdef DEBUG_HITS + ATH_MSG_DEBUG("Process: rho,eta,phi " << p.perp() << " " << eta << " " << phi); +#endif + + // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate + G4int subdet = ( p.z() > 0.) ? 4 : -4; + G4int phiBin = (int) ( phi * oneOverDphi ); + if (phiBin>63) phiBin=63; + G4int type = 1; + + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int sampling = INT_MIN; + G4int region = INT_MIN; + G4int etaBin = INT_MIN; + + if (eta < 1.0) { + sampling = 2; + region = 1; + etaBin = (int) ( eta * oneOverDeta ); + } + else if (eta < 1.5) { + sampling = 2; + region = 2; + etaBin = (int) ( (eta-1.) * oneOverDeta ); + } + else if (eta < 1.6) { + sampling = 1; + region = 4; + etaBin = 0; + } + else if (eta < 1.8) { + sampling = 1; + region = 5; + etaBin = (int) ( (eta-1.5) * oneOverDeta ); + } + else if (eta < 3.2) { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.3) * oneOverDeta ); + } + else { + ATH_MSG_WARNING("hit above 3.2 in eta !!!"); + return false; + } + + + // Append the cell ID to the (empty) identifier. + identifier << 10 // Calorimeter + << subdet // LAr +/-4 where "+" or " -" according to + // the sign of Z in World coorinate + << type + << sampling + << region + << etaBin + << phiBin; + + } + +#ifdef DEBUG_HITS + G4double energy = accumulate(energies.begin(),energies.end(),0.); + ATH_MSG_DEBUG("Process:" + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")"); +#endif + + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; + + return true; + } + + } // namespace DM + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/DMCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.h similarity index 67% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/DMCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.h index 32d33885be32..69d6e40dc412 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/DMCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/DMCalibrationCalculator.h @@ -11,7 +11,7 @@ #ifndef LArG4_DM_CalibrationCalculator_H #define LArG4_DM_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -31,12 +31,12 @@ namespace LArG4 { namespace DM { - class CalibrationCalculator : public VCalibrationCalculator { + class CalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationCalculator(); + + CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); virtual ~CalibrationCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -47,23 +47,11 @@ namespace LArG4 { // escaped energy), or only the energy (no known application // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; private: - - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelGeometry.h b/LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelGeometry.h new file mode 100644 index 000000000000..c6db4e65066b --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelGeometry.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ILArBarrelGeometry.h +// Prepared in 2016 based on LArVCalculator from Bill Seligman + +#ifndef LARG4BARREL_ILARBARRELGEOMETRY_H +#define LARG4BARREL_ILARBARRELGEOMETRY_H + +#include "GaudiKernel/IService.h" + +#include "globals.hh" + +#include "LArG4Code/LArG4Identifier.h" + + +// Forward declaractions: +class G4Step; + +namespace LArG4 { + + namespace Barrel { + + // output of computations (everything in half barrel frame except m_zSide) + struct CalcData { + int cellID = 0; // 0 if not valid cell + G4int sampling = 0; // sampling number (1 to 3) + G4int region = 0; // region number (0 or 1) + G4int etaBin = 0; // cell number in eta + G4int phiBin = 0; // cell number in phi + G4int zSide = 0; // side (+-1 for +-z) + G4int phiGap = 0; // number (0 to 1024) of closest electrode + G4int nstraight = 0; // number of straight section (0 to 13) + G4int nfold = 0; // number of closest fold (0 to 14) + G4double distElec = 0.; // algebric distance to electrode + G4double distAbs = 0.; // algebric distance to absorber + G4double xl = 0.; // normalized lenght along electrode + G4double x0 = 0.; // + G4double y0 = 0.; // coordinates in local cell frame (down absorber with phi=0) + G4int sampMap = 0; // sampling number not taking into account readout strips + G4int etaMap = 0; // eta number not taking into account readout strips + }; + + } //end of Barrel namespace + +} // end of LArG4 namespace + +class ILArBarrelGeometry: virtual public IService { +public: + + ILArBarrelGeometry() {}; + static const InterfaceID& interfaceID() { + static const InterfaceID IID_ILArBarrelGeometry("ILArBarrelGeometry",1,0); + return IID_ILArBarrelGeometry; + } + + virtual ~ILArBarrelGeometry() {}; + + // Full identifier computation from a G4 step + virtual LArG4Identifier CalculateIdentifier( const G4Step* ) const = 0; + + // Given a point compute all quantities (cell number, distance to electrode, etc...) + virtual void findCell( LArG4::Barrel::CalcData & currentCellData, const double & x, const double & y, const double & z, + const double & r, const double & eta, const double & phi, const bool detail) const = 0; + +}; + +#endif // LARG4BARREL_ILARBARRELGEOMETRY_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelPresamplerGeometry.h b/LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelPresamplerGeometry.h new file mode 100644 index 000000000000..ca8cf02d0caf --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/ILArBarrelPresamplerGeometry.h @@ -0,0 +1,60 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ILArBarrelPresamplerGeometry.h +// Prepared in 2016 based on LArVCalculator from Bill Seligman + +#ifndef LARG4BARREL_ILARBARRELPRESAMPLERGEOMETRY_H +#define LARG4BARREL_ILARBARRELPRESAMPLERGEOMETRY_H + +#include "GaudiKernel/IService.h" + +#include "globals.hh" + +#include "LArG4Code/LArG4Identifier.h" + + +// Forward declaractions: +class G4Step; + +namespace LArG4 { + + namespace BarrelPresampler { + + // output of computations + struct CalcData { + G4int sampling = 0; // sampling number (1 to 3) + G4int region = 0; // region number (0 or 1) + G4int etaBin = 0; // cell number in eta + G4int phiBin = 0; // cell number in phi + G4int gap = 0; + G4int module = 0; + G4double distElec = 0.; // algebric distance to electrode + G4double xElec = 0.; // projection along electrode axis + G4double dist = 0.; + }; + + } //end of BarrelPresampler namespace + +} // end of LArG4 namespace + +class ILArBarrelPresamplerGeometry: virtual public IService { +public: + + ILArBarrelPresamplerGeometry() {}; + static const InterfaceID& interfaceID() { + static const InterfaceID IID_ILArBarrelPresamplerGeometry("ILArBarrelPresamplerGeometry",1,0); + return IID_ILArBarrelPresamplerGeometry; + } + + virtual ~ILArBarrelPresamplerGeometry() {}; + + // Full identifier computation from a G4 step + virtual LArG4Identifier CalculateIdentifier( const G4Step*) const = 0; + + // Given a point compute all quantities (cell number, distance to electrode, etc...) + virtual bool findCell(LArG4::BarrelPresampler::CalcData & currentCellData, G4double xloc,G4double yloc,G4double zloc) const = 0; +}; + +#endif // LARG4BARREL_ILARBARRELPRESAMPLERGEOMETRY_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cc deleted file mode 100644 index e417dccfe4bd..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cc +++ /dev/null @@ -1,794 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -// The Cell Identifier for the EM Barrel readout cells - -// Adapted from code written by Gaston Parrour -// Adaptation by Sylvain Negroni -// 17-11-2003: G.Unal cleanup -// 18-03-2003: G.Unal major revision to use new current maps - -// #define DEBUGSTEP -// #define DEBUGSTEP2 - -#include "LArG4Barrel/LArBarrelCalculator.h" -#include "LArG4Barrel/AccMap.h" -#include "LArG4Barrel/MapEta.h" - -#include "LArG4Code/LArVG4DetectorParameters.h" -#include "LArG4Code/LArG4BirksLaw.h" - -#include "LArG4RunControl/LArG4BarrelOptions.h" - -#include "G4ThreeVector.hh" -#include "G4StepPoint.hh" -#include "G4Step.hh" -#include "G4ios.hh" -#include "G4AffineTransform.hh" -#include "G4NavigationHistory.hh" -#include "G4VTouchable.hh" -#include "G4TouchableHistory.hh" - -#include <cmath> -#include <iostream> - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" -#include "AthenaKernel/Units.h" -#include "CxxUtils/make_unique.h" - -#include "LArHV/LArHVManager.h" -#include "LArHV/EMBHVManager.h" -#include "LArHV/EMBHVModule.h" -#include "LArHV/EMBHVModuleConstLink.h" -#include "LArHV/EMBHVElectrode.h" -#include "LArHV/EMBHVElectrodeConstLink.h" - -namespace Units = Athena::Units; - - -LArBarrelCalculator* LArBarrelCalculator::m_instance = 0; - -// ============================================================================== -LArBarrelCalculator* LArBarrelCalculator::GetCalculator() -{ - if (m_instance == 0) m_instance = new LArBarrelCalculator(); - return m_instance; -} - -// ================================================================================ -LArBarrelCalculator::LArBarrelCalculator() - : m_IflCur(true) - , m_IflMapTrans(true) - , m_IflXtalk(true) - , m_dstep(.2*CLHEP::mm) - , m_birksLaw(NULL) - , m_doHV(false) - , m_detectorName("LArMgr") - , m_nhits(0) -{ - std::cout << "LArBarrelCalculator: Beginning initialisation " << std::endl; - - // define RUN conditions for the Barrel - - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StoreGateSvc *detStore; - LArG4BarrelOptions *barrelOptions; - - StatusCode status = svcLocator->service("DetectorStore", detStore); - - if(status.isFailure()) - std::cout << "LArBarrelCalculator::LArBarrelCalculator() unable to get Detector Store! Using default values.\n"; - else { - status = detStore->retrieve(barrelOptions, "LArG4BarrelOptions"); - - if(status.isFailure()) - std::cout << "LArBarrelCalculator::LArBarrelCalculator() unable to get LArG4BarrelOptions! Using default values.\n"; - else { - m_IflCur = barrelOptions->EMBCurr(); - m_IflMapTrans = barrelOptions->EMBEtaTrans(); - m_IflXtalk = barrelOptions->EMBXtalk(); - - m_dstep = barrelOptions->EMBdstep(); - - bool IflBirks = barrelOptions->EMBBirksLaw(); - if (IflBirks) { - const double Birks_LAr_density = 1.396; - const double Birks_k = barrelOptions->EMBBirksk(); - m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); - } - m_doHV=barrelOptions->EMBHVEnable(); - } - } - - m_identifier2 = LArG4Identifier(); - m_identifier_xt1 = LArG4Identifier(); - m_identifier_xt2 = LArG4Identifier(); - -// Access source of detector parameters. - m_parameters = LArVG4DetectorParameters::GetInstance(); - -// Get the out-of-time cut from the detector parameters routine. - m_OOTcut = m_parameters->GetValue("LArExpHallOutOfTimeCut"); - std::cout << "**** OutOfTime cut " << m_OOTcut << std::endl; - -// Main Barrel parameters -// All the UNITS are implicitly the GEANT4 ONES e.g. mm, rad, etc ... - m_etaMaxBarrel = m_parameters->GetValue("LArEMBMaxEtaAcceptance"); - m_zMinBarrel = m_parameters->GetValue("LArEMBfiducialMothZmin"); - m_zMaxBarrel = m_parameters->GetValue("LArEMBfiducialMothZmax"); - m_NCellMax = (int) (m_parameters->GetValue("LArEMBnoOFPhysPhiCell")); - m_rMinAccordion = m_parameters->GetValue("LArEMBRadiusInnerAccordion"); - m_rMaxAccordion = m_parameters->GetValue("LArEMBFiducialRmax"); - -// absorbers and electrodes thickness - m_ThickAbs = 0.5*( m_parameters->GetValue("LArEMBThickAbsGlue") - +m_parameters->GetValue("LArEMBThickAbsIron") - +m_parameters->GetValue("LArEMBThickAbsLead")); - - G4double check = 0.5*( m_parameters->GetValue("LArEMBThinAbsGlue") - +m_parameters->GetValue("LArEMBThinAbsIron") - +m_parameters->GetValue("LArEMBThinAbsLead")); - - if (fabs(check-m_ThickAbs)>0.001) { - std::cout << " LArBarrelCalculator: WARNING THin and Thick Abs have difference thickness !" << std::endl; - } - - m_ThickEle= 0.5*( m_parameters->GetValue("LArEMBThickElecCopper") - +m_parameters->GetValue("LArEMBThickElecKapton")); - -// === GU 11/06/2003 total number of cells in phi -// to distinguish 1 module (testbeam case) from full Atlas - m_testbeam=false; - m_NCellTot = (int) (m_parameters->GetValue("LArEMBnoOFPhysPhiCell")); - if (m_NCellTot != 1024) { - m_NCellMax=1024; - m_testbeam=true; - } -// === -// access geometry computation class - m_geometry = LArG4::Barrel::Geometry::GetInstance(); - -// access current maps if required - if (m_IflCur) - std::cout << " LArBarrelCalculator: start reading of current maps" << std::endl; - if (m_IflCur) m_accmap = AccMap::GetAccMap(); - else m_accmap = 0; - if (m_IflCur) { - m_etamap1 = CxxUtils::make_unique<MapEta>(1); - m_etamap2 = CxxUtils::make_unique<MapEta>(2); - if (m_IflMapTrans) m_etamap3 = CxxUtils::make_unique<MapEta>(3); - } - if (m_IflCur) - std::cout << " LArBarrelCalculator: end of reading current maps" << std::endl; - -// Initialize HV values - InitHV(); - - std::cout << " LArBarrelCalculator: m_NCellMax " << m_NCellMax << std::endl; - std::cout << " LArBarrelCalculator: m_NCellTot " << m_NCellTot << std::endl; - std::cout << " LArBarrelCalculator: m_rMinAccordion " << m_rMinAccordion << std::endl; - std::cout << " LArBarrelCalculator: m_rMaxAccordion " << m_rMaxAccordion << std::endl; - std::cout << " LArBarrelCalculator: m_zMinBarrel " << m_zMinBarrel << std::endl; - std::cout << " LArBarrelCalculator: m_zMaxBarrel " << m_zMaxBarrel << std::endl; - std::cout << " LArBarrelCalculator: m_etaMaxBarrel " << m_etaMaxBarrel << std::endl; - std::cout << " LArBarrelCalculator: m_ThickAbs " << m_ThickAbs << std::endl; - std::cout << " LArBarrelCalculator: m_ThickEle " << m_ThickEle << std::endl; - if(m_IflCur) std::cout <<" LArBarrelCalculator: Deposited Energy dE/dX Corrected ==> CURRENT Option ON"<<std::endl; - else std::cout << " LArBarrelCalculator: Crude Deposited Energy dE/dX NO CURRENT option"<< std::endl; - if (m_IflCur && m_IflMapTrans) std::cout<<" LArBarrelCalculator: Compute effect of E field around eta=0.8 " << std::endl; - else std::cout <<" LArBarrelCalculator: Ignore effect of E field around eta=0.8 " << std::endl; - if(m_birksLaw) { - std::cout << " LArBarrelCalculator: Birks' law ON " << std::endl; - std::cout << " LArBarrelCalculator: parameter k " << m_birksLaw->k() << std::endl; - } - else - std::cout << " LArBarrelCalculator: Birks' law OFF" << std::endl; - -} - -// ============================================================================ -LArBarrelCalculator::~LArBarrelCalculator() -{ - if (m_birksLaw) delete m_birksLaw; -} - -// ============================================================================= -G4bool LArBarrelCalculator::Process(const G4Step* step, std::vector<LArHitData>& hdata) -{ - - m_nhits = 0; - //m_identifier.clear(); - //m_energy.clear(); - //m_time.clear(); - hdata.clear(); - m_isInTime.clear(); - -// check the Step content is non trivial - G4double thisStepEnergyDeposit = step->GetTotalEnergyDeposit(); - G4double thisStepLength = step->GetStepLength() / Units::mm; - -#ifdef DEBUGSTEP - std::cout << "****** LArBarrelCalculator: Step energy,length " - << thisStepEnergyDeposit << " " << thisStepLength << std::endl; -#endif - - if(thisStepEnergyDeposit <= 0. || thisStepLength <= 0.) - { -#ifdef DEBUGSTEP2 - std::cout << " Invalid hit trivial content" << std::endl; -#endif - return false; - } - -// Get Step geometrical parameters (first and end) - G4StepPoint *thisStepPoint = step->GetPreStepPoint(); - G4StepPoint *thisStepBackPoint = step->GetPostStepPoint(); - G4ThreeVector startPoint = thisStepPoint->GetPosition(); - G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); - -#ifdef DEBUGSTEP - std::cout << " Beginning step position " - << startPoint.x() << " " << startPoint.y() << " " << startPoint.z() << std::endl; -#endif - -// find zside from volume name - G4int zSide = 1; - if (!m_testbeam) { - const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); - G4int ndep = g4navigation->GetDepth(); - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - G4String vname = v1->GetName(); - if ( vname.find("NegPhysical") != std::string::npos) zSide=-1; - } - } - - -// BACK directly into the LOCAL half_Barrel Z > 0. PART (mother "stac_phys1") - - const G4AffineTransform transformation = - thisStepPoint->GetTouchable()->GetHistory()->GetTopTransform(); - - G4ThreeVector startPointinLocal = - transformation.TransformPoint(startPoint); - G4ThreeVector endPointinLocal = - transformation.TransformPoint (endPoint); - -#ifdef DEBUGSTEP - std::cout << " Local beginning step position " - << startPointinLocal.x() << " " << startPointinLocal.y() << " " - << startPointinLocal.z() << std::endl; - std::cout << " Local end step position " - << endPointinLocal.x() << " " << endPointinLocal.y() << " " - << endPointinLocal.z() << std::endl; -#endif - - G4double energy = step->GetTotalEnergyDeposit(); // Despite the name, this is only ionization. - - if (m_birksLaw) { - const double EField = 10.; // kV/cm, assume constant for now - const double wholeStepLengthCm = step->GetStepLength() / Units::cm; - energy = (*m_birksLaw)(energy, wholeStepLengthCm, EField); - } - - -// compute number of sub steps -// = 1 if no charge collection -// otherwise 200 microns (dstep) division - - G4int nsub_step=1; - if (m_IflCur) nsub_step=(int) (thisStepLength/m_dstep) + 1; -// delta is fraction of step between two sub steps - G4double delta=1./((double) nsub_step); -#ifdef DEBUGSTEP - std::cout << " nsub_step,delta " << nsub_step << " " << delta << std::endl; -#endif - - energy /= ((float) (nsub_step)); // Divide into substeps. - -// loop over sub steps - - for (G4int i=0;i<nsub_step;i++) { - - bool Xtalk = false; - - G4double fraction=(((G4double) i)+0.5)*delta; - G4ThreeVector subinLocal=startPointinLocal*(1-fraction) + endPointinLocal*fraction; - G4double xloc = subinLocal.x(); - G4double yloc = subinLocal.y(); - G4double zloc = subinLocal.z(); - G4double etaloc = subinLocal.pseudoRapidity(); - G4double philoc = subinLocal.phi(); - if(philoc<0.) philoc = philoc + 2.*M_PI; - G4double radloc = sqrt( xloc*xloc + yloc*yloc ); -#ifdef DEBUGSTEP - std::cout << " local position sub_step " - << xloc << " " << yloc << " " << zloc << std::endl; -#endif - -// apply fiducial cuts - if (!FiducialCuts(radloc,zloc,etaloc)) { -#ifdef DEBUGSTEP - std::cout << "LArBarrelCalculator: outside fiducial cuts" << std::endl; -#endif - continue; - } - - m_geometry->findCell(xloc,yloc,zloc,radloc,etaloc,philoc,m_IflCur,m_detectorName); - - if (m_geometry->cellID() == 0) - { -#ifdef DEBUGSTEP - std::cout << "LArBarrelCalculator: Invalid hit CELLID == 0 "<<std::endl; - std::cout << "x,y,z local " << xloc << " " << yloc << " " << zloc << std::endl; - std::cout << "radius " << radloc <<" etaloc "<< etaloc << " philoc " << philoc <<std::endl; -#endif - continue; - } - G4int region = m_geometry->region(); - G4int etaBin = m_geometry->etaBin(); - G4int phiBin = m_geometry->phiBin(); - G4int sampling = m_geometry->sampling(); - - if( zSide == -1 ) - { -// following code for an Y-axis rotation to define Z < 0. Barrel part - if( sampling == 1 && region ==0 ) - { - phiBin = 31 - phiBin; - if(phiBin < 0 ) phiBin += 64; - } - if( sampling == 1 && region ==1 ) - { - phiBin = 127 - phiBin; - if(phiBin < 0 ) phiBin += 256; - } - if( sampling >= 2 ) - { - phiBin = 127 - phiBin; - if(phiBin < 0 ) phiBin += 256; - } - } -#ifdef DEBUGSTEP - std::cout << " region,side,sampling,eta,phi " << region << " " << zSide << " " - << sampling << " " << etaBin << " " << phiBin << std::endl; - std::cout << " distance to electrode,abs " << m_geometry->distElec() << " " - << m_geometry->distAbs() << std::endl; - std::cout << " local coordinates " << m_geometry->x0() << " " << m_geometry->y0() << std::endl; -#endif - - if (std::fabs(m_geometry->distElec())< m_ThickEle || - std::fabs(m_geometry->distAbs()) < m_ThickAbs) { -#ifdef DEBUGSTEP - std::cout << " hit in absorber or electrode radius:" << radloc << std::endl; -#endif - continue; - } - - m_identifier2.clear(); - m_identifier2 << 4 // LArCalorimeter - << 1 // LArEM - << zSide - << sampling - << region - << etaBin - << phiBin; - -// time computation is not necessarily correct for test beam - G4double time; - if (m_testbeam) - { - time=0.; - } - else - { - G4double tof; - tof = thisStepPoint->GetGlobalTime() / Units::ns; - time = tof - ( thisStepPoint->GetPosition().mag()/Units::c_light ) / Units::ns; - } - -#ifdef DEBUGSTEP - std::cout << " Energy for sub step " << energy << std::endl; -#endif - - G4double Current; - G4double Current_xt1,Current_xt2; - Current_xt1=0; - Current_xt2=0; - if (!m_IflCur) { -// no charge collection Current=E from Geant - Current=energy; - } - else { -// full charge collection - G4double xmap,ymap; - G4int nfold = m_geometry->nfold(); - G4double x0=m_geometry->x0(); - G4double y0=m_geometry->y0(); - if (x0<1500 || x0>1960 || y0>30 || y0<-30) { - std::cout << "weird x0,y0 " << x0 << " " << y0 << std::endl; - } -#ifdef DEBUGSTEP - G4double rr = sqrt(x0*x0+y0*y0); - std::cout << " radius,rad0 " << radloc << " " << rr << std::endl; -#endif - bool UseFold=false; -// Are we close to a fold ? (fold 0 has some pathology) - if ((x0 > m_accmap->GetXmin(nfold) || nfold==0) && - x0 < m_accmap->GetXmax(nfold) && - y0 > m_accmap->GetYmin(nfold) && - y0 < m_accmap->GetYmax(nfold) && - (nfold != 13 || x0 < 1957.5) && - (nfold>0 || x0 < 1504.6) ) { - xmap=x0; - ymap=y0; -#ifdef DEBUGSTEP - std::cout << " Map for fold xmap,ymap " << nfold << " " << xmap << " " << ymap << std::endl; -#endif - UseFold=true; - G4int sampMap = m_geometry->sampMap(); - G4int etaMap = m_geometry->etaMap(); - m_accmap->SetMap(nfold,region,sampMap,etaMap); -// catch problem to find map - if (!m_accmap->Map()) { - std::cout << " Problem to access map fold = " << nfold << std::endl; - std::cout << " region,sampling,eta,fold " << region << " " << sampMap << " " - << etaMap << " " << nfold << std::endl; - return false; - } - } - else { - G4int n; - G4int nstraight = m_geometry->nstraight(); - if (nstraight%2==0) n=22; - else n=21; - m_accmap->SetMap(n,region,sampling,etaBin); -// catch problem to find map - if (!m_accmap->Map()) { - std::cout << " Problem to access map straight = " << nstraight << std::endl; - return false; - } - xmap = m_geometry->xl(); - ymap = m_geometry->distElec(); -// special case for first straight section, which is shorter - if (nstraight==0) xmap = 0.5*(xmap+1.); -#ifdef DEBUGSTEP - std::cout << " Map for straight xl,delec " << xmap << " " << ymap << std::endl; -#endif - } // fold or straight - double gap; - double current0,current1,current2; -// get current for elementary charge - m_accmap->Map()->GetAll(xmap,ymap,&gap,¤t0,¤t1,¤t2); - G4double gap2=std::fabs(m_geometry->distElec())+std::fabs(m_geometry->distAbs()) - -m_ThickEle-m_ThickAbs; - -// in which HV cell are we ? - int ipm,ielec,ieta,iside; - if (zSide==1) ipm=1; // A side - else ipm=0; // C side - ielec=m_geometry->phiGap(); - if (zSide==-1) { - ielec = 511 - ielec; - if(ielec < 0 ) ielec += 1024; - } - ieta=((int) (etaloc*(1./0.2))); - if (ieta>6) ieta=6; //part 1.4 to 1.475 is same HV as 1.2 to 1.4 - iside=0; // phi lower than electrode 0, 1 for phi higher than electrode - if ((m_geometry->distElec()>0 && zSide==1) - || (m_geometry->distElec()<0 && zSide==-1) ) iside=1; - -// HV extrapolation - double current; - double hv=m_hv[ipm][ielec][ieta][iside]; -// std::cout << " etaBin,phiBin " << etaBin << " " << phiBin << std::endl; -// std::cout << " ipm,ielec,ieta,iside " << ipm << " " << ielec << " " << ieta -// << " " << iside << std::endl; -// std::cout << " hv " << hv << std::endl; -// std::cout << " current0,current1,current2 " << current0 << " " << current1 -// << " " << current2 << std::endl; - if (hv>1995.) current=current0; - else if (hv>5.) current=ScaleHV(hv,current0,current1,current2); - else current=0.; -// std::cout << " current " << current << std::endl; - -// extrapolation for non nominal gap (allows to include sagging effect) -// i ~ (gap/gap2)**1.3 -// gap = nominal gap from current map -// gap2 = real gap from geometry -// dgap = gap/gap2 -1 -// at first order i ~ (1+1.3*dgap) - double dgap=0; - if (gap>1e-3 && gap2 >1e-3) dgap=gap/gap2-1; - current = current * (1. + 1.3*dgap); - -#ifdef DEBUGSTEP - std::cout << " elementary current " << current0 << std::endl; - std::cout << " Gap from Map/calculator " << gap << " " << gap2 << std::endl; -#endif - - Current = energy*current; - -// check if pathology... - if (!UseFold && std::fabs(m_geometry->distElec())>2.1 && current0 < 0.1) { - std::cout << " xl,distEle " << m_geometry->xl() << " " - << m_geometry->distElec() - << " str number " << m_geometry->nstraight() - << " sampling,eta " << sampling << " " << etaBin << " " - << " current/E " << current0 << std::endl; - } - -// compute effect around transition at eta=0.8 from electric field -// read from map weighting factor ( E**1.3 = E*E**0.3) -// in x +-9mm around transition (assume symmetry around 0) -// in y distance from electrode in gap - bool InTrans=false; - //double Current_test=Current; - if (m_IflMapTrans) { - float etaTrans=0.8; - if (fabs(etaloc-etaTrans) < 0.025) { - double x=std::fabs(zloc-radloc*sinh(etaTrans))/cosh(etaTrans); - double y=std::fabs(m_geometry->distElec()); - if ( x < m_etamap3->Xmax() ) { - double resp; - m_etamap3->GetData0(x,y,&resp); - Current = Current*resp; - InTrans=true; - } - } // eta = 0.8 +- 0.025 - } // if m_IflMapTrans - -// simulate cross-talk effects and transitions in eta between cells -// (only in region 0, samplings 1 and 2) - - if (region==0) { - - double resp,xt0,xt1,xt2,deta; - if (sampling==1) { - deta=etaloc-0.003125*((double)etaBin+0.5); - m_etamap1->GetData(std::fabs(deta),std::fabs(m_geometry->distElec()), - &resp,&xt0,&xt1,&xt2); -#ifdef DEBUGSTEP - std::cout << "hit in strip etaloc,etaBin,deta,delec,resp,xt0,xt1,xt2 " - << etaloc << " " << etaBin << " " << deta*1000 << " " << m_geometry->distElec() - << " " << resp << " " << xt0 << " " << xt1 << " " << xt2 << std::endl; -#endif - if (!InTrans) Current = Current*resp; - if (m_IflXtalk && etaBin > 1 && etaBin < 446) { - Xtalk=true; - if (deta>0) { - m_identifier_xt1.clear(); - m_identifier_xt1 << 4 << 1 << zSide << sampling << region << (etaBin+1) << phiBin; - Current_xt1 = Current*xt1; - m_identifier_xt2.clear(); - m_identifier_xt2 << 4 << 1 << zSide << sampling << region << (etaBin-1) << phiBin; - Current_xt2 = Current*xt2; - } - else { - m_identifier_xt1.clear(); - m_identifier_xt1 << 4 << 1 << zSide << sampling << region << (etaBin-1) << phiBin; - Current_xt1 = Current*xt1; - m_identifier_xt2.clear(); - m_identifier_xt2 << 4 << 1 << zSide << sampling << region << (etaBin+1) << phiBin; - Current_xt2 = Current*xt2; - } - Current = Current*xt0; - } // m_IflXtalk = true - } - else if (sampling==2 && !InTrans) { - deta=etaloc-0.025*((double)etaBin+0.5); - m_etamap2->GetData0(std::fabs(deta),std::fabs(m_geometry->distElec()), - &resp); -#ifdef DEBUGSTEP - std::cout << "hit in middle etaloc,etaBin,deta,delec,resp,xt0,xt1,xt2 " - << etaloc << " " << etaBin << " " << deta*1000 << " " << m_geometry->distElec() - << " " << resp << std::endl; -#endif - Current = Current*resp; - } // sampling =1 or 2 - - } // region=0 - - } // switch for current simulation - - -// check if we have a new hit in a different cell, or if we add this substep -// to an already existing hit - G4bool found=false; - for (int i=0; i<m_nhits; i++) { - if (hdata[i].id==m_identifier2) { - hdata[i].energy += Current; - hdata[i].time += time*Current; - found=true; - break; - } - } // loop over hits - if (!found) { - m_nhits++; - LArHitData newdata = {m_identifier2, time*Current, Current}; - hdata.push_back(newdata); - m_isInTime.push_back(true); - } // hit was not existing before - - if (Xtalk) { - for (int i=0; i<m_nhits; i++) { - if (hdata[i].id==m_identifier_xt1) { - hdata[i].energy += Current_xt1; - hdata[i].time += time*Current_xt1; - found=true; - break; - } - } // loop over hits - if (!found) { - m_nhits++; - LArHitData newdata = {m_identifier_xt1, time*Current_xt1, Current_xt1}; - hdata.push_back(newdata); - m_isInTime.push_back(true); - } - found=false; - for (int i=0; i<m_nhits; i++) { - if (hdata[i].id==m_identifier_xt2) { - hdata[i].energy += Current_xt2; - hdata[i].time += time*Current_xt2; - found=true; - break; - } - } // loop over hits - if (!found) { - m_nhits++; - LArHitData newdata = {m_identifier_xt2, time*Current_xt2, Current_xt2}; - hdata.push_back(newdata); - m_isInTime.push_back(true); - } - } // Xtalk true - - - } // *** End of loop over sub steps - -#ifdef DEBUGSTEP - std::cout << "Number of hits for this step " << m_nhits << " " - << hdata.size() << std::endl; -#endif - -// finalise time computations - for (int i=0;i<m_nhits;i++) { - if (std::fabs(hdata[i].energy)>1e-6) hdata[i].time=hdata[i].time/hdata[i].energy; - else hdata[i].time=0.; - if (std::fabs(hdata[i].time)> m_OOTcut) m_isInTime[i]=false; -#ifdef DEBUGSTEP - std::cout << "Hit Energy/Time " - << hdata[i].energy << " " << hdata[i].time << std::endl; -#endif - } - - if (m_nhits>0) return true; - else return false; - -} - -// =============================================================================== -// Cuts to define active region of accordion calorimeter -// 1500.024 < r < 1960.00 mm -// |eta| < 1.475 -// 4 < z < 3164 mm (in local half barrel coordinates) - -G4bool LArBarrelCalculator::FiducialCuts(G4double radloc,G4double zloc,G4double etaloc) -{ - if (radloc < m_rMinAccordion || - radloc > m_rMaxAccordion || - etaloc > m_etaMaxBarrel || - zloc < m_zMinBarrel || - zloc > m_zMaxBarrel) return false; - else return true; -} - -// ========================================================================== -// HV values -// set all to 2000V. This should be changed if one wants to simulate -// some HV imperfections -void LArBarrelCalculator::InitHV() -{ - std::cout << " **** in LArBarrelCalculator::InitHV() " << std::endl; - - - - - float defaultHvVal=2000.; - std::cout << " defaultHvVal " << defaultHvVal <<std::endl; - for (int ipm=0;ipm<2;ipm++) { - for (int ielec=0;ielec<1024;ielec++) { - for (int ieta=0;ieta<7;ieta++) { - for (int iside=0;iside<2;iside++) { - m_hv[ipm][ielec][ieta][iside] = defaultHvVal; - } - } - } - } - - if (m_doHV) { - // initialize services - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StoreGateSvc* pDetStore; - - StatusCode status = svcLocator->service("DetectorStore", pDetStore); - if(status.isFailure()) - { - std::cout << "LArBarrelCalculator::InitHV() unable to get Detector Store! Use default HV values\n"; - return; - } - - // get EMBHV Manager - const LArHVManager *manager = NULL; - if (pDetStore->retrieve(manager)==StatusCode::SUCCESS) { - const EMBHVManager* hvManager=manager->getEMBHVManager(); - std::cout << " got HV Manager " << std::endl; - // loop over HV modules - for (unsigned int iSide=0;iSide<2;iSide++) { - for (unsigned int iPhi=0;iPhi<16;iPhi++) { - for (unsigned int iSector=0;iSector<2;iSector++) { - for (unsigned int iEta=0;iEta<7;iEta++) { - EMBHVModuleConstLink hvMod = hvManager->getHVModule(iSide,iEta+1,iPhi,iSector); - for (unsigned int ielec=0;ielec<32;ielec++) { - EMBHVElectrodeConstLink electrode = hvMod->getElectrode(ielec); - unsigned jElec = ielec+32*iSector+64*iPhi; - for (unsigned int iGap=0;iGap<2;iGap++) { - double hv = electrode->voltage(iGap); - std::cout << " iSide,jElec,iEta,iGap,hv " << iSide << " " << jElec << " " << iEta << " " << iGap << " " << hv << std::endl; - if (hv>-999.) m_hv[iSide][jElec][iEta][iGap] = hv; - } - } - } - } - } - } - } - else { - std::cout << " Unable to find HV Manager " << std::endl; - } - } - - return; -} - -//========================================================================== -// extrapolate response with HV -// hv = actual HV -// curr0 = response for 2000V, curr1 = for 1000V, curr2 for 400V -// assumes resp = a* HV*b between 1000-2000 and 400-1000V -// (fixes b=0.57 for HV smaller than 400V) - -double LArBarrelCalculator::ScaleHV(double hv, double curr0, double curr1, double curr2) -{ - double b; - double resp=0.; - if (hv>1000.) { - if (std::fabs(curr1)>1e-6) { - double x=curr0/curr1; - if (x>1e-6) { - b=log(x)*(1./(log(2000.)-log(1000.))); - resp = curr0*exp(b*(log(hv)-log(2000.))); - } - } - } - else if (hv>400.) { - if (std::fabs(curr2)>1e-6) { - double x=curr1/curr2; - if (x>1e-6) { - b=log(x)*(1./(log(1000.)-log(400.))); - resp = curr1*exp(b*(log(hv)-log(1000.))); - } - } - } - else { - if (std::fabs(curr2)>1e-6) { - b=0.57; - resp = curr2*exp(b*(log(hv)-log(400.))); - } - } - return resp; -} - diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx new file mode 100644 index 000000000000..17176895aab6 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.cxx @@ -0,0 +1,761 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// The Cell Identifier for the EM Barrel readout cells + +// Adapted from code written by Gaston Parrour +// Adaptation by Sylvain Negroni +// 17-11-2003: G.Unal cleanup +// 18-03-2003: G.Unal major revision to use new current maps + +// #define DEBUGSTEP +// #define DEBUGSTEP2 + +#include "LArBarrelCalculator.h" +#include "AccMap.h" +#include "MapEta.h" + +#include "LArG4Code/LArG4BirksLaw.h" +#include "LArG4Code/LArVG4DetectorParameters.h" + +//#include "LArG4RunControl/LArG4BarrelOptions.h" + +#include "G4ThreeVector.hh" +#include "G4StepPoint.hh" +#include "G4Step.hh" +#include "G4ios.hh" +#include "G4AffineTransform.hh" +#include "G4NavigationHistory.hh" +#include "G4VTouchable.hh" +#include "G4TouchableHistory.hh" + +#include <cmath> +#include <iostream> + +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Bootstrap.h" +#include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/Units.h" +#include "CxxUtils/make_unique.h" + +#include "LArHV/LArHVManager.h" +#include "LArHV/EMBHVManager.h" +#include "LArHV/EMBHVModule.h" +#include "LArHV/EMBHVModuleConstLink.h" +#include "LArHV/EMBHVElectrode.h" +#include "LArHV/EMBHVElectrodeConstLink.h" + +namespace Units = Athena::Units; + +// ================================================================================ +LArBarrelCalculator::LArBarrelCalculator(const std::string& name, ISvcLocator* pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_geometry("LArBarrelGeometry", name) + , m_accmap(nullptr) + , m_IflCur(true) + , m_IflMapTrans(true) + , m_IflXtalk(true) + , m_dstep(.2*CLHEP::mm) + , m_birksLaw(nullptr) + , m_doHV(false) + , m_testbeam(false) +{ + ATH_MSG_DEBUG("LArBarrelCalculator: Beginning construction "); + + declareProperty("GeometryCalculator", m_geometry); + // define RUN conditions for the Barrel + declareProperty("EMBCurr",m_IflCur); + declareProperty("EMBEtaTrans",m_IflMapTrans); + declareProperty("EMBXtalk",m_IflXtalk); + declareProperty("EMBdstep", m_dstep); + declareProperty("EMBHVEnable",m_doHV); +} + +StatusCode LArBarrelCalculator::initialize() +{ + ATH_MSG_DEBUG("LArBarrelCalculator: Beginning initialization "); + if (m_BirksLaw) { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); + } + + // Access source of detector parameters. + LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); + + // Get the out-of-time cut from the detector parameters routine. + m_OOTcut = parameters->GetValue("LArExpHallOutOfTimeCut"); //FIXME should be done via configurables + ATH_MSG_DEBUG("**** OutOfTime cut " << m_OOTcut); + + // Main Barrel parameters + // All the UNITS are implicitly the GEANT4 ONES e.g. mm, rad, etc ... + m_etaMaxBarrel = parameters->GetValue("LArEMBMaxEtaAcceptance"); + m_zMinBarrel = parameters->GetValue("LArEMBfiducialMothZmin"); + m_zMaxBarrel = parameters->GetValue("LArEMBfiducialMothZmax"); + m_NCellMax = (int) (parameters->GetValue("LArEMBnoOFPhysPhiCell")); + m_rMinAccordion = parameters->GetValue("LArEMBRadiusInnerAccordion"); + m_rMaxAccordion = parameters->GetValue("LArEMBFiducialRmax"); + + // absorbers and electrodes thickness + m_ThickAbs = 0.5*( parameters->GetValue("LArEMBThickAbsGlue") + +parameters->GetValue("LArEMBThickAbsIron") + +parameters->GetValue("LArEMBThickAbsLead")); + + G4double check = 0.5*( parameters->GetValue("LArEMBThinAbsGlue") + +parameters->GetValue("LArEMBThinAbsIron") + +parameters->GetValue("LArEMBThinAbsLead")); + + if (fabs(check-m_ThickAbs)>0.001) + { + ATH_MSG_WARNING("Thin and Thick Abs have difference thickness!"); + } + + m_ThickEle= 0.5*( parameters->GetValue("LArEMBThickElecCopper") + +parameters->GetValue("LArEMBThickElecKapton")); + + // === GU 11/06/2003 total number of cells in phi + // to distinguish 1 module (testbeam case) from full Atlas + m_NCellTot = (int) (parameters->GetValue("LArEMBnoOFPhysPhiCell")); + if (m_NCellTot != 1024) + { + m_NCellMax=1024; + m_testbeam=true; + } + // === + // access geometry computation class + ATH_CHECK(m_geometry.retrieve()); + + // access current maps if required + if (m_IflCur) + { + ATH_MSG_DEBUG(" LArBarrelCalculator: start reading of current maps"); + m_accmap = AccMap::GetAccMap(); + m_etamap1 = CxxUtils::make_unique<MapEta>(1); + m_etamap2 = CxxUtils::make_unique<MapEta>(2); + if (m_IflMapTrans) m_etamap3 = CxxUtils::make_unique<MapEta>(3); + ATH_MSG_DEBUG(" LArBarrelCalculator: end of reading current maps"); + } + // Initialize HV values + this->InitHV(); + + ATH_MSG_DEBUG(" LArBarrelCalculator: s_NCellMax " << m_NCellMax); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_NCellTot " << m_NCellTot); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_rMinAccordion " << m_rMinAccordion); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_rMaxAccordion " << m_rMaxAccordion); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_zMinBarrel " << m_zMinBarrel); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_zMaxBarrel " << m_zMaxBarrel); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_etaMaxBarrel " << m_etaMaxBarrel); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_ThickAbs " << m_ThickAbs); + ATH_MSG_DEBUG(" LArBarrelCalculator: s_ThickEle " << m_ThickEle); + if(m_IflCur) ATH_MSG_DEBUG(" LArBarrelCalculator: Deposited Energy dE/dX Corrected ==> CURRENT Option ON"); + else ATH_MSG_DEBUG(" LArBarrelCalculator: Crude Deposited Energy dE/dX NO CURRENT option"); + if (m_IflCur && m_IflMapTrans) ATH_MSG_DEBUG(" LArBarrelCalculator: Compute effect of E field around eta=0.8 "); + else ATH_MSG_DEBUG(" LArBarrelCalculator: Ignore effect of E field around eta=0.8 "); + if(m_BirksLaw) + { + ATH_MSG_DEBUG(" LArBarrelCalculator: Birks' law ON "); + ATH_MSG_DEBUG(" LArBarrelCalculator: parameter k " << m_birksLaw->k()); + } + else + { + ATH_MSG_DEBUG(" LArBarrelCalculator: Birks' law OFF"); + } + + return StatusCode::SUCCESS; +} + +// ============================================================================ +StatusCode LArBarrelCalculator::finalize() +{ + if (m_BirksLaw) delete m_birksLaw; + return StatusCode::SUCCESS; +} + +// ============================================================================= +G4bool LArBarrelCalculator::Process(const G4Step* step, std::vector<LArHitData>& hdata) const +{ + + hdata.clear(); + + LArG4Identifier identifier2; + LArG4Identifier identifier_xt1; + LArG4Identifier identifier_xt2; + + // check the Step content is non trivial + G4double thisStepEnergyDeposit = step->GetTotalEnergyDeposit(); + G4double thisStepLength = step->GetStepLength() / Units::mm; + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("****** LArBarrelCalculator: Step energy,length " + << thisStepEnergyDeposit << " " << thisStepLength); +#endif + + if(thisStepEnergyDeposit <= 0. || thisStepLength <= 0.) + { +#ifdef DEBUGSTEP2 + ATH_MSG_DEBUG(" Invalid hit trivial content"); +#endif + return false; + } + + // Get Step geometrical parameters (first and end) + G4StepPoint *thisStepPoint = step->GetPreStepPoint(); + G4StepPoint *thisStepBackPoint = step->GetPostStepPoint(); + G4ThreeVector startPoint = thisStepPoint->GetPosition(); + G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Beginning step position " + << startPoint.x() << " " << startPoint.y() << " " << startPoint.z()); +#endif + + // find zside from volume name + G4int zSide = 1; + if (!m_testbeam) { + const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); + G4int ndep = g4navigation->GetDepth(); + for (G4int ii=0;ii<=ndep;ii++) { + G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); + G4String vname = v1->GetName(); + if ( vname.find("NegPhysical") != std::string::npos) zSide=-1; + } + } + + + // BACK directly into the LOCAL half_Barrel Z > 0. PART (mother "stac_phys1") + + const G4AffineTransform transformation = + thisStepPoint->GetTouchable()->GetHistory()->GetTopTransform(); + + G4ThreeVector startPointinLocal = + transformation.TransformPoint(startPoint); + G4ThreeVector endPointinLocal = + transformation.TransformPoint (endPoint); + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Local beginning step position " + << startPointinLocal.x() << " " << startPointinLocal.y() << " " + << startPointinLocal.z()); + ATH_MSG_DEBUG(" Local end step position " + << endPointinLocal.x() << " " << endPointinLocal.y() << " " + << endPointinLocal.z()); +#endif + + G4double energy = step->GetTotalEnergyDeposit(); // Despite the name, this is only ionization. + + if (m_BirksLaw) { + const double EField = 10.; // kV/cm, assume constant for now + const double wholeStepLengthCm = step->GetStepLength() / CLHEP::cm; + energy = (*m_birksLaw)(energy, wholeStepLengthCm, EField); + } + + + // compute number of sub steps + // = 1 if no charge collection + // otherwise 200 microns (dstep) division + + G4int nsub_step=1; + if (m_IflCur) nsub_step=(int) (thisStepLength/m_dstep) + 1; + // delta is fraction of step between two sub steps + G4double delta=1./((double) nsub_step); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" nsub_step,delta " << nsub_step << " " << delta); +#endif + + energy /= ((float) (nsub_step)); // Divide into substeps. + + // loop over sub steps + + for (G4int i=0;i<nsub_step;i++) { + + bool Xtalk = false; + + G4double fraction=(((G4double) i)+0.5)*delta; + G4ThreeVector subinLocal=startPointinLocal*(1-fraction) + endPointinLocal*fraction; + G4double xloc = subinLocal.x(); + G4double yloc = subinLocal.y(); + G4double zloc = subinLocal.z(); + G4double etaloc = subinLocal.pseudoRapidity(); + G4double philoc = subinLocal.phi(); + if(philoc<0.) philoc = philoc + 2.*M_PI; + G4double radloc = sqrt( xloc*xloc + yloc*yloc ); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" local position sub_step " + << xloc << " " << yloc << " " << zloc); +#endif + + // apply fiducial cuts + if (!FiducialCuts(radloc,zloc,etaloc)) { +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("LArBarrelCalculator: outside fiducial cuts"); +#endif + continue; + } + LArG4::Barrel::CalcData currentCellData; + m_geometry->findCell(currentCellData,xloc,yloc,zloc,radloc,etaloc,philoc,m_IflCur); + + if (currentCellData.cellID == 0) + { +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("LArBarrelCalculator: Invalid hit CELLID == 0 "); + ATH_MSG_DEBUG("x,y,z local " << xloc << " " << yloc << " " << zloc); + ATH_MSG_DEBUG("radius " << radloc <<" etaloc "<< etaloc << " philoc " << philoc); +#endif + continue; + } + G4int region = currentCellData.region; + G4int etaBin = currentCellData.etaBin; + G4int phiBin = currentCellData.phiBin; + G4int sampling = currentCellData.sampling; + + if( zSide == -1 ) + { + // following code for an Y-axis rotation to define Z < 0. Barrel part + if( sampling == 1 && region ==0 ) + { + phiBin = 31 - phiBin; + if(phiBin < 0 ) phiBin += 64; + } + if( sampling == 1 && region ==1 ) + { + phiBin = 127 - phiBin; + if(phiBin < 0 ) phiBin += 256; + } + if( sampling >= 2 ) + { + phiBin = 127 - phiBin; + if(phiBin < 0 ) phiBin += 256; + } + } +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" region,side,sampling,eta,phi " << region << " " << zSide << " " + << sampling << " " << etaBin << " " << phiBin); + ATH_MSG_DEBUG(" distance to electrode,abs " << currentCellData.distElec << " " + << currentCellData.distAbs); + ATH_MSG_DEBUG(" local coordinates " << currentCellData.x0 << " " << currentCellData.y0); +#endif + + if (std::fabs(currentCellData.distElec)< m_ThickEle || + std::fabs(currentCellData.distAbs) < m_ThickAbs) { +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" hit in absorber or electrode radius:" << radloc); +#endif + continue; + } + + identifier2.clear(); + identifier2 << 4 // LArCalorimeter + << 1 // LArEM + << zSide + << sampling + << region + << etaBin + << phiBin; + + // time computation is not necessarily correct for test beam + // G4double time; + // if (m_testbeam) + // { + // time=0.; + // } + // else + // { + // const G4double tof = thisStepPoint->GetGlobalTime() / Units::ns; + // time = tof - ( thisStepPoint->GetPosition().mag()/CLHEP::c_light ) / Units::ns; + // } + + const G4double time = (m_testbeam)? 0.0 : + ( thisStepPoint->GetGlobalTime() - ( thisStepPoint->GetPosition().mag()/CLHEP::c_light ) ) / Units::ns; + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Energy for sub step " << energy); +#endif + + G4double Current; + G4double Current_xt1,Current_xt2; + Current_xt1=0; + Current_xt2=0; + if (!m_IflCur) { + // no charge collection Current=E from Geant + Current=energy; + } + else { + // full charge collection + G4double xmap,ymap; + G4int nfold = currentCellData.nfold; + G4double x0=currentCellData.x0; + G4double y0=currentCellData.y0; + if (x0<1500 || x0>1960 || y0>30 || y0<-30) { + ATH_MSG_INFO("weird x0,y0 " << x0 << " " << y0); + } +#ifdef DEBUGSTEP + G4double rr = sqrt(x0*x0+y0*y0); + ATH_MSG_DEBUG(" radius,rad0 " << radloc << " " << rr); +#endif + CurrMap* mapOfCurrent(nullptr); + bool UseFold=false; + // Are we close to a fold ? (fold 0 has some pathology) + if ((x0 > m_accmap->GetXmin(nfold) || nfold==0) && + x0 < m_accmap->GetXmax(nfold) && + y0 > m_accmap->GetYmin(nfold) && + y0 < m_accmap->GetYmax(nfold) && + (nfold != 13 || x0 < 1957.5) && + (nfold>0 || x0 < 1504.6) ) { + xmap=x0; + ymap=y0; +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Map for fold xmap,ymap " << nfold << " " << xmap << " " << ymap); +#endif + UseFold=true; + G4int sampMap = currentCellData.sampMap; + G4int etaMap = currentCellData.etaMap; + mapOfCurrent = m_accmap->GetMap(nfold,region,sampMap,etaMap); + // catch problem to find map + if (!mapOfCurrent) { + ATH_MSG_WARNING(" Problem to access map fold = " << nfold); + ATH_MSG_WARNING(" region,sampling,eta,fold " << region << " " << sampMap << " " + << etaMap << " " << nfold); + return false; + } + } + else { + G4int n; + G4int nstraight = currentCellData.nstraight; + if (nstraight%2==0) n=22; + else n=21; + mapOfCurrent = m_accmap->GetMap(n,region,sampling,etaBin); + // catch problem to find map + if (!mapOfCurrent) { + ATH_MSG_WARNING(" Problem to access map straight = " << nstraight); + return false; + } + xmap = currentCellData.xl; + ymap = currentCellData.distElec; + // special case for first straight section, which is shorter + if (nstraight==0) xmap = 0.5*(xmap+1.); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Map for straight xl,delec " << xmap << " " << ymap); +#endif + } // fold or straight + double gap; + double current0,current1,current2; + // get current for elementary charge + mapOfCurrent->GetAll(xmap,ymap,&gap,¤t0,¤t1,¤t2); + G4double gap2=std::fabs(currentCellData.distElec)+std::fabs(currentCellData.distAbs) + -m_ThickEle-m_ThickAbs; + + // in which HV cell are we ? + int ipm,ielec,ieta,iside; + if (zSide==1) ipm=1; // A side + else ipm=0; // C side + ielec=currentCellData.phiGap; + if (zSide==-1) { + ielec = 511 - ielec; + if(ielec < 0 ) ielec += 1024; + } + ieta=((int) (etaloc*(1./0.2))); + if (ieta>6) ieta=6; //part 1.4 to 1.475 is same HV as 1.2 to 1.4 + iside=0; // phi lower than electrode 0, 1 for phi higher than electrode + if ((currentCellData.distElec>0 && zSide==1) + || (currentCellData.distElec<0 && zSide==-1) ) iside=1; + + // HV extrapolation + double current; + double hv=m_hv[ipm][ielec][ieta][iside]; + // std::cout << " etaBin,phiBin " << etaBin << " " << phiBin << std::endl; + // std::cout << " ipm,ielec,ieta,iside " << ipm << " " << ielec << " " << ieta + // << " " << iside << std::endl; + // std::cout << " hv " << hv << std::endl; + // std::cout << " current0,current1,current2 " << current0 << " " << current1 + // << " " << current2 << std::endl; + if (hv>1995.) current=current0; + else if (hv>5.) current=ScaleHV(hv,current0,current1,current2); + else current=0.; + // std::cout << " current " << current << std::endl; + + // extrapolation for non nominal gap (allows to include sagging effect) + // i ~ (gap/gap2)**1.3 + // gap = nominal gap from current map + // gap2 = real gap from geometry + // dgap = gap/gap2 -1 + // at first order i ~ (1+1.3*dgap) + double dgap=0; + if (gap>1e-3 && gap2 >1e-3) dgap=gap/gap2-1; + current = current * (1. + 1.3*dgap); + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" elementary current " << current0); + ATH_MSG_DEBUG(" Gap from Map/calculator " << gap << " " << gap2); +#endif + + Current = energy*current; + + // check if pathology... + if (!UseFold && std::fabs(currentCellData.distElec)>2.1 && current0 < 0.1) { + ATH_MSG_WARNING(" xl,distEle " << currentCellData.xl << " " + << currentCellData.distElec + << " str number " << currentCellData.nstraight + << " sampling,eta " << sampling << " " << etaBin << " " + << " current/E " << current0); + } + + // compute effect around transition at eta=0.8 from electric field + // read from map weighting factor ( E**1.3 = E*E**0.3) + // in x +-9mm around transition (assume symmetry around 0) + // in y distance from electrode in gap + bool InTrans=false; + //double Current_test=Current; + if (m_IflMapTrans) { + float etaTrans=0.8; + if (fabs(etaloc-etaTrans) < 0.025) { + double x=std::fabs(zloc-radloc*sinh(etaTrans))/cosh(etaTrans); + double y=std::fabs(currentCellData.distElec); + if ( x < m_etamap3->Xmax() ) { + double resp; + m_etamap3->GetData0(x,y,&resp); + Current = Current*resp; + InTrans=true; + } + } // eta = 0.8 +- 0.025 + } // if m_IflMapTrans + + // simulate cross-talk effects and transitions in eta between cells + // (only in region 0, samplings 1 and 2) + + if (region==0) { + + double resp,xt0,xt1,xt2,deta; + if (sampling==1) { + deta=etaloc-0.003125*((double)etaBin+0.5); + m_etamap1->GetData(std::fabs(deta),std::fabs(currentCellData.distElec), + &resp,&xt0,&xt1,&xt2); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("hit in strip etaloc,etaBin,deta,delec,resp,xt0,xt1,xt2 " + << etaloc << " " << etaBin << " " << deta*1000 << " " << currentCellData.distElec + << " " << resp << " " << xt0 << " " << xt1 << " " << xt2); +#endif + if (!InTrans) Current = Current*resp; + if (m_IflXtalk && etaBin > 1 && etaBin < 446) { + Xtalk=true; + if (deta>0) { + identifier_xt1.clear(); + identifier_xt1 << 4 << 1 << zSide << sampling << region << (etaBin+1) << phiBin; + Current_xt1 = Current*xt1; + identifier_xt2.clear(); + identifier_xt2 << 4 << 1 << zSide << sampling << region << (etaBin-1) << phiBin; + Current_xt2 = Current*xt2; + } + else { + identifier_xt1.clear(); + identifier_xt1 << 4 << 1 << zSide << sampling << region << (etaBin-1) << phiBin; + Current_xt1 = Current*xt1; + identifier_xt2.clear(); + identifier_xt2 << 4 << 1 << zSide << sampling << region << (etaBin+1) << phiBin; + Current_xt2 = Current*xt2; + } + Current = Current*xt0; + } // m_IflXtalk = true + } + else if (sampling==2 && !InTrans) { + deta=etaloc-0.025*((double)etaBin+0.5); + m_etamap2->GetData0(std::fabs(deta),std::fabs(currentCellData.distElec), + &resp); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("hit in middle etaloc,etaBin,deta,delec,resp,xt0,xt1,xt2 " + << etaloc << " " << etaBin << " " << deta*1000 << " " << currentCellData.distElec + << " " << resp); +#endif + Current = Current*resp; + } // sampling =1 or 2 + + } // region=0 + + } // switch for current simulation + + + // check if we have a new hit in a different cell, or if we add this substep + // to an already existing hit + G4bool found=false; + for (unsigned int i=0; i<hdata.size(); i++) { + if (hdata[i].id==identifier2) { + hdata[i].energy += Current; + hdata[i].time += time*Current; + found=true; + break; + } + } // loop over hits + if (!found) { + LArHitData newdata = {identifier2, time*Current, Current}; + hdata.push_back(newdata); + } // hit was not existing before + + if (Xtalk) { + for (unsigned int i=0; i<hdata.size(); i++) { + if (hdata[i].id==identifier_xt1) { + hdata[i].energy += Current_xt1; + hdata[i].time += time*Current_xt1; + found=true; + break; + } + } // loop over hits + if (!found) { + LArHitData newdata = {identifier_xt1, time*Current_xt1, Current_xt1}; + hdata.push_back(newdata); + } + found=false; + for (unsigned int i=0; i<hdata.size(); i++) { + if (hdata[i].id==identifier_xt2) { + hdata[i].energy += Current_xt2; + hdata[i].time += time*Current_xt2; + found=true; + break; + } + } // loop over hits + if (!found) { + LArHitData newdata = {identifier_xt2, time*Current_xt2, Current_xt2}; + hdata.push_back(newdata); + } + } // Xtalk true + + + } // *** End of loop over sub steps + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("Number of hits for this step " << m_nhits << " " + << hdata.size()); +#endif + + // finalise time computations + for (unsigned int i=0;i<hdata.size();i++) { + if (std::fabs(hdata[i].energy)>1e-6) hdata[i].time=hdata[i].time/hdata[i].energy; + else hdata[i].time=0.; +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("Hit Energy/Time " + << hdata[i].energy << " " << hdata[i].time); +#endif + } + + if (hdata.size()>0) return true; + return false; +} + +// =============================================================================== +// Cuts to define active region of accordion calorimeter +// 1500.024 < r < 1960.00 mm +// |eta| < 1.475 +// 4 < z < 3164 mm (in local half barrel coordinates) + +G4bool LArBarrelCalculator::FiducialCuts(G4double radloc,G4double zloc,G4double etaloc) const +{ + if (radloc < m_rMinAccordion || + radloc > m_rMaxAccordion || + etaloc > m_etaMaxBarrel || + zloc < m_zMinBarrel || + zloc > m_zMaxBarrel) return false; + else return true; +} + +// ========================================================================== +// HV values +// set all to 2000V. This should be changed if one wants to simulate +// some HV imperfections +void LArBarrelCalculator::InitHV() +{ + ATH_MSG_INFO(" **** in LArBarrelCalculator::InitHV() "); + + + + + float defaultHvVal=2000.; + ATH_MSG_INFO(" defaultHvVal " << defaultHvVal); + for (int ipm=0;ipm<2;ipm++) { + for (int ielec=0;ielec<1024;ielec++) { + for (int ieta=0;ieta<7;ieta++) { + for (int iside=0;iside<2;iside++) { + m_hv[ipm][ielec][ieta][iside] = defaultHvVal; + } + } + } + } + + if (m_doHV) { + // initialize services + ISvcLocator* svcLocator = Gaudi::svcLocator(); + StoreGateSvc* pDetStore = nullptr; + + if(svcLocator->service("DetectorStore", pDetStore).isFailure()) + { + std::cout << "LArBarrelCalculator::InitHV() unable to get Detector Store! Use default HV values\n"; + return; + } + + // get EMBHV Manager + const LArHVManager *manager = nullptr; + if (pDetStore->retrieve(manager)==StatusCode::SUCCESS) { + const EMBHVManager* hvManager=manager->getEMBHVManager(); + ATH_MSG_INFO(" got HV Manager "); + // loop over HV modules + for (unsigned int iSide=0;iSide<2;iSide++) { + for (unsigned int iPhi=0;iPhi<16;iPhi++) { + for (unsigned int iSector=0;iSector<2;iSector++) { + for (unsigned int iEta=0;iEta<7;iEta++) { + EMBHVModuleConstLink hvMod = hvManager->getHVModule(iSide,iEta+1,iPhi,iSector); + for (unsigned int ielec=0;ielec<32;ielec++) { + EMBHVElectrodeConstLink electrode = hvMod->getElectrode(ielec); + unsigned jElec = ielec+32*iSector+64*iPhi; + for (unsigned int iGap=0;iGap<2;iGap++) { + double hv = electrode->voltage(iGap); + ATH_MSG_DEBUG(" iSide,jElec,iEta,iGap,hv " << iSide << " " << jElec << " " << iEta << " " << iGap << " " << hv); + if (hv>-999.) m_hv[iSide][jElec][iEta][iGap] = hv; + } + } + } + } + } + } + } + else { + ATH_MSG_WARNING(" Unable to find HV Manager "); + } + } + + return; +} + +//========================================================================== +// extrapolate response with HV +// hv = actual HV +// curr0 = response for 2000V, curr1 = for 1000V, curr2 for 400V +// assumes resp = a* HV*b between 1000-2000 and 400-1000V +// (fixes b=0.57 for HV smaller than 400V) + +double LArBarrelCalculator::ScaleHV(double hv, double curr0, double curr1, double curr2) const +{ + double b; + double resp=0.; + if (hv>1000.) { + if (std::fabs(curr1)>1e-6) { + double x=curr0/curr1; + if (x>1e-6) { + b=log(x)*(1./(log(2000.)-log(1000.))); + resp = curr0*exp(b*(log(hv)-log(2000.))); + } + } + } + else if (hv>400.) { + if (std::fabs(curr2)>1e-6) { + double x=curr1/curr2; + if (x>1e-6) { + b=log(x)*(1./(log(1000.)-log(400.))); + resp = curr1*exp(b*(log(hv)-log(1000.))); + } + } + } + else { + if (std::fabs(curr2)>1e-6) { + b=0.57; + resp = curr2*exp(b*(log(hv)-log(400.))); + } + } + return resp; +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.h new file mode 100644 index 000000000000..de1ebd7e8a15 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalculator.h @@ -0,0 +1,106 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArBarrelCalculator.hh +// The Cell Identifier for the EM Barrel readout cells + +// Adapted from code written by Gaston Parrour +// Adaptation by Sylvain Negroni + +// 12-Jul-2002 WGS: Added LArG4Identifier. + +// 18-03-2005 G.Unal: major revision to include new current maps +#ifndef LARBARRELCALCULATOR_H +#define LARBARRELCALCULATOR_H + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include "ILArBarrelGeometry.h" + +#include <stdexcept> +#include <vector> +#include <string> +#include <memory> + +class G4Step; +class AccMap; +class MapEta; +class LArG4BirksLaw; + +class LArBarrelCalculator : public LArCalculatorSvcImp +{ +public: + + LArBarrelCalculator(const std::string& name, ISvcLocator* pSvcLocator); + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + + LArBarrelCalculator (const LArBarrelCalculator&) = delete; + LArBarrelCalculator& operator= (const LArBarrelCalculator&) = delete; + + virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const override final; + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(std::fabs(hitTime) > m_OOTcut); + } + + // + // get functions: + // + virtual G4float OOTcut() const override final { return m_OOTcut; } + +private: + + ServiceHandle<ILArBarrelGeometry> m_geometry; + AccMap* m_accmap; + std::unique_ptr<MapEta> m_etamap1; + std::unique_ptr<MapEta> m_etamap2; + std::unique_ptr<MapEta> m_etamap3; + + // RUN Options + bool m_IflCur; + bool m_IflMapTrans; + bool m_IflXtalk; + + double m_dstep; + + const LArG4BirksLaw *m_birksLaw; + bool m_doHV; + + // global EMBarrel dimensions + double m_etaMaxBarrel; + double m_zMinBarrel; + double m_zMaxBarrel; + // global Accordion dimensions + double m_rMinAccordion; + double m_rMaxAccordion; + // half thickness of absorber and electrode + double m_ThickAbs; + double m_ThickEle; + // GU 11/06/2003 total number of cells in phi + int m_NCellTot; + int m_NCellMax; + // to handle small difference (mostly phi wrapping and +-z symmetry) + // between atlas and test beam + bool m_testbeam; + + + // Hv values + // 0,1 = positive/negative barrel + // 0->1023 = electrode number + // 0->6 = eta region number (0.2 granularity) (1.2 to 1.475 in same eta bin) + // 0,1 = below, above the electrode (according to phi in global Atlas frame) + + double m_hv[2][1024][7][2]; + + G4bool FiducialCuts(G4double,G4double,G4double) const; + + void InitHV(); + double ScaleHV(double, double, double, double) const; + +}; + +#endif // LARBARRELCALCULATOR_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cc deleted file mode 100644 index cd398907b086..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -/******************************************************************** - -NAME: CalibrationCalculator.cxx -PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel - -AUTHORS: G. Unal, L. Carminati (on a template from Bill Selingman) -CREATED: September, 2004 - -PURPOSE: This class calculates the values needed for calibration hits - in the barrel LAr calorimeter. This calculator is called - in calibration runs (see LArBarrelSDConsultant) for calibration - hits in the accordion (no presampler). - -UPDATES: - -********************************************************************/ - -//#define DEBUG_HITS - -#include "LArG4Barrel/LArBarrelCalibrationCalculator.h" - -#include "LArG4Barrel/LArBarrelGeometry.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" -#include <algorithm> - -namespace LArG4 { - -namespace Barrel { - - CalibrationCalculator::CalibrationCalculator() - : m_detectorName("LArMgr") - { - // Initialize the geometry calculator. - m_geometryCalculator = Geometry::GetInstance(); - } - - CalibrationCalculator::~CalibrationCalculator() - { - } - - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { -#ifdef DEBUG_HITS - std::cout << "LArG4::Barrel::CalibrationCalculator::Process" - << " calling SimulationEnergies" << std::endl; -#endif - m_energyCalculator.Energies( a_step, m_energies ); - - // First, get the energy. - // m_energy = a_step->GetTotalEnergyDeposit(); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - m_identifier = m_geometryCalculator->CalculateIdentifier( a_step, m_detectorName ); - } - else - m_identifier = LArG4Identifier(); - - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::Barrel::CalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - -} // namespace Barrel - -} // namespace LAr diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cxx new file mode 100644 index 000000000000..8ddca11f58e1 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.cxx @@ -0,0 +1,107 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: CalibrationCalculator.cxx +PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel + +AUTHORS: G. Unal, L. Carminati (on a template from Bill Selingman) +CREATED: September, 2004 + +PURPOSE: This class calculates the values needed for calibration hits + in the barrel LAr calorimeter. This calculator is called + in calibration runs (see LArBarrelSDConsultant) for calibration + hits in the accordion (no presampler). + +UPDATES: + +********************************************************************/ + +//#define DEBUG_HITS + +#include "LArBarrelCalibrationCalculator.h" + +#include "LArG4Code/LArG4Identifier.h" + +#include "G4Step.hh" +#include "globals.hh" +#include <algorithm> + +namespace LArG4 { + + namespace Barrel { + + CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_geometryCalculator("LArBarrelGeometry", name) + { + declareProperty("GeometryCalculator", m_geometryCalculator); + } + + StatusCode CalibrationCalculator::initialize() { + // Initialize the geometry calculator. + ATH_CHECK(m_geometryCalculator.retrieve()); + return StatusCode::SUCCESS; + } + + CalibrationCalculator::~CalibrationCalculator() + { + } + + + G4bool CalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { +#ifdef DEBUG_HITS + std::cout << "LArG4::Barrel::CalibrationCalculator::Process" + << " calling SimulationEnergies" << std::endl; +#endif + m_energyCalculator.Energies( step, energies ); + + // First, get the energy. + // m_energy = step->GetTotalEnergyDeposit(); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + identifier = m_geometryCalculator->CalculateIdentifier( step ); + } + else + identifier = LArG4Identifier(); + + +#ifdef DEBUG_HITS + G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "LArG4::Barrel::CalibrationCalculator::Process" + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; +#endif + + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; + + return true; + } + + } // namespace Barrel + +} // namespace LAr diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.h similarity index 59% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.h index d9f30492fa28..346c6dd84cce 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/LArBarrelCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelCalibrationCalculator.h @@ -2,7 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -// LArG4::Barrel::CalibrationCalculator +// LArG4::Barrel::CalibrationCalculator // This class calculates the values needed for calibration hits in the // simulation. @@ -10,8 +10,9 @@ #ifndef LArG4_Barrel_CalibrationCalculator_H #define LArG4_Barrel_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" +#include "ILArBarrelGeometry.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -30,18 +31,16 @@ class G4Step; namespace LArG4 { - -namespace Barrel { - - // Forward declaration - class Geometry; - - class CalibrationCalculator : public VCalibrationCalculator { + + namespace Barrel { + + class CalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationCalculator(); + + CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -53,29 +52,17 @@ namespace Barrel { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } ; - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; }; - - inline void detectorName(std::string name) { m_detectorName=name; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; // Geometry calculator - Geometry* m_geometryCalculator; + ServiceHandle<ILArBarrelGeometry> m_geometryCalculator; // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; - - // detector name, for translated geometry - std::string m_detectorName; }; } // namespace Barrel diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cc deleted file mode 100644 index 5e0eae5271e8..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cc +++ /dev/null @@ -1,1402 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -/******************************************************************** - -NAME: LArBarrelGeometry.cxx -PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel - -AUTHORS: G. Unal, L. Carminati -CREATED: September, 2004 - -PURPOSE: 'geometrical' methods used by the LArBarrelCalculator. - These methods (previously in LArBarrelCalculator) were written - by Gaston Parrour and adapted by Sylvain Negroni. - -UPDATES: - Calculate identifier method used by CalibrationCalculator. - (sept 2004) - - Cleanup (GU March-April 2005) - -********************************************************************/ - -// #define DEBUGHITS - -#include <cmath> -#include <iostream> -#include "LArG4Barrel/LArBarrelGeometry.h" - -#include "LArG4Barrel/LArStraightAbsorbers.h" -#include "LArG4Barrel/LArStraightElectrodes.h" -#include "LArG4Barrel/LArCoudeElectrodes.h" -#include "LArG4Barrel/LArCoudeAbsorbers.h" - -namespace LArG4 { - -namespace Barrel { - -Geometry* Geometry::m_instance = 0; - -// =================================================================== - -Geometry* Geometry::GetInstance() -{ - if (m_instance == 0) - { - m_instance = new Geometry(); - } - return m_instance; -} - -// ========================================================================== -Geometry::Geometry() - : m_testbeam(false), - m_cellID(0), m_sampling(0), m_region(0), m_etaBin(0), m_phiBin(0), m_zSide(0), m_phiGap(0), m_nstraight(0), m_nfold(0), m_distElec(0), m_distAbs(0), m_xl(0), m_x0(0), m_y0(0), m_sampMap(0), m_etaMap(0), - m_iflSAG(false) -{ -// Constructor initializes the geometry. -// Access source of detector parameters. - - LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); - -// number of straight sections (should be 14) - m_Nbrt = (int) (parameters->GetValue("LArEMBnoOFAccZigs")); -// Number of ZIGs + 1 i.e. 15 = number of folds - m_Nbrt1 = m_Nbrt + 1; -// phi of first absorber - m_gam0 = parameters->GetValue("LArEMBAbsPhiFirst"); -// radius of curvature of neutral fiber in the folds - m_rint_eleFib = parameters->GetValue("LArEMBNeutFiberRadius"); - - m_rc = new double[m_Nbrt1]; - m_phic = new double[m_Nbrt1]; - m_delta = new double[m_Nbrt1]; - m_xc = new double[m_Nbrt1]; - m_yc = new double[m_Nbrt1]; - -// r,phi positions of the centre of the folds (nominal geometry) - for (G4int idat = 0; idat < m_Nbrt1 ; idat++) - { - m_rc[idat] = (double) parameters->GetValue("LArEMBRadiusAtCurvature",idat); - m_phic[idat] = (double) parameters->GetValue("LArEMBPhiAtCurvature",idat); - m_delta[idat] = (double) parameters->GetValue("LArEMBDeltaZigAngle",idat); - m_xc[idat] = m_rc[idat]*cos(m_phic[idat]); - m_yc[idat] = m_rc[idat]*sin(m_phic[idat]); - } - // define parity of accordion waves: =0 if first wave goes up, 1 if first wave goes down in the local frame - m_parity=0; - if (m_phic[0]<0.) m_parity=1; -// - m_rMinAccordion = parameters->GetValue("LArEMBRadiusInnerAccordion"); - m_rMaxAccordion = parameters->GetValue("LArEMBFiducialRmax"); - m_etaMaxBarrel = parameters->GetValue("LArEMBMaxEtaAcceptance"); - m_zMinBarrel = parameters->GetValue("LArEMBfiducialMothZmin"); - m_zMaxBarrel = parameters->GetValue("LArEMBfiducialMothZmax"); -// === GU 11/06/2003 total number of cells in phi -// to distinguish 1 module (testbeam case) from full Atlas - m_NCellTot = (int) (parameters->GetValue("LArEMBnoOFPhysPhiCell")); - m_NCellMax=1024; -// === - -// Initialize r-phi reference map - GetRphi(); - - m_FIRST = true; - m_coudeabs=NULL; - m_absorber=NULL; - m_coudeelec=NULL; - m_electrode=NULL; - -} - -// ==================================================================================== - -Geometry::~Geometry() { - - if (m_rc) delete [] m_rc; - if (m_phic) delete [] m_phic; - if (m_delta) delete [] m_delta; - if (m_xc) delete [] m_xc; - if (m_yc) delete [] m_yc; - -} - - -//====================================================================================== -// -// Here INTRINSIC Distance_to_electrode determination (G.P.) -// -// This retuns an ALGEBRICDistEle value, the distance from electrode -//neutral fiber TOWARDS the Sub_Step in LAr (measured on a local perpendicular -//vector unit oriented upwards i.e. following increasing Phi values). -// -// This is done in THE INTRINSIC LOCAL Z > 0. half_barrel part ("stac_phys1") -// -// inputs: xhit,yhit = x,y positions in local half barrel -// PhiCell = electrode number in phi (0 to 1023 for Atlas case) -// Num_Straight = number (0 to 13) of the straight section -// Num_Coude = number (0 to 14) of closest fold -// -// output: Function value = algebric distance to electrode -// xl = normalized lenght along electrode straight section (between +-1) - -double Geometry::Distance_Ele(const double & xhit, - const double &yhit, const int &PhiCell, int &Num_Straight, - const int &Num_Coude, double &xl) -{ - double dx, dy, dr; - double DistEle = 0.; -// -// FrameWork is consistent with the one used to PhiCell determination -// e.g. it assumes HERE to be the LOCAL one of "stac_phys1", -// (mother of ACCordion volumes) from which Z> 0. and Z < 0. half_barrel -// parts are then defined. -// -// One needs POINTERS to Electrode neutral fibers -// either for straight parts or for folds -// -// Fold Center ccoordinates - G4double Xc[2]; - Xc[0] = m_coudeelec->XCentCoude(Num_Coude, PhiCell); - Xc[1] = m_coudeelec->YCentCoude(Num_Coude, PhiCell); - G4double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]); - G4double radhit = sqrt(xhit*xhit+yhit*yhit); - -// check if the assumed straight number is the correct one -// (this can be wrong when we are close to a fold and there is sagging) - if (Num_Coude == Num_Straight && radhit <radfold) { - if (Num_Straight>0) Num_Straight = Num_Straight-1; -// std::cout << "radhit,radfold " << radhit << " " << radfold << " change straight by +1" << std::endl; - } - if (Num_Coude == (Num_Straight+1) && radhit > radfold) { - if (Num_Straight<12) Num_Straight = Num_Straight+1; -// std::cout << "radhit,radfold " << radhit << " " << radfold << " change straight by -1" << std::endl; - } - -// u unit 2D_Vector along straight part of the electrode neutral fiber - double u[2]; - u[0] = m_electrode->Cosu(Num_Straight, PhiCell); - u[1] = m_electrode->Sinu(Num_Straight, PhiCell); -// Middle m_coordinates of this straight part of the electrode neutral fiber - double Xm[2]; - Xm[0] = m_electrode->XCentEle(Num_Straight, PhiCell); - Xm[1] = m_electrode->YCentEle(Num_Straight, PhiCell); -// m_Hit Vector components - dx = xhit - Xm[0]; dy = yhit - Xm[1]; - -// First compute algebric distance m_hit (2D) the 2D_projection of the -// m_Hit Vector on this electrode neutral fiber. - double hit = dx*u[0] + dy*u[1]; - -// -// Flat of Fold Region ? -// - G4double Half_Elec; - Half_Elec = m_electrode->HalfLength(Num_Straight,PhiCell); - - if(fabs(hit) < Half_Elec) { -// Flat Region - DistEle = u[0]*dy - u[1]*dx; - xl=hit/Half_Elec; - } - else { -// Fold region -// c_Hit Vector components and its length - dx = xhit - Xc[0]; dy = yhit - Xc[1]; dr = sqrt( dx*dx + dy*dy); - DistEle = (Num_Coude%2 == m_parity) ? (m_rint_eleFib-dr) : (dr - m_rint_eleFib); - if (Num_Coude==Num_Straight) xl=-1.; - else xl=+1; - } // end of Fold Regions - - return DistEle; - -} // end of the function Distance_Ele - - -//====================================================================================== -// Algebric distance to absorber -// -// inputs: xhit,yhit = x,y positions in local half barrel -// PhiCell = absorber number in phi (0 to 1023 for Atlas case) -// Num_Straight = number (0 to 13) of the straight section -// Num_Coude = number (0 to 14) of closest fold -// -// output: Function value = algebric distance to electrode - -double Geometry::Distance_Abs(const double & xhit, - const double &yhit, const int &PhiCell, const int &Num_Straight, - const int &Num_Coude) -{ - double dx, dy, dr; - double DistAbs = 0.; -// -// FrameWork is consistent with the one used to PhiCell determination -// e.g. it assumes HERE to be the LOCAL one of "stac_phys1", -// (mother of ACCordion volumes) from which Z> 0. and Z < 0. half_barrel -// parts are then defined. -// -// One needs POINTERS to Electrode neutral fibers -// either for straight parts or for folds -// -// u unit 2D_Vector along straight part of the electrode neutral fiber - G4double u[2]; - u[0] = m_absorber->Cosu(Num_Straight, PhiCell); - u[1] = m_absorber->Sinu(Num_Straight, PhiCell); -// Middle m_coordinates of this straight part of the electrode neutral fiber - G4double Xm[2]; - Xm[0] = m_absorber->XCentAbs(Num_Straight, PhiCell); - Xm[1] = m_absorber->YCentAbs(Num_Straight, PhiCell); -// m_Hit Vector components - dx = xhit - Xm[0]; dy = yhit - Xm[1]; - -// First compute algebric distance hit (2D) the 2D_projection of the -// m_Hit Vector on this electrode neutral fiber. - double hit = dx*u[0] + dy*u[1]; - -// -// Flat of Fold Region ? -// - G4double Half_Abs; - Half_Abs = m_absorber->HalfLength(Num_Straight,PhiCell); - - if(fabs(hit) < Half_Abs) { -// Flat Region - DistAbs = u[0]*dy - u[1]*dx; - } - else { -// Fold Center c_coordinates - G4double Xc[2]; - Xc[0] = m_coudeabs->XCentCoude(Num_Coude, PhiCell); - Xc[1] = m_coudeabs->YCentCoude(Num_Coude, PhiCell); -// c_Hit Vector components and its length - dx = xhit - Xc[0]; dy = yhit - Xc[1]; dr = sqrt( dx*dx + dy*dy); - DistAbs = (Num_Coude%2 == m_parity) ? (m_rint_eleFib-dr) : (dr - m_rint_eleFib); - - } // end of Fold Regions - - return DistAbs; - -} // end of the function Distance_Abs - - -//============================================================================= -// Function SampSeg -// -// eta-sampling segmentation of barrel calorimeter GU, January 2005 -// input values: eta,radius in half-barrel frame -// -// return value of function: true=active area, false=inactive area -// return arguments: iregion,isampling,ieta -// take into account detailed electrode drawing -// with readout strips -// isamp2,ieta2 do not take into account -// readout strips and can be used to access current -// maps. -// -// iregion=0 (eta<1.4) or 1 (eta=1.4-1.475) -// for region 0: isampling = 1 (strips), 2 (middle), 3 (back) -// for region 1: isampling = 1 or isampling = 2 -// ieta= eta cell number -// region0,samp1: ieta=1->448 (strip 0 does not exist) -// region0,samp2: ieta=0->55 -// region0,samp3: ieta=0->26 (max eta 1.325) -// region1,samp1: ieta=0->2 (deta=0.025) -// region1,samp2: ieta=0 (only 1 cell) - -G4int Geometry::SampSeg(G4double eta, G4double radius, G4double z, - G4int& iregion, G4int& isampling, G4int& ieta, - G4int& isamp2, G4int& ieta2) -{ - static G4double Rmax1[448]; - static G4double Rmax2[56]; - static G4double Eta_max,Eta_max_s1,Eta_max_s3,R_max_acc,Z_max_acc,R_min_acc,R_min_highz; - static G4double Dr_s12; - static G4double deltaz,Z_max_lowr,dzdr; - static G4double deta; - static G4double zmax1,zmax2,zmax3,zmax4,zmax5,zmax6,zmax7,rmax1,rmax2,rmax3,rmax4; - static bool FILL = true; - if (FILL) { - - LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); - -// maximum eta barrel 1.475 (at r=1500.024) - Eta_max = parameters->GetValue("LArEMBMaxEtaAcceptance"); -// minimum active radius 1500.024 - R_min_acc= parameters->GetValue("LArEMBRadiusInnerAccordion"); -// maximum active radius 1960. - R_max_acc = parameters->GetValue("LArEMBFiducialRmax"); -// maximum active z (before subtracting edge for signal readout) -// currently 3150, should be changed in database to become 3164 - Z_max_acc = parameters->GetValue("LArEMBfiducialMothZmax"); -// minimum radius at z max for active region - R_min_highz=1548.; //FIXME should be taken from database - -// inactive thickness between S1 and S2 FIXME should be taken from database - Dr_s12=1.1; - - Eta_max_s1=1.4; // maximum eta region 0 - Eta_max_s3=1.325; // maximum eta for S3 in region 0 - deta=0.025; // basic granularity - -// values of the radial separations between samplings -#include "LArBarrelSampling.icc" - -// compute z edge taken by readout strips on the edge - - deltaz=7.; // this include copper 6mm + 2*0.5mm empty space on each side - - zmax1=Z_max_acc-deltaz; - zmax2=Z_max_acc-2.*deltaz; - zmax3=Z_max_acc-3.*deltaz; - zmax4=Z_max_acc-4.*deltaz; - zmax5=Z_max_acc-5.*deltaz; - zmax6=Z_max_acc-6.*deltaz; - zmax7=Z_max_acc-7.*deltaz; - rmax1=R_max_acc-deltaz; - rmax2=R_max_acc-2.*deltaz; - rmax3=R_max_acc-3.*deltaz; - rmax4=R_max_acc-4.*deltaz; - - -// maximum z at r=1500.024 - Z_max_lowr = sinh(Eta_max)*R_min_acc; -// slope of z vs r edge (which is not projective in eta...) - dzdr = (Z_max_acc-Z_max_lowr)/(R_min_highz-R_min_acc); - -// std::cout << "Initialization of SampSet " << std::endl; -// std::cout << " Rmin/Rmax " << R_min_acc << " " << R_max_acc << std::endl; -// std::cout << " Zmax/Zmax_lowR " << Z_max_acc << " " << Z_max_lowr << std::endl; -// std::cout << " Rmin_highz " << R_min_highz << std::endl; -// std::cout << " dzdr " << dzdr << std::endl; - - FILL=false; - }; - -// iactive = 1 if active region, 0 if region considered as inactive - G4int iactive = 1; - - G4double aeta=fabs(eta); - - G4double r12=-1.; - G4double r23=-1.; - - // Not used: G4double rmax=Z_max_acc/sinh(aeta); - - G4int istrip,imid; - -// eta < 1.4 - - if (aeta<Eta_max_s1) { - -// get radius for end of strips - istrip=(int) (aeta/deta*8.); - if (istrip<0 || istrip >=448) { - std::cout << " Problem aeta,istrip " << aeta << " " << istrip << std::endl; - return 0; - } - r12=Rmax1[istrip]; - -// get radius for end of middle - imid = (int) (aeta/deta); - if (imid <0 || imid >=56) { - std::cout << " Problem aeta,imid " << aeta << " " << imid << std::endl; - return 0; - } - r23=Rmax2[imid]; - - iregion=0; - -// strips - if (radius <= r12) { - isampling=1; - ieta=istrip; - if (ieta==0) iactive=0; - isamp2=1; - ieta2=istrip; - } - -// region between strips and middle => not active, same identifier as strips - else if (radius < (r12+Dr_s12)) { - isampling=1; - ieta=istrip; - iactive=0; - isamp2=1; - ieta2=istrip; - } - - else { - -// eta<1.325, we can be in the back - if (aeta<Eta_max_s3) { -// radius<r23 we are in the middle - if (radius <= r23) { - isampling=2; - ieta=imid; - isamp2=2; - ieta2=imid; - } -// for radius >r23 we have to take care of the readout strips at high z -// and attribute some of the energy to other cells - else { // radius>r23 - if (z>zmax1) { - isampling=2; - ieta=55; - } - else if (z>zmax2) { - isampling=2; - ieta=54; - } - else if (z>zmax3) { - isampling=2; - ieta=53; - } - else if (z>zmax4) { - isampling=3; - ieta=26; - } - else if (aeta<1.3 && z>zmax5) { - isampling=2; - ieta=52; - } - else if (aeta<1.3 && z>zmax6) { - isampling=2; - ieta=51; - } - else if (radius>rmax4 && z<zmax5 && aeta>1.2) { - if (radius>rmax1) { - isampling=2; - ieta=51; - } - else if(radius>rmax2) { - isampling=3; - ieta=25; - } - else if (radius>rmax3) { - if (z<zmax7) { - isampling=2; - ieta=50; - } - else { - isampling=3; - ieta=25; - } - } - else { - if (aeta<1.25) { - isampling=2; - ieta=49; - } - else { - isampling=3; - ieta=25; - } - } - } -// normal back cell - else { - isampling=3; - ieta=imid/2; - isamp2=3; - ieta2=ieta; - } - isamp2=3; - ieta2=imid/2; - } // end radius>r23 -// put into middle energy deposited along readout strips across the back - if (isampling==3 && z<zmax4 && (radius<rmax4 || aeta<1.2) ) { - double etastr; - if (imid%2==0) etastr=0.025*imid; - else etastr=0.025*(imid+1); - double delta=radius*(sinh(etastr)-sinh(aeta))/cosh(etastr); - double deltastr; - if (aeta<0.475) { deltastr=1.5;} - else if (aeta<0.80) { deltastr=2.75;} - else if (aeta<0.85) { deltastr=1.5;} - else if (aeta<1.1) { deltastr=2.75;} - else { deltastr=3.25;} - - if (std::fabs(delta)<deltastr) { - isampling=2; - ieta=imid; - } - } // end if sampling==3 - } // end if eta<1.325 - else { - isampling=2; - ieta=imid; - if (z>zmax1) { - ieta=55; - } - else if (z>zmax2 && aeta<1.375) { - ieta=54; - } - isamp2=2; - ieta2=imid; - } // end eta>1.352 - } // end radius selection - } // end eta1.4 - -// eta between 1.4 and 1.475 - - if (aeta>=Eta_max_s1 && aeta<Eta_max) { - r12 = Rmax1[447]; // radius for end of sampling 1 - r23=Z_max_acc/sinh(aeta); // radius of end of sampling 2, bounded by high z end - - double zmax = Z_max_lowr + dzdr*(radius-R_min_acc); - - iregion=1; - if (radius <=r12) { - isampling=1; - ieta=int((aeta-Eta_max_s1)/deta); - if (z>zmax) iactive=0; - } - else if (radius < (r12+Dr_s12)) { - isampling=1; - ieta=int((aeta-Eta_max_s1)/deta); - iactive=0; - } - else if (radius <= r23) { - isampling=2; - ieta=0; - if (z>zmax) iactive=0; - } - else { - isampling=2; - ieta=0; - iactive=0; - } - isamp2=isampling; - ieta2=ieta; - } -// eta above 1.475, not fiducial region, but still returns something -// for calibration hits - if (aeta>Eta_max) { - iregion=1; - r12 = Rmax1[447]; - if (radius <=r12) { - isampling=1; - ieta=2; - } - else { - isampling=2; - ieta=0; - } - isamp2=isampling; - ieta2=ieta; - iactive=0; - } - -// cross-check of active region - if (z>Z_max_acc || radius>R_max_acc || radius<R_min_acc || aeta > Eta_max) iactive=0; - - return iactive; -} -// ======================================================================= -// function findCell -// -// compute cell in EM accordion for hit at position x,y,z,radius,eta,phi -// given in LOCAL half barrel coordinate system (Stac Geant volume) -// It has already been checked that the hit is in the accordion sensitive volume -// - -void Geometry::findCell(const double &xPosition, - const double &yPosition, - const double &zPosition, - const double &aRadius, - const double &anEta, - const double &/*aPhi*/, - const bool MapDetail, - std::string strDetector) -{ - - if (m_FIRST) { -// get pointers to access G4 geometry - m_electrode = LArStraightElectrodes::GetInstance(strDetector); - m_absorber = LArStraightAbsorbers::GetInstance(strDetector); - m_coudeelec = LArCoudeElectrodes::GetInstance(strDetector); - m_coudeabs = LArCoudeAbsorbers::GetInstance(strDetector); - m_FIRST = false; - } - - m_cellID = 0; - - if (aRadius < m_rc[0] || aRadius >= m_rc[m_Nbrt1-1]) { -#ifdef DEBUGHITS - std::cout << " Outside Accordion " << aRadius << " " << m_rc[0] << " " << m_rc[m_Nbrt1-1] << std::endl; -#endif - return; // outside accordion - } - -// set the straight section number - m_nstraight=0; - for (int i=1;i<m_Nbrt1;i++) { - if (m_rc[i] > aRadius) break; - m_nstraight++; - } - if (m_nstraight <0 || m_nstraight >= m_Nbrt) { - std::cout << "Invalid straight number " << m_nstraight << " " << aRadius << std::endl; - return; - } - -// get the closest fold number - m_nfold=m_nstraight; - if (fabs(aRadius-m_rc[m_nfold]) > fabs(aRadius-m_rc[m_nfold+1]) ) m_nfold +=1; - if (m_nfold <0 || m_nfold >= m_Nbrt1) { - std::cout << "Invalid fold number " << m_nfold << std::endl; - return; - } - - -#ifdef DEBUGHITS - std::cout << " BarrelGeometry: radius,eta,phi " << aRadius << " " << anEta << " " << aPhi << std::endl; - std::cout << " Straight/Fold numbers " << m_nstraight << " " << m_nfold << std::endl; -#endif - -// eta and longitudinal segmentations - G4int ireg,isamp,ieta,isamp2,ieta2; - m_cellID = SampSeg(anEta,aRadius,zPosition,ireg,isamp,ieta,isamp2,ieta2); - - m_etaBin = ieta; - m_sampling = isamp; - m_region = ireg; - m_etaMap = ieta2; - m_sampMap = isamp2; - -// compute electrode number in phi - int phicell = PhiGap(aRadius,xPosition,yPosition); - if (phicell<0) phicell=0; -// for test beam, some protection - if (m_NCellTot !=1024) { - if (phicell>=m_NCellTot) { - if (phicell<512) phicell=m_NCellTot-1; - else phicell=0; - m_cellID=0; - } - } - -#ifdef DEBUGHITS - std::cout << " phigap " << phicell << std::endl; -#endif - -// compute readout cell number - int sampling_phi_nGaps=4; - if (m_region==0 && m_sampling==1) sampling_phi_nGaps=16; - - if (m_cellID==0) { - m_phiBin = (G4int) ( phicell/sampling_phi_nGaps ); - m_distElec=9999.; - return; - } - -// compute distance to electrode - G4double xl; - G4int nstr = m_nstraight; - G4double distElec = Distance_Ele(xPosition,yPosition,phicell,nstr,m_nfold,xl); - -#ifdef DEBUGHITS - std::cout << " distElec " << distElec << std::endl; -#endif - -// if distance is < 2.5mm we are sure to be in the correct gap - if (std::fabs(distElec) > 2.5) { -// try +-2 electrode in phi to get minimum distance - double dElecMin=distElec; - double xlmin=xl; - int phicellmin=phicell; - for (int ii=-2;ii<3;ii++) { - if (ii==0) continue; - int phicellnew = phicell+ii; -// for test beam no phi wrapping - if (m_NCellTot != 1024 && ( phicellnew<0 || phicellnew >= m_NCellTot)) continue; - if (phicellnew < 0) phicellnew += m_NCellTot; - if (phicellnew >= m_NCellTot) phicellnew -= m_NCellTot; - double xln; - int nstr2=m_nstraight; - double dElec = Distance_Ele(xPosition,yPosition,phicellnew,nstr2,m_nfold,xln); - if (fabs(dElec)<fabs(dElecMin)) { - phicellmin=phicellnew; - xlmin=xln; - dElecMin = dElec; - nstr=nstr2; - } - } - m_phiGap = phicellmin; - m_distElec = dElecMin; - m_xl = xlmin; - m_nstraight = nstr; - } // end distance >2.5mm - else { - m_phiGap=phicell; - m_distElec=distElec; - m_xl=xl; - m_nstraight=nstr; - } - -#ifdef DEBUGHITS - std::cout << " final phiGap,distElec,xl " << m_phiGap << " " << m_distElec << " " - << m_xl << std::endl; -#endif - -// compute distance to absorber - - G4int nabs; - if (m_distElec<0) nabs=m_phiGap; - else nabs=m_phiGap+1; - if (nabs >= m_NCellMax) nabs -= m_NCellMax; - m_distAbs = Distance_Abs(xPosition,yPosition,nabs,m_nstraight,m_nfold); -#ifdef DEBUGHITS - std::cout << " nabs,distAbs " << nabs << " " << m_distAbs << std::endl; -#endif - -// in some rare cases near fold, the closest distance could give the wrong gap -// in such case, the signs of distAbs and distElec are not opposite as they should - if ((m_distAbs>0. && m_distElec>0) || - (m_distAbs<0. && m_distElec<0) ) { -// std::cout << "distElec and distAbs same sign " << m_distElec << " " << m_distAbs << std::endl; -// std::cout << " m_phiGap " << m_phiGap << std::endl; - if (std::fabs(m_distElec)>std::fabs(m_distAbs)) { - if (m_distAbs>0) m_phiGap += 1; - if (m_distAbs<0) m_phiGap -= 1; - if (m_NCellTot != 1024) { - if (m_phiGap <0) m_phiGap=0; - if (m_phiGap >= m_NCellTot) m_phiGap = m_NCellTot-1; - } else { - if (m_phiGap < 0) m_phiGap += m_NCellTot; - if (m_phiGap >= m_NCellTot) m_phiGap -= m_NCellTot; - } - m_distElec = Distance_Ele(xPosition,yPosition,m_phiGap,m_nstraight,m_nfold,m_xl); -// std::cout << " new phiGap,distElec " << m_phiGap << " " << m_distElec << std::endl; - } - } - - m_phiBin = (G4int) ( m_phiGap/sampling_phi_nGaps ); - - if (MapDetail) { -// compute x0,y0 coordinates in local electrode frame, using closest fold -// as reference - G4double alpha = m_coudeelec->PhiRot(m_nfold,m_phiGap); - G4double dx=xPosition-m_coudeelec->XCentCoude(m_nfold,m_phiGap); - G4double dy=yPosition-m_coudeelec->YCentCoude(m_nfold,m_phiGap); - G4double dx1=dx*cos(alpha)-dy*sin(alpha); - G4double dy1=dx*sin(alpha)+dy*cos(alpha); - m_x0 = dx1 + m_xc[m_nfold]; - m_y0 = dy1 + m_yc[m_nfold]; - if (m_parity==1) m_y0 = -1*m_y0; - } - - -} // end of findCell method - -// ============================================================================= -// initialize phi0 vs radius of first absorber (for gam=0) -void Geometry::GetRphi() -{ - const G4double dl=0.001; - const G4double inv_dl = 1. / dl; - G4double cenx[15],ceny[15]; - G4double xl,xl2; - G4double sum1[5000],sumx[5000]; - xl=0; - xl2=0.; - m_NRphi=5000; - m_Rmin=1500.; - m_dR=0.10; - m_Rmax=0.; - - m_2pi = 2.*M_PI; - - const G4double rint= m_rint_eleFib; - const G4double inv_rint = 1. / rint; - const G4double dt=dl * inv_rint; - const G4double inv_dt = 1. / dt; - - for (G4int i=0;i<m_NRphi;i++) { - sum1[i]=0.; - sumx[i]=0.; - } - for (G4int i=0;i<15;i++) { - cenx[i]=m_rc[i]*cos(m_phic[i]); - ceny[i]=m_rc[i]*sin(m_phic[i]); - } - - for (G4int i=0; i<15; i++) { - -// fold - G4double phi0,phi1; - if (i==0) { - // first fold goes up - if (m_parity==0) { - phi0=-CLHEP::pi/2.; - phi1=-m_delta[0]; - } - // first fold goes down - else { - phi0=m_delta[0]; - phi1=CLHEP::pi/2; - } - } - else if (i==14) { - if (m_parity==0) { - phi0=-CLHEP::pi+m_delta[13]; - phi1=-CLHEP::pi/2.; - } - else { - phi0=CLHEP::pi/2; - phi1=CLHEP::pi - m_delta[13]; - } - } - else { - if (i%2==(1-m_parity)) { - phi0=m_delta[i]; - phi1=CLHEP::pi-m_delta[i-1]; - } - else { - phi0=-CLHEP::pi+m_delta[i-1]; - phi1=-m_delta[i]; - } - } - xl2+=rint*fabs(phi1-phi0); - G4int nstep=int((phi1-phi0)*inv_dt)+1; - for (int ii=0;ii<nstep;ii++) { - xl+=dl; - G4double phi=phi0+dt*((G4double)ii); - G4double x=cenx[i]+rint*cos(phi); - G4double y=ceny[i]+rint*sin(phi); - G4double radius=sqrt(x*x+y*y); - if (radius>m_Rmax) m_Rmax=radius; - G4double phid=atan(y/x); - G4int ir=((int) ((radius-m_Rmin)/m_dR) ); - if (ir>=0 && ir < m_NRphi) { - sum1[ir]+=1.; - sumx[ir]+=phid; - } - } - -// straight section - if (i<14) { - G4double dx=cenx[i+1]-cenx[i]; - G4double dy=ceny[i+1]-ceny[i]; - G4double along=dx*dx+dy*dy-4.*rint*rint; - along=sqrt(along); - G4double x0=0.5*(cenx[i+1]+cenx[i]); - G4double y0=0.5*(ceny[i+1]+ceny[i]); - G4double phi; - if (i%2==m_parity) phi=CLHEP::pi/2-m_delta[i]; - else phi=-CLHEP::pi/2.+m_delta[i]; - G4double x1=x0-0.5*along*cos(phi); - G4double y1=y0-0.5*along*sin(phi); - xl2+=along; - int nstep=int(along*inv_dl)+1; - for (int ii=0;ii<nstep;ii++) { - xl+=dl; - G4double x=x1+dl*((G4double)ii)*cos(phi); - G4double y=y1+dl*((G4double)ii)*sin(phi); - G4double radius=sqrt(x*x+y*y); - if (radius>m_Rmax) m_Rmax=radius; - G4double phid=atan(y/x); - G4int ir=((int) ((radius-m_Rmin)/m_dR) ); - if (ir>=0 && ir < m_NRphi) { - sum1[ir]+=1.; - sumx[ir]+=phid; - } - } - } - } -// std::cout << "total electrode lenght " << xl << " " << xl2 << std::endl; -// std::cout << "rmax in accordion " << m_Rmax << std::endl; - for (int i=0; i<m_NRphi; i++) { - if (sum1[i]>0) { - m_Rphi[i]=sumx[i]/sum1[i]; - // Not used: - //G4double radius = m_Rmin + ((G4double(i))+0.5)*m_dR; - //std::cout << " GUTEST r,phi0 " << radius << " " << m_Rphi[i] << std::endl; - } - else m_Rphi[i]=0.; - } -} - -// ====================================================================================== -// phi of first absorber as function of radius for nominal accordion geometry -// (before sagging) -G4double Geometry::Phi0(G4double radius) -{ - G4int ir; - if (radius < m_Rmin) ir=0; - else { - if (radius > m_Rmax) radius=m_Rmax-0.0001; - ir=((int) ((radius-m_Rmin)/m_dR) ); - } - return m_Rphi[ir]; -} - -// ====================================================================================== -// compute number (0 to 1023) of closest electrode according to nominal -// accordion geometry -G4int Geometry::PhiGap(const double & radius, const double & xhit, const double &yhit) -{ - G4double phi0=Phi0(radius)+m_gam0; // from -pi to pi - G4double phi_hit=atan2(yhit,xhit); // from -pi to pi - G4double dphi=phi_hit-phi0; -// bring back to 0-2pi - if (dphi<0) dphi=dphi+m_2pi; - if (dphi>=m_2pi) dphi=dphi-m_2pi; - dphi=dphi/(m_2pi)*1024; - G4int ngap=((int) dphi); -#ifdef DEBUGHITS - std::cout << " phi0 " << phi0 << " dphi, ngap " << dphi << " " << ngap << std::endl; -#endif - return ngap; -} - -//=================================================================================== -// full cell id computation starting from an arbitrary G4 step - -LArG4Identifier Geometry::CalculateIdentifier(const G4Step* a_step,std::string strDetector) -{ - -// total number of cells in phi to distinguish 1 module (testbeam case) from full Atlas - m_testbeam=false; - if (m_NCellTot != 1024) { - m_testbeam=true; - } - -// The default result is a blank identifier. - LArG4Identifier result = LArG4Identifier(); - -// Get all the required information from the current step - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - const G4NavigationHistory* g4navigation = pre_step_point->GetTouchable()->GetHistory(); - G4int ndep = g4navigation->GetDepth(); - G4int indECAM = -999; - -// Now navigate through the volumes hierarchy - - G4String ecamName; - if (strDetector=="") ecamName = "LAr::EMB::ECAM"; - else ecamName = strDetector+"::LAr::EMB::ECAM"; - - bool inSTAC = false; - int zside=1; - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - G4String vname = v1->GetName(); - if ( vname == ecamName ) indECAM=ii; - if ( vname.find("STAC") !=std::string::npos) inSTAC=true; - if ( vname.find("NegPhysical") != std::string::npos) zside=-1; - } - if (indECAM>=0) - result = CalculateECAMIdentifier( a_step , indECAM, strDetector, inSTAC, zside) ; - else - std::cout << "LArBarrel::Geometry::CalculateIdentifier ECAM volume not found in hierarchy" << std::endl; - - return result; -} - -//====================================================================================== -// -// The following method computes the identifiers in the ECAM volume: -// (including dead material identifier) -// -// 1) Tranformation into LOCAL half barrel frame -// -// 2) Check if the hit is in the fiducial region (EM accordion, no presampler) -// fiducial range: 1500.24 < r < 1960.00 mm -// |eta| < 1.475 -// 4 < z < 3164 mm (in local half barrel coordinates) -// -// 3) If the hit is in the fiducial region standard identifier are filled -// -// 4) If the hit is outside the fiduacial region calibration hits are filled -// -// CaloDM_ID identifier for the barrel: -// -// detector_system/subdet/type/sampling/region/eta/phi -// -// * For hits with radius < 1500.24 -// ****************************** -// -// detector system = 10 -> Calorimeters -// subdet = +/-4 -> LAr dead materials -// type = 1 -> dead materials outside accordion and active presampler layers -// sampling = 1 -> dead materials in front and in active LAr calorimeters (starting from front warm -// cryostat walls) -// regions: = 3 -> all materials from the active layer of the barrel presampler to the active layer -// of accordion, 0 < |eta| < 1.5 -// -// ---> Granularity : deta 0.1 granularity within region -// dphi pi/32 ~ 0.1 granularity within region -// -// * For hits with radius > 1960.00 -// ****************************** -// -// detector system = 10 -> Calorimeters -// subdet = +/-4 -> LAr dead materials -// type = 1 -> dead materials outside accordion and active presampler layers -// sampling = 2 -> dead materials between active LAr calorimeters and Tile calorimeters or HEC-2 wheels -// regions: = 0 -> all materials behind the active layer of accordion in front the Tile barrel -// for |eta| < 1.0 -// =2 -> all materials in front of the scintillator and behind the active layer of accordion -// for 1.0 < |eta| < 1.5 -// -// ---> Granularity : deta 0.1 granularity within region -// dphi pi/32 ~ 0.1 granularity within region -// -//====================================================================================== - -LArG4Identifier Geometry::CalculateECAMIdentifier(const G4Step* a_step, const G4int indECAM, std::string strDetector, const bool inSTAC, int zside) -{ - - LArG4Identifier result = LArG4Identifier();; - - // Get all the information about the step - - G4StepPoint *thisStepPoint = a_step->GetPreStepPoint(); - G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = thisStepPoint->GetPosition(); - G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); - G4ThreeVector p = (thisStepPoint->GetPosition() + thisStepBackPoint->GetPosition()) * 0.5; - -#ifdef DEBUGHITS - std::cout << "Position of the step in the ATLAS frame (x,y,z) --> " << p.x() << " " << p.y() << " " << p.z() << std::endl; - std::cout << "Eta and Phi in the ATLAS frame --> " << p.eta() << " " << p.phi() << std::endl; -#endif - - // BACK directly into the LOCAL half_Barrel. All the variables in this LOCAL framework get the SUFFIX Zpos - - const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); - const G4AffineTransform transformation = g4navigation->GetTransform(indECAM); - G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); - G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint); - G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5; - -#ifdef DEBUGHITS - std::cout << "Position of the step in the LOCAL frame (x,y,z) --> " << midinLocal.x() << " " << midinLocal.y() << " " << midinLocal.z() << std::endl; - std::cout << "Eta and Phi of the step in LOCAL frame --> " << midinLocal.eta() << " " << midinLocal.phi() << std::endl; -#endif - - // coordinates in the local frame - - G4double xZpos = midinLocal.x(); - G4double yZpos = midinLocal.y(); - G4double zZpos = midinLocal.z(); - G4double etaZpos = midinLocal.pseudoRapidity(); - G4double phiZpos = midinLocal.phi(); - if(phiZpos<0.) phiZpos = phiZpos + 2.*M_PI; - G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos; - G4double radiusZpos = sqrt(radius2Zpos); - - if (m_testbeam) - m_zSide = 1; - else - m_zSide = zside; - - -// Check if the hit is in the fiducial range and in the STAC volume -// if yes this is active or inactive material - - if (inSTAC && radiusZpos >=m_rMinAccordion && radiusZpos <= m_rMaxAccordion && - zZpos <= m_zMaxBarrel && zZpos >= m_zMinBarrel && etaZpos <= m_etaMaxBarrel) { - -#ifdef DEBUGHITS - std::cout << "This hit is in the STAC volume !!!!! " << std::endl; -#endif - -// DETERMINATION of m_cellID, m_zSide, m_sampling, m_phiBin, m_etaBin, m_stackNumID - bool MapDetail=false; - Geometry::findCell( xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail, strDetector ); - - // adjust phi in the negative half barrel frame - - if( m_zSide == -1 ) - { - if( m_sampling == 1 && m_region ==0 ) - { - m_phiBin = 31 - m_phiBin; - if(m_phiBin < 0 ) m_phiBin += 64; - } - if( m_sampling == 1 && m_region ==1 ) - { - m_phiBin = 127 - m_phiBin; - if(m_phiBin < 0 ) m_phiBin += 256; - } - if( m_sampling >= 2 ) - { - m_phiBin = 127 - m_phiBin; - if(m_phiBin < 0 ) m_phiBin += 256; - } - } - -// there are few hundred microns between the 4mm nominal beginning of the active region -// and the real beginning of the first strip at eta=0.025/8 -// to avoid inactive energy with strip=0 assign this to strip=1 - if (m_sampling==1 && m_region==0 && m_etaBin==0) { - m_etaBin=1; - } - - result << 4 // LArCalorimeter - << 1 // LArEM - << m_zSide - << m_sampling - << m_region - << m_etaBin - << m_phiBin; - -#ifdef DEBUGHITS - std::cout << "Here the identifier for the barrel ACTIVE ----> " << std::endl; - std::cout << "eta in local frame --> " << etaZpos << std::endl; - std::cout << "m_zSide ----> " << m_zSide << std::endl; - std::cout << "m_sampling ----> " << m_sampling << std::endl; - std::cout << "m_region ----> " << m_region << std::endl; - std::cout << "m_etaBin ----> " << m_etaBin << std::endl; - std::cout << "m_phiBin ----> " << m_phiBin << std::endl; - G4double firsteta = thisStepPoint->GetPosition().pseudoRapidity(); - std::cout << "And also etafirst ----> " << firsteta << std::endl; -#endif - -// if (!Geometry::CheckLArIdentifier(m_sampling,m_region,m_etaBin,m_phiBin)) { -// std::cout << " ** Bad LAr identifier " << m_sampling << " " << m_region << " " -// << m_etaBin << " " << m_phiBin << std::endl; -// std::cout << " x,y,z,eta,phi " << xZpos << " " << yZpos << " " << zZpos -// << " " << radiusZpos << " " << etaZpos << " " << phiZpos << std::endl; -// } - - - } -// hits in dead material part - else { - - G4int sampling=0; - G4int region=0; - G4int numDeadPhiBins = 64; - double abs_eta = fabs(etaZpos); - double DM1EtaWidth = 0.1 ; - double DM1PhiWidth = 2.*M_PI / numDeadPhiBins ; - m_etaBin = (G4int) ( abs_eta * (1./DM1EtaWidth) ) ; - m_phiBin = (G4int) (phiZpos/ DM1PhiWidth ); - G4int type=1; - // protect against rounding error for phi ~2pi - if (m_phiBin==numDeadPhiBins) m_phiBin=m_phiBin-1; - - // adjust phi for negative half barrel - - if ( m_zSide == -1 ) { - m_phiBin = 31 - m_phiBin; - if (m_phiBin < 0 ) m_phiBin +=64 ; - } - -// material in front of the active accordion - if ( radiusZpos < m_rMinAccordion ) { - sampling =1 ; - region = 3 ; - if (m_etaBin > 14) m_etaBin=14; - -#ifdef DEBUGHITS - std::cout << "This hit is in the ECAM volume in front of the accordion (DEAD MATERIAL) !!!!! " << std::endl; -#endif - - } else if (radiusZpos >= m_rMaxAccordion){ // material behind the active accordion - sampling = 2; - - if (abs_eta < 1.0 ) { - region = 0 ; -#ifdef DEBUGHITS - std::cout << "This hit is in the ECAM volume behind accordion (DEAD MATERIAL 0) !!!!! " << std::endl; -#endif - } else if ( abs_eta >= 1.0 && abs_eta < 1.5) { - region = 2; - m_etaBin = m_etaBin - 10; // to have etabin between 0 and 4 -#ifdef DEBUGHITS - std::cout << "This hit is in the ECAM volume behind accordion (DEAD MATERIAL 2) !!!!! " << std::endl; -#endif - } else { - std::cout << " LArBarrelGeometry: hit behind accordion at eta>1.5 !!! " << std::endl, - region = 2; - m_etaBin = 4; - } - - } else if (zZpos <= m_zMinBarrel) { // inactive matter between two EMB halves - type=2; - region=0; - G4int phisave=m_phiBin; - G4bool MapDetail=false; - Geometry::findCell( xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail ,strDetector ); - sampling = m_sampling; // sampling as in normal definition - m_etaBin=0; - m_phiBin=phisave; - - } else if (zZpos >= m_zMaxBarrel || abs_eta >= 1.40) { // inactive matter between EMB and scintillator - if (abs_eta >1.0 && abs_eta < 1.5) { - sampling=2; - region=2; - m_etaBin = m_etaBin - 10; // to have etabin between 0 and 4 - } else if (abs_eta < 1.6) { - sampling=1; - region=4; - m_etaBin=0; - } else { - std::cout << " LArBarrelGeometry: hit at eta>1.6 !!! " << std::endl; - sampling=1; - region=4; - m_etaBin=0; - } - } else { - if (!m_testbeam) { - std::cout << "LArBarrelGeometry: cannot find region for DM hit..." << std::endl; - std::cout << "r,z,eta,phi " << radiusZpos << " " << zZpos << " " << etaZpos << " " << phiZpos << std::endl; - std::cout << "x,y,z (Atlas) " << p.x() << " " << p.y() << " " << p.z() << std::endl; - std::cout << " inSTAC " << inSTAC << std::endl; - G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit(); - std::cout << " eDeposited " << thisStepEnergyDeposit << std::endl; - G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume(); - G4String volName = vol->GetName(); - std::cout << " volName " << volName << std::endl; - G4int ndep = g4navigation->GetDepth(); - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - G4String vname = v1->GetName(); - std::cout << "vname " << vname << std::endl; - } - - } -// in test beam case, we can get there for leakage on the side (in phi) of the module -// in this case, we attribute an identifier like inactive material - else - { - G4bool MapDetail=false; - Geometry::findCell( xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail ,strDetector ); -// std::cout << " Lateral lakage r,eta,phi " << radiusZpos << " " << etaZpos << " " -// << phiZpos << " sampling/region/eta/phi " << m_sampling << " " << -// m_region << " " << m_etaBin << " " << m_phiBin << std::endl; -// protect against small space between z=4m and real beginning of ieta=1 in strips - if (m_sampling==1 && m_region==0 && m_etaBin==0) { - m_etaBin=1; -// std::cout << "S1R0 etabin 0 found r,z,phi local " << radiusZpos << " " -// << " " << zZpos << " " << phiZpos << std::endl; - } - result << 4 // LArCalorimeter - << 1 // LArEM - << m_zSide - << m_sampling - << m_region - << m_etaBin - << m_phiBin; - return result; - } - } - - result << 10 // LArCalorimeter - << m_zSide * 4 // LArBarrel - << type - << sampling - << region - << m_etaBin - << m_phiBin; - -#ifdef DEBUGHITS - std::cout << "Here the identifier for the barrel DEAD materials ---->" << std::endl; - std::cout << "Type ----> " << type << std::endl; - std::cout << "Sampling ----> " << sampling << std::endl; - std::cout << "Region ----> " << region << std::endl; - std::cout << "m_zSide ----> " << m_zSide*4 << std::endl; - std::cout << "etaBin ----> " << m_etaBin << std::endl; - std::cout << "phiBin ----> " << m_phiBin << std::endl; -#endif - -// if (!Geometry::CheckDMIdentifier(type,sampling,region,m_etaBin,m_phiBin)) { -// std::cout << " ** Bad DM identifier " << type << " " << sampling << " " << region << " " -// << m_etaBin << " " << m_phiBin << std::endl; -// std::cout << "x,y,z,r,eta,phi" << xZpos << " " << yZpos << " " << zZpos << -// " " << radiusZpos << " " << etaZpos << " " << phiZpos << std::endl; -// } - - } - - return result; - -} - -bool Geometry::CheckDMIdentifier(int type, int sampling, int region, int eta, int phi) -{ - - if (type <1 || type > 2) return false; - if (type==1) { - if (sampling<1 || sampling>2) return false; - if (sampling==1) { - if (region!=3 && region !=4) return false; - if (phi<0 || phi>63) return false; - if (region==3) { - if (eta<0 || eta>14) return false; - } - if (region==4) { - if (eta !=0) return false; - } - } - if (sampling==2) { - if (region !=0 && region !=2) return false; - if (phi<0 || phi>63) return false; - if (region==0){ - if (eta<0 || eta>9) return false; - } - if (region==2) { - if (eta<0 || eta>4) return false; - } - } - } - if (type==2) { - if (sampling<1 || sampling >3) return false; - if (region !=0) return false; - if (eta!=0) return false; - if (phi<0 || phi>63) return false; - } - return true; -} - - -bool Geometry::CheckLArIdentifier(int sampling, int region, int eta, int phi) -{ - if (sampling<0 || sampling >3) return false; - if (sampling==0) { - if (region!=0) return false; - if (eta<0 || eta>60) return false; - if (phi<0 || phi>63) return false; - } - if (sampling==1) { - if (region<0 || region >1) return false; - if (region==0) { - if (eta<1 || eta>447) return false; - if (phi<0 || phi>63) return false; - } - if (region==1) { - if (eta<0 || eta>2) return false; - if (phi<0 || phi>255) return false; - } - } - if (sampling==2) { - if (region<0 || region >1) return false; - if (region==0) { - if (eta<0 || eta>55) return false; - if (phi<0 || phi>255) return false; - } - if (region==1) { - if (eta!=0) return false; - if (phi<0 || phi>255) return false; - } - } - if (sampling==3) { - if (region !=0) return false; - if (eta<0 || eta>26) return false; - if (phi<0 || phi>255) return false; - } - return true; -} - -} //end of Barrel namespace - -} // end of LArG4 namespace diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cxx new file mode 100644 index 000000000000..db082e8c058c --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.cxx @@ -0,0 +1,1371 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: LArBarrelGeometry.cxx +PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel + +AUTHORS: G. Unal, L. Carminati +CREATED: September, 2004 + +PURPOSE: 'geometrical' methods used by the LArBarrelCalculator. + These methods (previously in LArBarrelCalculator) were written + by Gaston Parrour and adapted by Sylvain Negroni. + +UPDATES: - Calculate identifier method used by CalibrationCalculator. + (sept 2004) + - Cleanup (GU March-April 2005) + +********************************************************************/ + +// #define DEBUGHITS + +#include <cmath> +#include <iostream> +#include "LArBarrelGeometry.h" + +#include "LArStraightAbsorbers.h" +#include "LArStraightElectrodes.h" +#include "LArCoudeElectrodes.h" +#include "LArCoudeAbsorbers.h" + +namespace LArG4 { + + namespace Barrel { + + Geometry::Geometry(const std::string& name, ISvcLocator *pSvcLocator) + : AthService(name, pSvcLocator) + , m_detectorName("LArMgr") + , m_testbeam(false) + , m_iflSAG(false) + { + declareProperty("DetectorName",m_detectorName); + declareProperty("TestBeam", m_testbeam); + } + + // ==================================================================================== + + StatusCode Geometry::initialize() + { + // initialize the geometry. + // Access source of detector parameters. + + LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); + + // number of straight sections (should be 14) + m_Nbrt = (int) (parameters->GetValue("LArEMBnoOFAccZigs")); + // Number of ZIGs + 1 i.e. 15 = number of folds + m_Nbrt1 = m_Nbrt + 1; + // phi of first absorber + m_gam0 = parameters->GetValue("LArEMBAbsPhiFirst"); + // radius of curvature of neutral fiber in the folds + m_rint_eleFib = parameters->GetValue("LArEMBNeutFiberRadius"); + + m_rc = new double[m_Nbrt1]; + m_phic = new double[m_Nbrt1]; + m_delta = new double[m_Nbrt1]; + m_xc = new double[m_Nbrt1]; + m_yc = new double[m_Nbrt1]; + + // r,phi positions of the centre of the folds (nominal geometry) + for (G4int idat = 0; idat < m_Nbrt1 ; idat++) { + m_rc[idat] = (double) parameters->GetValue("LArEMBRadiusAtCurvature",idat); + m_phic[idat] = (double) parameters->GetValue("LArEMBPhiAtCurvature",idat); + m_delta[idat] = (double) parameters->GetValue("LArEMBDeltaZigAngle",idat); + m_xc[idat] = m_rc[idat]*cos(m_phic[idat]); + m_yc[idat] = m_rc[idat]*sin(m_phic[idat]); + } + // define parity of accordion waves: =0 if first wave goes up, 1 if first wave goes down in the local frame + m_parity=0; + if (m_phic[0]<0.) { m_parity=1; } + // + m_rMinAccordion = parameters->GetValue("LArEMBRadiusInnerAccordion"); + m_rMaxAccordion = parameters->GetValue("LArEMBFiducialRmax"); + m_etaMaxBarrel = parameters->GetValue("LArEMBMaxEtaAcceptance"); + m_zMinBarrel = parameters->GetValue("LArEMBfiducialMothZmin"); + m_zMaxBarrel = parameters->GetValue("LArEMBfiducialMothZmax"); + // === GU 11/06/2003 total number of cells in phi + // to distinguish 1 module (testbeam case) from full Atlas + m_NCellTot = (int) (parameters->GetValue("LArEMBnoOFPhysPhiCell")); + // total number of cells in phi to distinguish 1 module (testbeam case) from full Atlas + m_testbeam=false; + if (m_NCellTot != 1024) { + m_testbeam=true; + } + m_NCellMax=1024; + // === + + // Initialize r-phi reference map + this->GetRphi(); + + // get pointers to access G4 geometry + m_electrode = LArStraightElectrodes::GetInstance(m_detectorName); + m_absorber = LArStraightAbsorbers::GetInstance(m_detectorName); + m_coudeelec = LArCoudeElectrodes::GetInstance(m_detectorName); + m_coudeabs = LArCoudeAbsorbers::GetInstance(m_detectorName); + + if (m_detectorName.empty()) m_ecamName = "LAr::EMB::ECAM"; + else m_ecamName = m_detectorName+"::LAr::EMB::ECAM"; + + + return StatusCode::SUCCESS; + } + + // ==================================================================================== + + StatusCode Geometry::finalize() + { + if (m_rc) delete [] m_rc; + if (m_phic) delete [] m_phic; + if (m_delta) delete [] m_delta; + if (m_xc) delete [] m_xc; + if (m_yc) delete [] m_yc; + + return StatusCode::SUCCESS; + } + + // ==================================================================================== + + StatusCode Geometry::queryInterface( const InterfaceID & riid, void** ppvInterface ) + { + if ( ILArBarrelGeometry::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<ILArBarrelGeometry*>(this); + addRef(); + return StatusCode::SUCCESS; + } + // Interface is not directly available : try out a base class + return AthService::queryInterface(riid, ppvInterface); + } + + //====================================================================================== + // + // Here INTRINSIC Distance_to_electrode determination (G.P.) + // + // This retuns an ALGEBRICDistEle value, the distance from electrode + //neutral fiber TOWARDS the Sub_Step in LAr (measured on a local perpendicular + //vector unit oriented upwards i.e. following increasing Phi values). + // + // This is done in THE INTRINSIC LOCAL Z > 0. half_barrel part ("stac_phys1") + // + // inputs: xhit,yhit = x,y positions in local half barrel + // PhiCell = electrode number in phi (0 to 1023 for Atlas case) + // Num_Straight = number (0 to 13) of the straight section + // Num_Coude = number (0 to 14) of closest fold + // + // output: Function value = algebric distance to electrode + // xl = normalized lenght along electrode straight section (between +-1) + + double Geometry::Distance_Ele(const double & xhit, + const double &yhit, const int &PhiCell, int &Num_Straight, + const int &Num_Coude, double &xl) const + { + // + // FrameWork is consistent with the one used to PhiCell determination + // e.g. it assumes HERE to be the LOCAL one of "stac_phys1", + // (mother of ACCordion volumes) from which Z> 0. and Z < 0. half_barrel + // parts are then defined. + // + // One needs POINTERS to Electrode neutral fibers + // either for straight parts or for folds + // + // Fold Center ccoordinates + const G4double Xc[2] = { m_coudeelec->XCentCoude(Num_Coude, PhiCell), m_coudeelec->YCentCoude(Num_Coude, PhiCell) }; + const G4double radfold = sqrt(Xc[0]*Xc[0]+Xc[1]*Xc[1]); + const G4double radhit = sqrt(xhit*xhit+yhit*yhit); + + // check if the assumed straight number is the correct one + // (this can be wrong when we are close to a fold and there is sagging) + if (Num_Coude == Num_Straight && radhit <radfold) { + if (Num_Straight>0) { Num_Straight = Num_Straight-1; } + // ATH_MSG_VERBOSE("radhit,radfold " << radhit << " " << radfold << " change straight by +1"); + } + if (Num_Coude == (Num_Straight+1) && radhit > radfold) { + if (Num_Straight<12) { Num_Straight = Num_Straight+1; } + // ATH_MSG_VERBOSE("radhit,radfold " << radhit << " " << radfold << " change straight by -1"); + } + + // u unit 2D_Vector along straight part of the electrode neutral fiber + const double u[2] = { m_electrode->Cosu(Num_Straight, PhiCell), m_electrode->Sinu(Num_Straight, PhiCell) }; + // Middle m_coordinates of this straight part of the electrode neutral fiber + const double Xm[2] = { m_electrode->XCentEle(Num_Straight, PhiCell), m_electrode->YCentEle(Num_Straight, PhiCell) }; + // m_Hit Vector components + double dx = xhit - Xm[0]; + double dy = yhit - Xm[1]; + + // First compute algebric distance m_hit (2D) the 2D_projection of the + // m_Hit Vector on this electrode neutral fiber. + const double hit = dx*u[0] + dy*u[1]; + + // + // Flat of Fold Region ? + // + const G4double Half_Elec(m_electrode->HalfLength(Num_Straight,PhiCell)); + + if(std::fabs(hit) < Half_Elec) { + // Flat Region + xl=hit/Half_Elec; + return u[0]*dy - u[1]*dx; + } + else { + // Fold region + // c_Hit Vector components and its length + dx = xhit - Xc[0]; + dy = yhit - Xc[1]; + const double dr = sqrt( dx*dx + dy*dy); + if (Num_Coude==Num_Straight) { xl=-1.; } + else xl=+1; + return (Num_Coude%2 == m_parity) ? (m_rint_eleFib-dr) : (dr - m_rint_eleFib); + } // end of Fold Regions + } // end of the function Distance_Ele + + + //====================================================================================== + // Algebric distance to absorber + // + // inputs: xhit,yhit = x,y positions in local half barrel + // PhiCell = absorber number in phi (0 to 1023 for Atlas case) + // Num_Straight = number (0 to 13) of the straight section + // Num_Coude = number (0 to 14) of closest fold + // + // output: Function value = algebric distance to electrode + + double Geometry::Distance_Abs(const double & xhit, + const double &yhit, const int &PhiCell, const int &Num_Straight, + const int &Num_Coude) const + { + // + // FrameWork is consistent with the one used to PhiCell determination + // e.g. it assumes HERE to be the LOCAL one of "stac_phys1", + // (mother of ACCordion volumes) from which Z> 0. and Z < 0. half_barrel + // parts are then defined. + // + // One needs POINTERS to Electrode neutral fibers + // either for straight parts or for folds + // + // u unit 2D_Vector along straight part of the electrode neutral fiber + const G4double u[2] = { m_absorber->Cosu(Num_Straight, PhiCell), m_absorber->Sinu(Num_Straight, PhiCell) }; + // Middle m_coordinates of this straight part of the electrode neutral fiber + const G4double Xm[2] = { m_absorber->XCentAbs(Num_Straight, PhiCell), m_absorber->YCentAbs(Num_Straight, PhiCell) }; + // m_Hit Vector components + double dx = xhit - Xm[0]; double dy = yhit - Xm[1]; + + // First compute algebric distance hit (2D) the 2D_projection of the + // m_Hit Vector on this electrode neutral fiber. + const double hit = dx*u[0] + dy*u[1]; + + // + // Flat of Fold Region ? + // + if(std::fabs(hit) < m_absorber->HalfLength(Num_Straight,PhiCell)) { + // Flat Region + return u[0]*dy - u[1]*dx; + } + else { + // Fold Center c_coordinates + const G4double Xc[2] = { m_coudeabs->XCentCoude(Num_Coude, PhiCell), m_coudeabs->YCentCoude(Num_Coude, PhiCell) }; + // c_Hit Vector components and its length + dx = xhit - Xc[0]; + dy = yhit - Xc[1]; + const double dr = sqrt( dx*dx + dy*dy); + return (Num_Coude%2 == m_parity) ? (m_rint_eleFib-dr) : (dr - m_rint_eleFib); + } // end of Fold Regions + } // end of the function Distance_Abs + + + //============================================================================= + // Function SampSeg + // + // eta-sampling segmentation of barrel calorimeter GU, January 2005 + // input values: eta,radius in half-barrel frame + // + // return value of function: true=active area, false=inactive area + // return arguments: iregion,isampling,ieta + // take into account detailed electrode drawing + // with readout strips + // isamp2,ieta2 do not take into account + // readout strips and can be used to access current + // maps. + // + // iregion=0 (eta<1.4) or 1 (eta=1.4-1.475) + // for region 0: isampling = 1 (strips), 2 (middle), 3 (back) + // for region 1: isampling = 1 or isampling = 2 + // ieta= eta cell number + // region0,samp1: ieta=1->448 (strip 0 does not exist) + // region0,samp2: ieta=0->55 + // region0,samp3: ieta=0->26 (max eta 1.325) + // region1,samp1: ieta=0->2 (deta=0.025) + // region1,samp2: ieta=0 (only 1 cell) + + G4int Geometry::SampSeg(G4double eta, G4double radius, G4double z, + G4int& iregion, G4int& isampling, G4int& ieta, + G4int& isamp2, G4int& ieta2) const + { + static G4double Rmax1[448]; + static G4double Rmax2[56]; + static G4double Eta_max,Eta_max_s1,Eta_max_s3,R_max_acc,Z_max_acc,R_min_acc,R_min_highz; + static G4double Dr_s12; + static G4double deltaz,Z_max_lowr,dzdr; + static G4double deta; + static G4double zmax1,zmax2,zmax3,zmax4,zmax5,zmax6,zmax7,rmax1,rmax2,rmax3,rmax4; + static bool FILL = true; + if (FILL) { + + LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); + + // maximum eta barrel 1.475 (at r=1500.024) + Eta_max = parameters->GetValue("LArEMBMaxEtaAcceptance"); + // minimum active radius 1500.024 + R_min_acc= parameters->GetValue("LArEMBRadiusInnerAccordion"); + // maximum active radius 1960. + R_max_acc = parameters->GetValue("LArEMBFiducialRmax"); + // maximum active z (before subtracting edge for signal readout) + // currently 3150, should be changed in database to become 3164 + Z_max_acc = parameters->GetValue("LArEMBfiducialMothZmax"); + // minimum radius at z max for active region + R_min_highz=1548.; //FIXME should be taken from database + + // inactive thickness between S1 and S2 FIXME should be taken from database + Dr_s12=1.1; + + Eta_max_s1=1.4; // maximum eta region 0 + Eta_max_s3=1.325; // maximum eta for S3 in region 0 + deta=0.025; // basic granularity + + // values of the radial separations between samplings +#include "LArBarrelSampling.icc" + + // compute z edge taken by readout strips on the edge + + deltaz=7.; // this include copper 6mm + 2*0.5mm empty space on each side + + zmax1=Z_max_acc-deltaz; + zmax2=Z_max_acc-2.*deltaz; + zmax3=Z_max_acc-3.*deltaz; + zmax4=Z_max_acc-4.*deltaz; + zmax5=Z_max_acc-5.*deltaz; + zmax6=Z_max_acc-6.*deltaz; + zmax7=Z_max_acc-7.*deltaz; + rmax1=R_max_acc-deltaz; + rmax2=R_max_acc-2.*deltaz; + rmax3=R_max_acc-3.*deltaz; + rmax4=R_max_acc-4.*deltaz; + + + // maximum z at r=1500.024 + Z_max_lowr = sinh(Eta_max)*R_min_acc; + // slope of z vs r edge (which is not projective in eta...) + dzdr = (Z_max_acc-Z_max_lowr)/(R_min_highz-R_min_acc); + + // ATH_MSG_VERBOSE("Initialization of SampSet "); + // ATH_MSG_VERBOSE(" Rmin/Rmax " << R_min_acc << " " << R_max_acc); + // ATH_MSG_VERBOSE(" Zmax/Zmax_lowR " << Z_max_acc << " " << Z_max_lowr); + // ATH_MSG_VERBOSE(" Rmin_highz " << R_min_highz); + // ATH_MSG_VERBOSE(" dzdr " << dzdr); + + FILL=false; + }; + + // iactive = 1 if active region, 0 if region considered as inactive + G4int iactive = 1; + + const G4double aeta=std::fabs(eta); + + G4double r12=-1.; + G4double r23=-1.; + + // Not used: G4double rmax=Z_max_acc/sinh(aeta); + + G4int istrip,imid; + + // eta < 1.4 + + if (aeta<Eta_max_s1) { + + // get radius for end of strips + istrip=(int) (aeta/deta*8.); + if (istrip<0 || istrip >=448) { + ATH_MSG_ERROR(" Problem aeta,istrip " << aeta << " " << istrip); + return 0; + } + r12=Rmax1[istrip]; + + // get radius for end of middle + imid = (int) (aeta/deta); + if (imid <0 || imid >=56) { + ATH_MSG_ERROR(" Problem aeta,imid " << aeta << " " << imid); + return 0; + } + r23=Rmax2[imid]; + + iregion=0; + + // strips + if (radius <= r12) { + isampling=1; + ieta=istrip; + if (ieta==0) iactive=0; + isamp2=1; + ieta2=istrip; + } + + // region between strips and middle => not active, same identifier as strips + else if (radius < (r12+Dr_s12)) { + isampling=1; + ieta=istrip; + iactive=0; + isamp2=1; + ieta2=istrip; + } + + else { + + // eta<1.325, we can be in the back + if (aeta<Eta_max_s3) { + // radius<r23 we are in the middle + if (radius <= r23) { + isampling=2; + ieta=imid; + isamp2=2; + ieta2=imid; + } + // for radius >r23 we have to take care of the readout strips at high z + // and attribute some of the energy to other cells + else { // radius>r23 + if (z>zmax1) { + isampling=2; + ieta=55; + } + else if (z>zmax2) { + isampling=2; + ieta=54; + } + else if (z>zmax3) { + isampling=2; + ieta=53; + } + else if (z>zmax4) { + isampling=3; + ieta=26; + } + else if (aeta<1.3 && z>zmax5) { + isampling=2; + ieta=52; + } + else if (aeta<1.3 && z>zmax6) { + isampling=2; + ieta=51; + } + else if (radius>rmax4 && z<zmax5 && aeta>1.2) { + if (radius>rmax1) { + isampling=2; + ieta=51; + } + else if(radius>rmax2) { + isampling=3; + ieta=25; + } + else if (radius>rmax3) { + if (z<zmax7) { + isampling=2; + ieta=50; + } + else { + isampling=3; + ieta=25; + } + } + else { + if (aeta<1.25) { + isampling=2; + ieta=49; + } + else { + isampling=3; + ieta=25; + } + } + } + // normal back cell + else { + isampling=3; + ieta=imid/2; + isamp2=3; + ieta2=ieta; + } + isamp2=3; + ieta2=imid/2; + } // end radius>r23 + // put into middle energy deposited along readout strips across the back + if (isampling==3 && z<zmax4 && (radius<rmax4 || aeta<1.2) ) { + const double etastr = (imid%2==0) ? 0.025*imid : 0.025*(imid+1); + const double delta=radius*(sinh(etastr)-sinh(aeta))/cosh(etastr); + double deltastr; + if (aeta<0.475) { deltastr=1.5;} + else if (aeta<0.80) { deltastr=2.75;} + else if (aeta<0.85) { deltastr=1.5;} + else if (aeta<1.1) { deltastr=2.75;} + else { deltastr=3.25;} + + if (std::fabs(delta)<deltastr) { + isampling=2; + ieta=imid; + } + } // end if sampling==3 + } // end if eta<1.325 + else { + isampling=2; + ieta=imid; + if (z>zmax1) { + ieta=55; + } + else if (z>zmax2 && aeta<1.375) { + ieta=54; + } + isamp2=2; + ieta2=imid; + } // end eta>1.352 + } // end radius selection + } // end eta1.4 + + // eta between 1.4 and 1.475 + + if (aeta>=Eta_max_s1 && aeta<Eta_max) { + r12 = Rmax1[447]; // radius for end of sampling 1 + r23=Z_max_acc/sinh(aeta); // radius of end of sampling 2, bounded by high z end + + const double zmax = Z_max_lowr + dzdr*(radius-R_min_acc); + + iregion=1; + if (radius <=r12) { + isampling=1; + ieta=int((aeta-Eta_max_s1)/deta); + if (z>zmax) { iactive=0; } + } + else if (radius < (r12+Dr_s12)) { + isampling=1; + ieta=int((aeta-Eta_max_s1)/deta); + iactive=0; + } + else if (radius <= r23) { + isampling=2; + ieta=0; + if (z>zmax) { iactive=0; } + } + else { + isampling=2; + ieta=0; + iactive=0; + } + isamp2=isampling; + ieta2=ieta; + } + // eta above 1.475, not fiducial region, but still returns something + // for calibration hits + if (aeta>Eta_max) { + iregion=1; + r12 = Rmax1[447]; + if (radius <=r12) { + isampling=1; + ieta=2; + } + else { + isampling=2; + ieta=0; + } + isamp2=isampling; + ieta2=ieta; + iactive=0; + } + + // cross-check of active region + if (z>Z_max_acc || radius>R_max_acc || radius<R_min_acc || aeta > Eta_max) iactive=0; + + return iactive; + } + // ======================================================================= + // function findCell + // + // compute cell in EM accordion for hit at position x,y,z,radius,eta,phi + // given in LOCAL half barrel coordinate system (Stac Geant volume) + // It has already been checked that the hit is in the accordion sensitive volume + // + + void Geometry::findCell(CalcData & currentCellData, + const double &xPosition, + const double &yPosition, + const double &zPosition, + const double &aRadius, + const double &anEta, + const double &/*aPhi*/, + const bool MapDetail) const + { + + currentCellData.cellID = 0; + + if (aRadius < m_rc[0] || aRadius >= m_rc[m_Nbrt1-1]) { +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" Outside Accordion " << aRadius << " " << m_rc[0] << " " << m_rc[m_Nbrt1-1]); +#endif + return; // outside accordion + } + + // set the straight section number + currentCellData.nstraight=0; + for (int i=1;i<m_Nbrt1;i++) { + if (m_rc[i] > aRadius) { break; } + currentCellData.nstraight++; + } + if (currentCellData.nstraight <0 || currentCellData.nstraight >= m_Nbrt) { + ATH_MSG_ERROR("Invalid straight number " << currentCellData.nstraight << " " << aRadius); + return; + } + + // get the closest fold number + currentCellData.nfold=currentCellData.nstraight; + if (std::fabs(aRadius-m_rc[currentCellData.nfold]) > std::fabs(aRadius-m_rc[currentCellData.nfold+1]) ) { + currentCellData.nfold +=1; + } + if (currentCellData.nfold <0 || currentCellData.nfold >= m_Nbrt1) { + ATH_MSG_ERROR("Invalid fold number " << currentCellData.nfold); + return; + } + + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" BarrelGeometry: radius,eta,phi " << aRadius << " " << anEta << " "); + ATH_MSG_VERBOSE(" Straight/Fold numbers " << currentCellData.nstraight << " " << currentCellData.nfold); +#endif + + // eta and longitudinal segmentations + G4int ireg,isamp,ieta,isamp2,ieta2; + currentCellData.cellID = this->SampSeg(anEta,aRadius,zPosition,ireg,isamp,ieta,isamp2,ieta2); + + currentCellData.etaBin = ieta; + currentCellData.sampling = isamp; + currentCellData.region = ireg; + currentCellData.etaMap = ieta2; + currentCellData.sampMap = isamp2; + + // compute electrode number in phi + int phicell = this->PhiGap(aRadius,xPosition,yPosition); + if (phicell<0) phicell=0; + // for test beam, some protection + if (m_NCellTot !=1024) { + if (phicell>=m_NCellTot) { + if (phicell<512) { phicell=m_NCellTot-1; } + else { phicell=0; } + currentCellData.cellID=0; + } + } + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" phigap " << phicell); +#endif + + // compute readout cell number + int sampling_phi_nGaps=4; + if (currentCellData.region==0 && currentCellData.sampling==1) { sampling_phi_nGaps=16; } + + if (currentCellData.cellID==0) { + currentCellData.phiBin = (G4int) ( phicell/sampling_phi_nGaps ); + currentCellData.distElec=9999.; + return; + } + + // compute distance to electrode + G4double xl; + G4int nstr = currentCellData.nstraight; + const G4double distElec = this->Distance_Ele(xPosition,yPosition,phicell,nstr,currentCellData.nfold,xl); + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" distElec " << distElec); +#endif + + // if distance is < 2.5mm we are sure to be in the correct gap + if (std::fabs(distElec) > 2.5) { + // try +-2 electrode in phi to get minimum distance + double dElecMin=distElec; + double xlmin=xl; + int phicellmin=phicell; + for (int ii=-2;ii<3;ii++) { + if (ii==0) { continue; } + int phicellnew = phicell+ii; + // for test beam no phi wrapping + if (m_NCellTot != 1024 && ( phicellnew<0 || phicellnew >= m_NCellTot)) { continue; } + if (phicellnew < 0) { phicellnew += m_NCellTot; } + if (phicellnew >= m_NCellTot) { phicellnew -= m_NCellTot; } + double xln; + int nstr2=currentCellData.nstraight; + double dElec = Distance_Ele(xPosition,yPosition,phicellnew,nstr2,currentCellData.nfold,xln); + if (std::fabs(dElec)<std::fabs(dElecMin)) { + phicellmin=phicellnew; + xlmin=xln; + dElecMin = dElec; + nstr=nstr2; + } + } + currentCellData.phiGap = phicellmin; + currentCellData.distElec = dElecMin; + currentCellData.xl = xlmin; + currentCellData.nstraight = nstr; + } // end distance >2.5mm + else { + currentCellData.phiGap=phicell; + currentCellData.distElec=distElec; + currentCellData.xl=xl; + currentCellData.nstraight=nstr; + } + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" final phiGap,distElec,xl " << currentCellData.phiGap << " " << currentCellData.distElec << " " + << currentCellData.xl); +#endif + + // compute distance to absorber + + G4int nabs; + if (currentCellData.distElec<0) nabs=currentCellData.phiGap; + else nabs=currentCellData.phiGap+1; + if (nabs >= m_NCellMax) nabs -= m_NCellMax; + currentCellData.distAbs = Distance_Abs(xPosition,yPosition,nabs,currentCellData.nstraight,currentCellData.nfold); +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" nabs,distAbs " << nabs << " " << currentCellData.distAbs); +#endif + + // in some rare cases near fold, the closest distance could give the wrong gap + // in such case, the signs of distAbs and distElec are not opposite as they should + if ((currentCellData.distAbs>0. && currentCellData.distElec>0) || + (currentCellData.distAbs<0. && currentCellData.distElec<0) ) { + // ATH_MSG_VERBOSE("distElec and distAbs same sign " << currentCellData.distElec << " " << currentCellData.distAbs); + // ATH_MSG_VERBOSE(" currentCellData.phiGap " << currentCellData.phiGap); + if (std::fabs(currentCellData.distElec)>std::fabs(currentCellData.distAbs)) { + if (currentCellData.distAbs>0) { currentCellData.phiGap += 1; } + if (currentCellData.distAbs<0) { currentCellData.phiGap -= 1; } + if (m_NCellTot != 1024) { + if (currentCellData.phiGap <0) { currentCellData.phiGap=0; } + if (currentCellData.phiGap >= m_NCellTot) { currentCellData.phiGap = m_NCellTot-1; } + } + else { + if (currentCellData.phiGap < 0) { currentCellData.phiGap += m_NCellTot; } + if (currentCellData.phiGap >= m_NCellTot) { currentCellData.phiGap -= m_NCellTot; } + } + currentCellData.distElec = Distance_Ele(xPosition,yPosition,currentCellData.phiGap,currentCellData.nstraight,currentCellData.nfold,currentCellData.xl); + // ATH_MSG_VERBOSE(" new phiGap,distElec " << currentCellData.phiGap << " " << currentCellData.distElec); + } + } + + currentCellData.phiBin = (G4int) ( currentCellData.phiGap/sampling_phi_nGaps ); + + if (MapDetail) { + // compute x0,y0 coordinates in local electrode frame, using closest fold + // as reference + const G4double alpha = m_coudeelec->PhiRot(currentCellData.nfold,currentCellData.phiGap); + const G4double dx=xPosition-m_coudeelec->XCentCoude(currentCellData.nfold,currentCellData.phiGap); + const G4double dy=yPosition-m_coudeelec->YCentCoude(currentCellData.nfold,currentCellData.phiGap); + const G4double dx1=dx*cos(alpha)-dy*sin(alpha); + const G4double dy1=dx*sin(alpha)+dy*cos(alpha); + currentCellData.x0 = dx1 + m_xc[currentCellData.nfold]; + currentCellData.y0 = dy1 + m_yc[currentCellData.nfold]; + if (m_parity==1) { currentCellData.y0 = -1*currentCellData.y0; } + } + + + } // end of findCell method + + // ============================================================================= + // initialize phi0 vs radius of first absorber (for gam=0) + void Geometry::GetRphi() + { + const G4double dl=0.001; + const G4double inv_dl = 1. / dl; + G4double cenx[15],ceny[15]; + G4double xl,xl2; + G4double sum1[5000],sumx[5000]; + xl=0; + xl2=0.; + m_NRphi=5000; + m_Rmin=1500.; + m_dR=0.10; + m_Rmax=0.; + + m_2pi = 2.*M_PI; + + const G4double rint= m_rint_eleFib; + const G4double inv_rint = 1. / rint; + const G4double dt=dl * inv_rint; + const G4double inv_dt = 1. / dt; + + for (G4int i=0;i<m_NRphi;i++) { + sum1[i]=0.; + sumx[i]=0.; + } + for (G4int i=0;i<15;i++) { + cenx[i]=m_rc[i]*cos(m_phic[i]); + ceny[i]=m_rc[i]*sin(m_phic[i]); + } + + for (G4int i=0; i<15; i++) { + + // fold + G4double phi0,phi1; + if (i==0) { + // first fold goes up + if (m_parity==0) { + phi0=-CLHEP::pi/2.; + phi1=-m_delta[0]; + } + // first fold goes down + else { + phi0=m_delta[0]; + phi1=CLHEP::pi/2; + } + } + else if (i==14) { + if (m_parity==0) { + phi0=-CLHEP::pi+m_delta[13]; + phi1=-CLHEP::pi/2.; + } + else { + phi0=CLHEP::pi/2; + phi1=CLHEP::pi - m_delta[13]; + } + } + else { + if (i%2==(1-m_parity)) { + phi0=m_delta[i]; + phi1=CLHEP::pi-m_delta[i-1]; + } + else { + phi0=-CLHEP::pi+m_delta[i-1]; + phi1=-m_delta[i]; + } + } + xl2+=rint*std::fabs(phi1-phi0); + const G4int nstep=int((phi1-phi0)*inv_dt)+1; + for (int ii=0;ii<nstep;ii++) { + xl+=dl; + const G4double phi=phi0+dt*((G4double)ii); + const G4double x=cenx[i]+rint*cos(phi); + const G4double y=ceny[i]+rint*sin(phi); + const G4double radius=sqrt(x*x+y*y); + if (radius>m_Rmax) { m_Rmax=radius; } + const G4double phid=atan(y/x); + const G4int ir=((int) ((radius-m_Rmin)/m_dR) ); + if (ir>=0 && ir < m_NRphi) { + sum1[ir]+=1.; + sumx[ir]+=phid; + } + } + + // straight section + if (i<14) { + const G4double dx=cenx[i+1]-cenx[i]; + const G4double dy=ceny[i+1]-ceny[i]; + const G4double along=std::sqrt(dx*dx+dy*dy-4.*rint*rint); + const G4double x0=0.5*(cenx[i+1]+cenx[i]); + const G4double y0=0.5*(ceny[i+1]+ceny[i]); + const G4double phi = (i%2==m_parity) ? CLHEP::pi/2-m_delta[i] : -CLHEP::pi/2.+m_delta[i]; + const G4double x1=x0-0.5*along*cos(phi); + const G4double y1=y0-0.5*along*sin(phi); + xl2+=along; + const int nstep=int(along*inv_dl)+1; + for (int ii=0;ii<nstep;ii++) { + xl+=dl; + const G4double x=x1+dl*((G4double)ii)*cos(phi); + const G4double y=y1+dl*((G4double)ii)*sin(phi); + const G4double radius=sqrt(x*x+y*y); + if (radius>m_Rmax) { m_Rmax=radius; } + const G4double phid=atan(y/x); + const G4int ir=((int) ((radius-m_Rmin)/m_dR) ); + if (ir>=0 && ir < m_NRphi) { + sum1[ir]+=1.; + sumx[ir]+=phid; + } + } + } + } + // ATH_MSG_VERBOSE("total electrode lenght " << xl << " " << xl2); + // ATH_MSG_VERBOSE("rmax in accordion " << m_Rmax); + for (int i=0; i<m_NRphi; i++) { + if (sum1[i]>0) { + m_Rphi[i]=sumx[i]/sum1[i]; + // Not used: + //G4double radius = m_Rmin + ((G4double(i))+0.5)*m_dR; + //ATH_MSG_VERBOSE(" GUTEST r,phi0 " << radius << " " << m_Rphi[i]); + } + else { m_Rphi[i]=0.; } + } + } + + // ====================================================================================== + // phi of first absorber as function of radius for nominal accordion geometry + // (before sagging) + G4double Geometry::Phi0(G4double radius) const + { + // TODO This function could be simplified. + G4int ir; + if (radius < m_Rmin) { ir=0; } + else { + if (radius > m_Rmax) radius=m_Rmax-0.0001; + ir=((int) ((radius-m_Rmin)/m_dR) ); + } + return m_Rphi[ir]; + } + + // ====================================================================================== + // compute number (0 to 1023) of closest electrode according to nominal + // accordion geometry + G4int Geometry::PhiGap(const double & radius, const double & xhit, const double &yhit) const + { + const G4double phi0=Phi0(radius)+m_gam0; // from -pi to pi + const G4double phi_hit=atan2(yhit,xhit); // from -pi to pi + G4double dphi=phi_hit-phi0; + // bring back to 0-2pi + if (dphi<0) dphi=dphi+m_2pi; + if (dphi>=m_2pi) dphi=dphi-m_2pi; + dphi=dphi/(m_2pi)*1024; + const G4int ngap=((int) dphi); +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" phi0 " << phi0 << " dphi, ngap " << dphi << " " << ngap); +#endif + return ngap; + } + + //=================================================================================== + // full cell id computation starting from an arbitrary G4 step + + LArG4Identifier Geometry::CalculateIdentifier(const G4Step* a_step) const + { + + // The default result is a blank identifier. + LArG4Identifier result = LArG4Identifier(); + + // Get all the required information from the current step + const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); + const G4int ndep = g4navigation->GetDepth(); + bool inSTAC = false; + int zside=1; + G4int indECAM = -999; + + // Now navigate through the volumes hierarchy + for (G4int ii=0;ii<=ndep;ii++) { + const G4String& vname = g4navigation->GetVolume(ii)->GetName(); + // FIXME Need to find a way to avoid these string-comparisons + if ( indECAM<0 && vname == m_ecamName ) indECAM=ii; + if ( !inSTAC && vname.find("STAC") !=std::string::npos) inSTAC=true; + if ( vname.find("NegPhysical") != std::string::npos) zside=-1; + } + if (indECAM>=0) + result = this->CalculateECAMIdentifier( a_step , indECAM, inSTAC, zside) ; + else + ATH_MSG_ERROR("LArBarrel::Geometry::CalculateIdentifier ECAM volume not found in hierarchy"); + + return result; + } + + //====================================================================================== + // + // The following method computes the identifiers in the ECAM volume: + // (including dead material identifier) + // + // 1) Tranformation into LOCAL half barrel frame + // + // 2) Check if the hit is in the fiducial region (EM accordion, no presampler) + // fiducial range: 1500.24 < r < 1960.00 mm + // |eta| < 1.475 + // 4 < z < 3164 mm (in local half barrel coordinates) + // + // 3) If the hit is in the fiducial region standard identifier are filled + // + // 4) If the hit is outside the fiduacial region calibration hits are filled + // + // CaloDM_ID identifier for the barrel: + // + // detector_system/subdet/type/sampling/region/eta/phi + // + // * For hits with radius < 1500.24 + // ****************************** + // + // detector system = 10 -> Calorimeters + // subdet = +/-4 -> LAr dead materials + // type = 1 -> dead materials outside accordion and active presampler layers + // sampling = 1 -> dead materials in front and in active LAr calorimeters (starting from front warm + // cryostat walls) + // regions: = 3 -> all materials from the active layer of the barrel presampler to the active layer + // of accordion, 0 < |eta| < 1.5 + // + // ---> Granularity : deta 0.1 granularity within region + // dphi pi/32 ~ 0.1 granularity within region + // + // * For hits with radius > 1960.00 + // ****************************** + // + // detector system = 10 -> Calorimeters + // subdet = +/-4 -> LAr dead materials + // type = 1 -> dead materials outside accordion and active presampler layers + // sampling = 2 -> dead materials between active LAr calorimeters and Tile calorimeters or HEC-2 wheels + // regions: = 0 -> all materials behind the active layer of accordion in front the Tile barrel + // for |eta| < 1.0 + // =2 -> all materials in front of the scintillator and behind the active layer of accordion + // for 1.0 < |eta| < 1.5 + // + // ---> Granularity : deta 0.1 granularity within region + // dphi pi/32 ~ 0.1 granularity within region + // + //====================================================================================== + + LArG4Identifier Geometry::CalculateECAMIdentifier(const G4Step* a_step, const G4int indECAM, const bool inSTAC, int zside) const + { + + LArG4Identifier result = LArG4Identifier();; + + // Get all the information about the step + + const G4StepPoint *thisStepPoint = a_step->GetPreStepPoint(); + const G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint(); + const G4ThreeVector startPoint = thisStepPoint->GetPosition(); + const G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); + const G4ThreeVector p = (thisStepPoint->GetPosition() + thisStepBackPoint->GetPosition()) * 0.5; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Position of the step in the ATLAS frame (x,y,z) --> " << p.x() << " " << p.y() << " " << p.z()); + ATH_MSG_VERBOSE("Eta and Phi in the ATLAS frame --> " << p.eta() << " " << p.phi()); +#endif + + // BACK directly into the LOCAL half_Barrel. All the variables in this LOCAL framework get the SUFFIX Zpos + + const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); + const G4AffineTransform transformation = g4navigation->GetTransform(indECAM); + const G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); + const G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint); + const G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Position of the step in the LOCAL frame (x,y,z) --> " << midinLocal.x() << " " << midinLocal.y() << " " << midinLocal.z()); + ATH_MSG_VERBOSE("Eta and Phi of the step in LOCAL frame --> " << midinLocal.eta() << " " << midinLocal.phi()); +#endif + + // coordinates in the local frame + + const G4double xZpos = midinLocal.x(); + const G4double yZpos = midinLocal.y(); + const G4double zZpos = midinLocal.z(); + const G4double etaZpos = midinLocal.pseudoRapidity(); + const G4double phiZpos = (midinLocal.phi()<0.) ? midinLocal.phi() + 2.*M_PI : midinLocal.phi(); + const G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos; + const G4double radiusZpos = sqrt(radius2Zpos); + + CalcData currentCellData; + if (m_testbeam) { + currentCellData.zSide = 1; + } + else { + currentCellData.zSide = zside; + } + + // Check if the hit is in the fiducial range and in the STAC volume + // if yes this is active or inactive material + + if (inSTAC && radiusZpos >=m_rMinAccordion && radiusZpos <= m_rMaxAccordion && + zZpos <= m_zMaxBarrel && zZpos >= m_zMinBarrel && etaZpos <= m_etaMaxBarrel) { + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("This hit is in the STAC volume !!!!! "); +#endif + + // DETERMINATION of currentCellData.cellID, + // currentCellData.zSide, currentCellData.sampling, + // currentCellData.phiBin, currentCellData.etaBin, + // m_stackNumID + const bool MapDetail(false); + this->findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail ); + + // adjust phi in the negative half barrel frame + + if( currentCellData.zSide == -1 ) + { + if( currentCellData.sampling == 1 && currentCellData.region ==0 ) + { + currentCellData.phiBin = 31 - currentCellData.phiBin; + if(currentCellData.phiBin < 0 ) currentCellData.phiBin += 64; + } + if( currentCellData.sampling == 1 && currentCellData.region ==1 ) + { + currentCellData.phiBin = 127 - currentCellData.phiBin; + if(currentCellData.phiBin < 0 ) currentCellData.phiBin += 256; + } + if( currentCellData.sampling >= 2 ) + { + currentCellData.phiBin = 127 - currentCellData.phiBin; + if(currentCellData.phiBin < 0 ) currentCellData.phiBin += 256; + } + } + + // there are few hundred microns between the 4mm nominal beginning of the active region + // and the real beginning of the first strip at eta=0.025/8 + // to avoid inactive energy with strip=0 assign this to strip=1 + if (currentCellData.sampling==1 && currentCellData.region==0 && currentCellData.etaBin==0) { + currentCellData.etaBin=1; + } + + result << 4 // LArCalorimeter + << 1 // LArEM + << currentCellData.zSide + << currentCellData.sampling + << currentCellData.region + << currentCellData.etaBin + << currentCellData.phiBin; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Here the identifier for the barrel ACTIVE ----> "); + ATH_MSG_VERBOSE("eta in local frame --> " << etaZpos); + ATH_MSG_VERBOSE("currentCellData.zSide ----> " << currentCellData.zSide); + ATH_MSG_VERBOSE("currentCellData.sampling ----> " << currentCellData.sampling); + ATH_MSG_VERBOSE("currentCellData.region ----> " << currentCellData.region); + ATH_MSG_VERBOSE("currentCellData.etaBin ----> " << currentCellData.etaBin); + ATH_MSG_VERBOSE("currentCellData.phiBin ----> " << currentCellData.phiBin); + ATH_MSG_VERBOSE("And also etafirst ----> " << thisStepPoint->GetPosition().pseudoRapidity()); +#endif + + // if (!Geometry::CheckLArIdentifier(currentCellData.sampling,currentCellData.region,currentCellData.etaBin,currentCellData.phiBin)) { + // ATH_MSG_ERROR(" ** Bad LAr identifier " << currentCellData.sampling << " " << currentCellData.region << " " + // << currentCellData.etaBin << " " << currentCellData.phiBin); + // ATH_MSG_ERROR(" x,y,z,eta,phi " << xZpos << " " << yZpos << " " << zZpos + // << " " << radiusZpos << " " << etaZpos << " " << phiZpos); + // } + + + } + // hits in dead material part + else { + + G4int sampling=0; + G4int region=0; + const G4int numDeadPhiBins = 64; + double abs_eta = std::fabs(etaZpos); + const double DM1EtaWidth = 0.1 ; + const double DM1PhiWidth = 2.*M_PI / numDeadPhiBins ; + currentCellData.etaBin = (G4int) ( abs_eta * (1./DM1EtaWidth) ) ; + currentCellData.phiBin = (G4int) (phiZpos/ DM1PhiWidth ); + G4int type=1; + // protect against rounding error for phi ~2pi + if (currentCellData.phiBin==numDeadPhiBins) currentCellData.phiBin=currentCellData.phiBin-1; + + // adjust phi for negative half barrel + + if ( currentCellData.zSide == -1 ) { + currentCellData.phiBin = 31 - currentCellData.phiBin; + if (currentCellData.phiBin < 0 ) currentCellData.phiBin +=64 ; + } + + // material in front of the active accordion + if ( radiusZpos < m_rMinAccordion ) { + sampling =1 ; + region = 3 ; + if (currentCellData.etaBin > 14) currentCellData.etaBin=14; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("This hit is in the ECAM volume in front of the accordion (DEAD MATERIAL) !!!!! "); +#endif + + } else if (radiusZpos >= m_rMaxAccordion){ // material behind the active accordion + sampling = 2; + + if (abs_eta < 1.0 ) { + region = 0 ; +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("This hit is in the ECAM volume behind accordion (DEAD MATERIAL 0) !!!!! "); +#endif + } else if ( abs_eta >= 1.0 && abs_eta < 1.5) { + region = 2; + currentCellData.etaBin = currentCellData.etaBin - 10; // to have etabin between 0 and 4 +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("This hit is in the ECAM volume behind accordion (DEAD MATERIAL 2) !!!!! "); +#endif + } else { + ATH_MSG_ERROR(" LArBarrelGeometry: hit behind accordion at eta>1.5 !!! "); + region = 2; + currentCellData.etaBin = 4; + } + + } else if (zZpos <= m_zMinBarrel) { // inactive matter between two EMB halves + type=2; + region=0; + const G4int phisave=currentCellData.phiBin; + const G4bool MapDetail(false); + this->findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail ); + sampling = currentCellData.sampling; // sampling as in normal definition + currentCellData.etaBin=0; + currentCellData.phiBin=phisave; + + } else if (zZpos >= m_zMaxBarrel || abs_eta >= 1.40) { // inactive matter between EMB and scintillator + if (abs_eta >1.0 && abs_eta < 1.5) { + sampling=2; + region=2; + currentCellData.etaBin = currentCellData.etaBin - 10; // to have etabin between 0 and 4 + } else if (abs_eta < 1.6) { + sampling=1; + region=4; + currentCellData.etaBin=0; + } else { + ATH_MSG_ERROR(" LArBarrelGeometry: hit at eta>1.6 !!! "); + sampling=1; + region=4; + currentCellData.etaBin=0; + } + } else { + if (!m_testbeam) { + ATH_MSG_ERROR("LArBarrelGeometry: cannot find region for DM hit..."); + ATH_MSG_ERROR("r,z,eta,phi " << radiusZpos << " " << zZpos << " " << etaZpos << " " << phiZpos); + ATH_MSG_ERROR("x,y,z (Atlas) " << p.x() << " " << p.y() << " " << p.z()); + ATH_MSG_ERROR(" inSTAC " << inSTAC); + const G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit(); + ATH_MSG_ERROR(" eDeposited " << thisStepEnergyDeposit); + const G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume(); + const G4String volName = vol->GetName(); + ATH_MSG_ERROR(" volName " << volName); + const G4int ndep = g4navigation->GetDepth(); + for (G4int ii=0;ii<=ndep;ii++) { + const G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); + const G4String vname = v1->GetName(); + ATH_MSG_ERROR("vname " << vname); + } + + } + // in test beam case, we can get there for leakage on the side (in phi) of the module + // in this case, we attribute an identifier like inactive material + else + { + G4bool MapDetail=false; + this->findCell( currentCellData, xZpos, yZpos, zZpos, radiusZpos, etaZpos, phiZpos, MapDetail ); + // ATH_MSG_ERROR(" Lateral lakage r,eta,phi " << radiusZpos << " " << etaZpos << " " + // << phiZpos << " sampling/region/eta/phi " << currentCellData.sampling << " " << + // currentCellData.region << " " << currentCellData.etaBin << " " << currentCellData.phiBin); + // protect against small space between z=4m and real beginning of ieta=1 in strips + if (currentCellData.sampling==1 && currentCellData.region==0 && currentCellData.etaBin==0) { + currentCellData.etaBin=1; + // ATH_MSG_ERROR("S1R0 etabin 0 found r,z,phi local " << radiusZpos << " " + // << " " << zZpos << " " << phiZpos); + } + result << 4 // LArCalorimeter + << 1 // LArEM + << currentCellData.zSide + << currentCellData.sampling + << currentCellData.region + << currentCellData.etaBin + << currentCellData.phiBin; + return result; + } + } + + result << 10 // LArCalorimeter + << currentCellData.zSide * 4 // LArBarrel + << type + << sampling + << region + << currentCellData.etaBin + << currentCellData.phiBin; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Here the identifier for the barrel DEAD materials ---->"); + ATH_MSG_VERBOSE("Type ----> " << type); + ATH_MSG_VERBOSE("Sampling ----> " << sampling); + ATH_MSG_VERBOSE("Region ----> " << region); + ATH_MSG_VERBOSE("zSide ----> " << currentCellData.zSide*4); + ATH_MSG_VERBOSE("etaBin ----> " << currentCellData.etaBin); + ATH_MSG_VERBOSE("phiBin ----> " << currentCellData.phiBin); +#endif + + // if (!Geometry::CheckDMIdentifier(type,sampling,region,currentCellData.etaBin,currentCellData.phiBin)) { + // ATH_MSG_ERROR(" ** Bad DM identifier " << type << " " << sampling << " " << region << " " + // << currentCellData.etaBin << " " << currentCellData.phiBin); + // ATH_MSG_ERROR("x,y,z,r,eta,phi" << xZpos << " " << yZpos << " " << zZpos << + // " " << radiusZpos << " " << etaZpos << " " << phiZpos); + // } + + } + + return result; + + } + + bool Geometry::CheckDMIdentifier(int type, int sampling, int region, int eta, int phi) const + { + + if (type <1 || type > 2) return false; + if (type==1) { + if (sampling<1 || sampling>2) return false; + if (sampling==1) { + if (region!=3 && region !=4) return false; + if (phi<0 || phi>63) return false; + if (region==3) { + if (eta<0 || eta>14) return false; + } + if (region==4) { + if (eta !=0) return false; + } + } + if (sampling==2) { + if (region !=0 && region !=2) return false; + if (phi<0 || phi>63) return false; + if (region==0){ + if (eta<0 || eta>9) return false; + } + if (region==2) { + if (eta<0 || eta>4) return false; + } + } + } + if (type==2) { + if (sampling<1 || sampling >3) return false; + if (region !=0) return false; + if (eta!=0) return false; + if (phi<0 || phi>63) return false; + } + return true; + } + + + bool Geometry::CheckLArIdentifier(int sampling, int region, int eta, int phi) const + { + if (sampling<0 || sampling >3) return false; + if (sampling==0) { + if (region!=0) return false; + if (eta<0 || eta>60) return false; + if (phi<0 || phi>63) return false; + } + if (sampling==1) { + if (region<0 || region >1) return false; + if (region==0) { + if (eta<1 || eta>447) return false; + if (phi<0 || phi>63) return false; + } + if (region==1) { + if (eta<0 || eta>2) return false; + if (phi<0 || phi>255) return false; + } + } + if (sampling==2) { + if (region<0 || region >1) return false; + if (region==0) { + if (eta<0 || eta>55) return false; + if (phi<0 || phi>255) return false; + } + if (region==1) { + if (eta!=0) return false; + if (phi<0 || phi>255) return false; + } + } + if (sampling==3) { + if (region !=0) return false; + if (eta<0 || eta>26) return false; + if (phi<0 || phi>255) return false; + } + return true; + } + + } //end of Barrel namespace + +} // end of LArG4 namespace diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.h new file mode 100644 index 000000000000..186ee18178c4 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelGeometry.h @@ -0,0 +1,143 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArBarrelGeometry.hh + +#ifndef LARG4BARREL_LARBARRELGEOMETRY_H +#define LARG4BARREL_LARBARRELGEOMETRY_H + +#include "ILArBarrelGeometry.h" +#include "AthenaBaseComps/AthService.h" + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArVG4DetectorParameters.h" +#include "G4ThreeVector.hh" +#include "G4StepPoint.hh" +#include "G4Step.hh" +#include "G4LogicalVolume.hh" +#include "G4LogicalVolumeStore.hh" +#include "G4TouchableHistory.hh" + +#include <string> + +// Forward declarations. +class LArG4Identifier; +class G4Step; +class LArCoudeElectrodes; +class LArCoudeAbsorbers; +class LArStraightAbsorbers; +class LArStraightElectrodes; + +namespace LArG4 { + + namespace Barrel { + + class Geometry: public AthService, virtual public ILArBarrelGeometry { + + public: + + //constructor + Geometry(const std::string& name, ISvcLocator * pSvcLocator); + + virtual ~Geometry() { }; + + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; + + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + + // Full identifier computation from a G4 step + virtual LArG4Identifier CalculateIdentifier( const G4Step* ) const override final; + + // Given a point compute all quantities (cell number, distance to electrode, etc...) + virtual void findCell( CalcData & currentCellData, const double & x, const double & y, const double & z, + const double & r, const double & eta, const double & phi, const bool detail) const override final; + + private: + + LArG4Identifier CalculateECAMIdentifier( const G4Step* , const G4int indEcam, const bool inSTAC=true,int zside=1) const; + bool CheckLArIdentifier(int sampling,int region, int eta,int phi) const; + bool CheckDMIdentifier(int type, int sampling, int region, int eta, int phi) const; + + // detector name, for translated geometry + std::string m_detectorName; + G4String m_ecamName; + + // global EMBarrel dimensions + double m_rMinAccordion; + double m_rMaxAccordion; + double m_zMinBarrel; + double m_zMaxBarrel; + double m_etaMaxBarrel; + + // GU 11/06/2003 total number of cells in phi + int m_NCellTot; // either 64 or 1024 for TestBeam or Atlas + int m_NCellMax; // 1024 + + // Accordion parameters + int m_Nbrt; // number of straight sections (=14) + int m_Nbrt1; // number of folds (=15) + + // Accordion parameters, refering to the neutral fibre + double m_gam0 ; //phi position for the first absorber neutral fiber + double m_rint_eleFib ; //2.78 + double *m_rc, *m_phic, *m_xc, *m_yc, *m_delta;// double m_rc[15] ; // R and + int m_parity; + //double m_phic[15] ; // phi positions of center of fold for first absorber + // double m_xc[15]; // corresponding x,y values + // double m_yc[15]; + //double m_delta[15]; // zig-zag angles + // to access G4 geometry + mutable LArCoudeElectrodes* m_coudeelec; // FIXME needed due to lazy initialization + mutable LArCoudeAbsorbers* m_coudeabs; // FIXME needed due to lazy initialization + mutable LArStraightElectrodes* m_electrode; // FIXME needed due to lazy initialization + mutable LArStraightAbsorbers* m_absorber; // FIXME needed due to lazy initialization + + // to handle small difference (mostly phi wrapping and +-z symmetry) + // between atlas and test beam + bool m_testbeam; + + bool m_iflSAG; + + // intermediate values for phi cell computation + G4int m_NRphi; + G4double m_Rmin; + G4double m_Rmax; + G4double m_Rphi[5000]; + G4double m_dR; + double m_2pi; + + // function to compute distance to electrode + double Distance_Ele(const double &x, const double &y, + const int &PhiC, int &Num_Straight, const int &Num_Coude, + double &xl) const; + // function to compute distance to absorber + double Distance_Abs(const double &x, const double &y, + const int &nabs, const int &Num_Straight, const int &Num_Coude) const; + + // longitudinal and eta segmentation of electrodes + G4int SampSeg(G4double,G4double,G4double,G4int&,G4int&,G4int&,G4int&,G4int&) const; + + /// phi vs r of first absorber in nominal geometry + + /// Initialize r-phi reference map (called from constructor) + void GetRphi(); + /// + G4double Phi0(G4double) const; + /// + G4int PhiGap(const double &, const double &, const double &) const; + + protected: + + Geometry(); + + + } ; + + } //end of Barrel namespace + +} // end of LArG4 namespace + +#endif // LARG4BARREL_LARBARRELGEOMETRY_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cc deleted file mode 100644 index e2e7ed18dffb..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cc +++ /dev/null @@ -1,392 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// Prepared 05-Dec-2002 Bill Seligman - -// A first pass at determing hit cell ID in the LAr barrel presampler. - -// Modified oct-2005 by Guillaume Unal to include current map for presampler - -#include "LArG4Barrel/LArBarrelPresamplerCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArG4BirksLaw.h" -#include "LArG4Barrel/LArBarrelPresamplerGeometry.h" -#include "LArG4RunControl/LArG4BarrelOptions.h" -#include "LArG4Barrel/PsMap.h" - -#include "G4AffineTransform.hh" -#include "G4NavigationHistory.hh" - -#include "G4ThreeVector.hh" -#include "G4StepPoint.hh" -#include "G4Step.hh" - -#include "G4ios.hh" -#include "globals.hh" - -#include <cmath> -#include <limits.h> - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" -#include "AthenaKernel/Units.h" - -namespace Units = Athena::Units; - -// #define DEBUGSTEP - -// Standard implementation of a singleton pattern. - -LArBarrelPresamplerCalculator* LArBarrelPresamplerCalculator::m_instance = 0; - -//============================================================================= -LArBarrelPresamplerCalculator* LArBarrelPresamplerCalculator::GetCalculator() -{ - if (m_instance == 0) - { - m_instance = new LArBarrelPresamplerCalculator(); - } - return m_instance; -} - -//============================================================================= -LArBarrelPresamplerCalculator::LArBarrelPresamplerCalculator() - : m_IflCur(true) - , m_birksLaw(NULL) - , m_nhits(0) - , m_detectorName("LArMgr") - , m_testbeam(false) -{ - - std::cout << "LArBarrelPresamplerCalculator: Beginning initialization " << std::endl; - // Initialize private members. - m_identifier2 = LArG4Identifier(); - - // Access source of detector parameters. - m_parameters = LArVG4DetectorParameters::GetInstance(); - - //Inizialize the geometry calculator - m_geometry = LArG4::BarrelPresampler::Geometry::GetInstance(); - - if (m_IflCur) - std::cout << " LArBarrelPresamplerCalculator: start reading current maps" << std::endl; - - if (m_IflCur) m_psmap = PsMap::GetPsMap(); - else m_psmap=0; - - // Get the out-of-time cut from the detector parameters routine. - m_OOTcut = m_parameters->GetValue("LArExpHallOutOfTimeCut"); - - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StoreGateSvc *detStore; - LArG4BarrelOptions *barrelOptions; - - StatusCode status = svcLocator->service("DetectorStore", detStore); - - if(status.isFailure()) - std::cout << "LArBarrelCalculator::LArBarrelCalculator() unable to get Detector Store! Using default values.\n"; - else { - status = detStore->retrieve(barrelOptions, "LArG4BarrelOptions"); - - if(status.isFailure()) - std::cout << "LArBarrelCalculator::LArBarrelCalculator() unable to get LArG4BarrelOptions! Using default values.\n"; - else { - - bool IflBirks = barrelOptions->EMBBirksLaw(); - if (IflBirks) { - const double Birks_LAr_density = 1.396; - const double Birks_k = barrelOptions->EMBBirksk(); - m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); - } - } - } - - if(m_birksLaw) { - std::cout << " LArBarrelPresamplerCalculator: Birks' law ON " << std::endl; - std::cout << " LArBarrelPresamplerCalculator: parameter k " << m_birksLaw->k() << std::endl; - } - else - std::cout << " LArBarrelPresamplerCalculator: Birks' law OFF" << std::endl; - - - - std::cout <<"End of LArBarrelPresamplerCalculator initialization " << std::endl; - -} - -//============================================================================== -LArBarrelPresamplerCalculator::~LArBarrelPresamplerCalculator() -{ - if (m_birksLaw) delete m_birksLaw; -} - - -// ============================================================================== -G4bool LArBarrelPresamplerCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) -{ - m_nhits = 0; - hdata.clear(); - m_isInTime.clear(); - -// check the Step content is non trivial - G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit(); - G4double thisStepLength = a_step->GetStepLength() / Units::mm; - G4double dstep = .1*Units::mm; // length of punctual charge for Current Option - -#ifdef DEBUGSTEP - std::cout << "****** LArBarrelPresamplerCalculator: Step energy,length " - << thisStepEnergyDeposit << " " << thisStepLength << std::endl; -#endif - if(thisStepEnergyDeposit <= 0. || thisStepLength <= 0.) - { - return false; - } - -// Get Step geometrical parameters (first and end) - G4StepPoint *thisStepPoint = a_step->GetPreStepPoint(); - G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = thisStepPoint->GetPosition(); - G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); - -#ifdef DEBUGSTEP - std::cout << " Global beginning step position " - << startPoint.x() << " " << startPoint.y() << " " - << startPoint.z() << std::endl; - std::cout << " Global end step position " - << endPoint.x() << " " << endPoint.y() << " " - << endPoint.z() << std::endl; -#endif - - -// find transformation to go inside local half presampler tube volume - - const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); - G4int ndep = g4navigation->GetDepth(); - G4bool testbeam=false; - G4int idep = -999; - -#ifdef DEBUGSTEP - std::cout << " Detector Name " << m_detectorName << std::endl; -#endif - - if(m_detectorName=="") - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - if (v1->GetName()=="LAr::Barrel::Presampler") idep=ii; // half barrel - if (v1->GetName()=="LAr::TBBarrel::Cryostat::LAr") testbeam=true; // TB or not ? - } - else - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); -#ifdef DEBUGSTEP - std::cout << " Level,VolumeName " << ii << " " << v1->GetName() << std::endl; -#endif - if (v1->GetName()==G4String(m_detectorName+"::LAr::Barrel::Presampler")) idep=ii; - if (v1->GetName()==G4String(m_detectorName+"::LAr::TBBarrel::Cryostat::LAr")) testbeam=true; // TB or not ? - } - -#ifdef DEBUGSTEP - std::cout << " idep = " << idep << std::endl; -#endif - - if (idep<0) { - std::cout << " LArBarrelPresamplerCalculator::Process Presampler volume not found !!" << std::endl; - return false; - } - -// transformation to go from global frame to LAr::Barrel::Presampler frame - const G4AffineTransform transformation = g4navigation->GetTransform(idep); - -// step beginning and end in local frame - G4ThreeVector startPointinLocal = - transformation.TransformPoint(startPoint); - G4ThreeVector endPointinLocal = - transformation.TransformPoint (endPoint); - -#ifdef DEBUGSTEP - std::cout << " Local beginning step position " - << startPointinLocal.x() << " " << startPointinLocal.y() << " " - << startPointinLocal.z() << std::endl; - std::cout << " Local end step position " - << endPointinLocal.x() << " " << endPointinLocal.y() << " " - << endPointinLocal.z() << std::endl; -#endif - -// compute number of sub steps -// = 1 if no charge collection -// otherwise 200 microns (dstep) division - - G4int nsub_step=1; - if (m_IflCur) nsub_step=(int) (thisStepLength*(1./dstep)) + 1; -// delta is fraction of step between two sub steps - G4double delta=1./((double) nsub_step); -#ifdef DEBUGSTEP - std::cout << " nsub_step,delta " << nsub_step << " " << delta << std::endl; -#endif - - G4double energy = a_step->GetTotalEnergyDeposit(); - if (m_birksLaw) { - const double EField = 10. ; // 10 kV/cm electric field in presampler gap - const double wholeStepLengthCm = a_step->GetStepLength() * (1./CLHEP::cm); - energy = (*m_birksLaw)(energy, wholeStepLengthCm, EField); - } - -// loop over sub steps - - -// share total step energy evenly in each sub step - energy = energy / ((float) (nsub_step)); - for (G4int i=0;i<nsub_step;i++) { - -#ifdef DEBUGSTEP - std::cout << " Energy for sub step " << energy << std::endl; -#endif - -// position for this substep - G4double fraction=(((G4double) i)+0.5)*delta; - G4ThreeVector subinLocal=startPointinLocal*(1-fraction) + endPointinLocal*fraction; - G4double xloc = subinLocal.x(); - G4double yloc = subinLocal.y(); - G4double zloc = subinLocal.z(); -// call geometry method to find cell from local position -// status = true if hit is in normal region (13mm LAr gap) -// this method fills the cell number as well as coordinates in the electrode frame - bool status = m_geometry->findCell(xloc,yloc,zloc); - -// check fiducical cuts - if (status) { - -// compute cell identifier - G4int zSide; - if (testbeam) - zSide = 1; - else - zSide = ( startPoint.z() > 0.) ? 1 : -1; - - G4int region = m_geometry->region(); - G4int etaBin = m_geometry->etaBin(); - G4int phiBin = m_geometry->phiBin(); - G4int sampling = m_geometry->sampling(); - - if( zSide == -1 ) - { -// following code for an Y-axis rotation to define Z < 0. Barrel part - phiBin = 31 - phiBin; - if(phiBin < 0 ) phiBin += 64; - } - -// check identifier - if (sampling !=0 || region != 0 || - etaBin <0 || etaBin > 60 || phiBin <0 || phiBin>63) continue; - -// fill identifier - m_identifier2.clear(); - m_identifier2 << 4 // LArCalorimeter - << 1 // LArEM - << zSide - << sampling - << region - << etaBin - << phiBin; - -// time computation is not necessarily correct for test beam - G4double time; - if (testbeam) - { - time=0.; - } - else - { - G4double tof; - tof = thisStepPoint->GetGlobalTime() / Units::ns; - time = tof - thisStepPoint->GetPosition().mag() * (1. / (CLHEP::c_light * CLHEP::ns)); - } - - G4double Current; - if (!m_IflCur) { -// no charge collection Current=E from Geant - Current=energy; - } - else { -// get module number and coordinates in electrode frame - G4int imodule = m_geometry->module(); - G4double x0 = m_geometry->distElec(); - G4double y0 = m_geometry->xElec(); -// full symmetry for angle=0 electrodes - if (imodule>1) { - x0=std::fabs(x0); - y0=std::fabs(y0); - } -// reduced symmetry (point symmetry around 0) for tilted electrodes - if (imodule==0 || imodule ==1) { - if (x0<0) { - x0=-1.*x0; - y0=-1.*y0; - } - } -#ifdef DEBUGSTEP - std::cout << " set current map for module " << imodule << std::endl; -#endif - m_psmap->SetMap(imodule); - if (!(m_psmap->Map())) { - std::cout << " LArBarrelPresamplerCalculator: cannot get map for module " << imodule << std::endl; - continue; - } - double current0,current1,current2,gap; - -// get information from current map - m_psmap->Map()->GetAll(x0,y0,&gap,¤t0,¤t1,¤t2); -#ifdef DEBUGSTEP - std::cout << " module,x0,y0,current0 from map " << imodule << " " << x0 << " " << y0 << " " << current0 << std::endl; -#endif - -// assume HV=2000 everywhere for the time being - Current = energy*current0; - - } - -// check if we have a new hit in a different cell, or if we add this substep -// to an already existing hit - G4bool found=false; - for (int j=0; j<m_nhits; j++) { - if (hdata[j].id==m_identifier2) { - hdata[j].energy += Current; - hdata[j].time += time*Current; - found=true; - break; - } - } // loop over hits - if (!found) { - m_nhits++; - LArHitData newdata = {m_identifier2, time*Current, Current}; - hdata.push_back(newdata); - m_isInTime.push_back(true); - } // hit was not existing before - - - } // hit fulfills fiducial cuts - } // end loop over sub steps - -#ifdef DEBUGSTEP - std::cout << "Number of hits for this step " << m_nhits << " " - << hdata.size() << std::endl; -#endif - -// finalise time computations - for (int i=0;i<m_nhits;i++) { - if (std::fabs(hdata[i].energy)>1e-6) hdata[i].time=hdata[i].time/hdata[i].energy; - else hdata[i].time=0.; - if (std::fabs(hdata[i].time)> m_OOTcut) m_isInTime[i]=false; -#ifdef DEBUGSTEP - std::cout << "Hit Energy/Time " - << hdata[i].energy << " " << hdata[i].time << std::endl; -#endif - } - - if (m_nhits>0) return true; - else return false; - -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx new file mode 100644 index 000000000000..987c3f4b47ab --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.cxx @@ -0,0 +1,369 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Prepared 05-Dec-2002 Bill Seligman + +// A first pass at determing hit cell ID in the LAr barrel presampler. + +// Modified oct-2005 by Guillaume Unal to include current map for presampler + +#include "LArBarrelPresamplerCalculator.h" +#include "LArG4Code/LArVG4DetectorParameters.h" +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArG4BirksLaw.h" +#include "LArBarrelPresamplerGeometry.h" +#include "PsMap.h" + +#include "G4AffineTransform.hh" +#include "G4NavigationHistory.hh" + +#include "G4ThreeVector.hh" +#include "G4StepPoint.hh" +#include "G4Step.hh" + +#include "G4ios.hh" +#include "globals.hh" + +#include <cmath> +#include <limits.h> + +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/Bootstrap.h" +#include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/Units.h" + +namespace Units = Athena::Units; + +// #define DEBUGSTEP + +//============================================================================= +LArBarrelPresamplerCalculator::LArBarrelPresamplerCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_geometry("LArBarrelPresamplerGeometry", name) + , m_psmap(nullptr) + , m_IflCur(true) + , m_birksLaw(nullptr) + , m_detectorName("LArMgr") + //, m_testbeam(false) + , m_volname("LArMgr::LAr::Barrel::Presampler") +{ + declareProperty("GeometryCalculator", m_geometry); + declareProperty("IflCur",m_IflCur); + declareProperty("DetectorName",m_detectorName); + //declareProperty("isTestbeam",m_testbeam); +} + +StatusCode LArBarrelPresamplerCalculator::initialize() +{ + ATH_MSG_DEBUG("LArBarrelPresamplerCalculator: Beginning initialization "); + // Initialize private members. + + // Access source of detector parameters. + LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); + + // Initialize the geometry calculator + ATH_CHECK(m_geometry.retrieve()); + + if (m_IflCur) + { + ATH_MSG_INFO(" LArBarrelPresamplerCalculator: start reading current maps"); + m_psmap = PsMap::GetPsMap(); + } + + // Get the out-of-time cut from the detector parameters routine. + m_OOTcut = parameters->GetValue("LArExpHallOutOfTimeCut"); //FIXME should be done by configurables + + if (m_BirksLaw) + { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); + ATH_MSG_INFO(" LArBarrelPresamplerCalculator: Birks' law ON "); + ATH_MSG_INFO(" LArBarrelPresamplerCalculator: parameter k " << m_birksLaw->k()); + } + else + { + ATH_MSG_INFO(" LArBarrelPresamplerCalculator: Birks' law OFF"); + } + + if(m_detectorName.size()==0) m_volname="LAr::Barrel::Presampler"; + else m_volname=m_detectorName+"::LAr::Barrel::Presampler"; + + ATH_MSG_DEBUG("End of LArBarrelPresamplerCalculator initialization "); + + return StatusCode::SUCCESS; +} + +//============================================================================== +StatusCode LArBarrelPresamplerCalculator::finalize() +{ + if (m_BirksLaw) delete m_birksLaw; + return StatusCode::SUCCESS; +} + +// ============================================================================== +G4bool LArBarrelPresamplerCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const +{ + hdata.clear(); + LArG4Identifier identifier2; + + // check the Step content is non trivial + G4double thisStepEnergyDeposit = a_step->GetTotalEnergyDeposit(); + G4double thisStepLength = a_step->GetStepLength() / Units::mm; + G4double dstep = .1*Units::mm; // length of punctual charge for Current Option + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG( "****** LArBarrelPresamplerCalculator: Step energy,length " + << thisStepEnergyDeposit << " " << thisStepLength); +#endif + if(thisStepEnergyDeposit <= 0. || thisStepLength <= 0.) + { + return false; + } + + // Get Step geometrical parameters (first and end) + G4StepPoint *thisStepPoint = a_step->GetPreStepPoint(); + G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint(); + G4ThreeVector startPoint = thisStepPoint->GetPosition(); + G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Global beginning step position " + << startPoint.x() << " " << startPoint.y() << " " + << startPoint.z()); + ATH_MSG_DEBUG(" Global end step position " + << endPoint.x() << " " << endPoint.y() << " " + << endPoint.z()); +#endif + + + // find transformation to go inside local half presampler tube volume + + const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); + G4int ndep = g4navigation->GetDepth(); + G4int idep = -999; + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Detector Name " << m_detectorName); +#endif + + bool testbeam=false; + + if(m_detectorName=="") + for (G4int ii=0;ii<=ndep;ii++) { + G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); + // FIXME More efficient to find the comparison volume once and compare pointers? + if (v1->GetName()=="LAr::Barrel::Presampler") idep=ii; // half barrel + // FIXME Why are we checking if the geo is test beam every step? + if (v1->GetName()=="LAr::TBBarrel::Cryostat::LAr") testbeam=true; // TB or not ? + } + else + for (G4int ii=0;ii<=ndep;ii++) { + G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Level,VolumeName " << ii << " " << v1->GetName()); +#endif + // FIXME More efficient to find the comparison volume once and compare pointers? + if (v1->GetName()==G4String(m_detectorName+"::LAr::Barrel::Presampler")) idep=ii; + // FIXME Why are we checking if the geo is test beam every step? + if (v1->GetName()==G4String(m_detectorName+"::LAr::TBBarrel::Cryostat::LAr")) testbeam=true; // TB or not ? + } + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" idep = " << idep); +#endif + + if (idep<0) { + ATH_MSG_INFO(" LArBarrelPresamplerCalculator::Process Presampler volume not found !!"); + return false; + } + + // transformation to go from global frame to LAr::Barrel::Presampler frame + const G4AffineTransform transformation = g4navigation->GetTransform(idep); + + // step beginning and end in local frame + G4ThreeVector startPointinLocal = + transformation.TransformPoint(startPoint); + G4ThreeVector endPointinLocal = + transformation.TransformPoint (endPoint); + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Local beginning step position " + << startPointinLocal.x() << " " << startPointinLocal.y() << " " + << startPointinLocal.z()); + ATH_MSG_DEBUG(" Local end step position " + << endPointinLocal.x() << " " << endPointinLocal.y() << " " + << endPointinLocal.z()); +#endif + + // compute number of sub steps + // = 1 if no charge collection + // otherwise 200 microns (dstep) division + + G4int nsub_step=1; + if (m_IflCur) nsub_step=(int) (thisStepLength*(1./dstep)) + 1; + // delta is fraction of step between two sub steps + G4double delta=1./((double) nsub_step); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" nsub_step,delta " << nsub_step << " " << delta); +#endif + + G4double energy = a_step->GetTotalEnergyDeposit(); + if (m_BirksLaw) { + const double EField = 10. ; // 10 kV/cm electric field in presampler gap + const double wholeStepLengthCm = a_step->GetStepLength() / CLHEP::cm; + energy = (*m_birksLaw)(energy, wholeStepLengthCm, EField); + } + + // loop over sub steps + + + // share total step energy evenly in each sub step + energy = energy / ((float) (nsub_step)); + for (G4int i=0;i<nsub_step;i++) { + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" Energy for sub step " << energy); +#endif + + // position for this substep + G4double fraction=(((G4double) i)+0.5)*delta; + G4ThreeVector subinLocal=startPointinLocal*(1-fraction) + endPointinLocal*fraction; + G4double xloc = subinLocal.x(); + G4double yloc = subinLocal.y(); + G4double zloc = subinLocal.z(); + // call geometry method to find cell from local position + // status = true if hit is in normal region (13mm LAr gap) + // this method fills the cell number as well as coordinates in the electrode frame + LArG4::BarrelPresampler::CalcData currentCellData; + bool status = m_geometry->findCell(currentCellData,xloc,yloc,zloc); + + // check fiducical cuts + if (status) { + + // compute cell identifier + G4int zSide; + if (testbeam) + zSide = 1; + else + zSide = ( startPoint.z() > 0.) ? 1 : -1; + + G4int region = currentCellData.region; + G4int etaBin = currentCellData.etaBin; + G4int phiBin = currentCellData.phiBin; + G4int sampling = currentCellData.sampling; + + if( zSide == -1 ) + { + // following code for an Y-axis rotation to define Z < 0. Barrel part + phiBin = 31 - phiBin; + if(phiBin < 0 ) phiBin += 64; + } + + // check identifier + if (sampling !=0 || region != 0 || + etaBin <0 || etaBin > 60 || phiBin <0 || phiBin>63) continue; + + // fill identifier + identifier2.clear(); + identifier2 << 4 // LArCalorimeter + << 1 // LArEM + << zSide + << sampling + << region + << etaBin + << phiBin; + + // time computation is not necessarily correct for test beam + G4double time; + if (testbeam) + { + time=0.; + } + else + { + G4double tof; + tof = thisStepPoint->GetGlobalTime() / Units::ns; + time = tof - thisStepPoint->GetPosition().mag() * (1. / (CLHEP::c_light * CLHEP::ns)); + } + + G4double Current; + if (!m_IflCur) { + // no charge collection Current=E from Geant + Current=energy; + } + else { + // get module number and coordinates in electrode frame + G4int imodule = currentCellData.module; + G4double x0 = currentCellData.distElec; + G4double y0 = currentCellData.xElec; + // full symmetry for angle=0 electrodes + if (imodule>1) { + x0=std::fabs(x0); + y0=std::fabs(y0); + } + // reduced symmetry (point symmetry around 0) for tilted electrodes + if (imodule==0 || imodule ==1) { + if (x0<0) { + x0=-1.*x0; + y0=-1.*y0; + } + } +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" set current map for module " << imodule); +#endif + m_psmap->SetMap(imodule); + if (!(m_psmap->Map())) { + ATH_MSG_INFO(" LArBarrelPresamplerCalculator: cannot get map for module " << imodule); + continue; + } + double current0,current1,current2,gap; + + // get information from current map + m_psmap->Map()->GetAll(x0,y0,&gap,¤t0,¤t1,¤t2); +#ifdef DEBUGSTEP + ATH_MSG_DEBUG(" module,x0,y0,current0 from map " << imodule << " " << x0 << " " << y0 << " " << current0); +#endif + + // assume HV=2000 everywhere for the time being + Current = energy*current0; + + } + + // check if we have a new hit in a different cell, or if we add this substep + // to an already existing hit + G4bool found=false; + for (unsigned int j=0; j<hdata.size(); j++) { + if (hdata[j].id==identifier2) { + hdata[j].energy += Current; + hdata[j].time += time*Current; + found=true; + break; + } + } // loop over hits + if (!found) { + LArHitData newdata = {identifier2, time*Current, Current}; + hdata.push_back(newdata); + } // hit was not existing before + + + } // hit fulfills fiducial cuts + } // end loop over sub steps + +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("Number of hits for this step " << m_nhits << " " << hdata.size()); +#endif + + // finalise time computations + for (unsigned int i=0;i<hdata.size();i++) { + if (std::fabs(hdata[i].energy)>1e-6) hdata[i].time=hdata[i].time/hdata[i].energy; + else hdata[i].time=0.; +#ifdef DEBUGSTEP + ATH_MSG_DEBUG("Hit Energy/Time " << hdata[i].energy << " " << hdata[i].time); +#endif + } + + if (hdata.size()>0) return true; + else return false; + +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.h new file mode 100644 index 000000000000..d25917284981 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerCalculator.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArBarrelPresamplerCalculator.hh +// Prepared 05-Dec-2002 Bill Seligman + +// A first pass at determing hit cell ID in the LAr barrel presampler. + +#ifndef LARG4BARREL_LARBARRELPRESAMPLERCALCULATOR_H +#define LARG4BARREL_LARBARRELPRESAMPLERCALCULATOR_H + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include "ILArBarrelPresamplerGeometry.h" + +#include "globals.hh" +#include <stdexcept> +// Forward declarations. +class G4Step; +class PsMap; +class LArG4BirksLaw; +class G4String; + +class LArBarrelPresamplerCalculator : public LArCalculatorSvcImp { + +public: + + LArBarrelPresamplerCalculator(const std::string& name, ISvcLocator *pSvcLocator); + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + + ///////////////////////////////////////////// + + virtual G4float OOTcut() const override final { return m_OOTcut; } + + virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const override final; + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(std::fabs(hitTime) > m_OOTcut); + } + +private: + + //copy constructor + LArBarrelPresamplerCalculator(const LArBarrelPresamplerCalculator&);//coverity issue fix. Declared, but not implemented + LArBarrelPresamplerCalculator& operator=(const LArBarrelPresamplerCalculator&);//coverity issue fix. Declared, but not implemented + // + // Class for calculating the identifier. + ServiceHandle<ILArBarrelPresamplerGeometry> m_geometry; + + PsMap* m_psmap; + + bool m_IflCur; + + const LArG4BirksLaw *m_birksLaw; + + // detector name, for translated geometry + std::string m_detectorName; + + //bool m_testbeam; + + G4String m_volname; + +}; + +#endif // __LArBarrelPresamplerCalculator_H__ diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cc deleted file mode 100644 index 883698956934..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cc +++ /dev/null @@ -1,519 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -/******************************************************************** - -NAME: LArBarrelPresamplerGeometry.cxx -PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel - -AUTHORS: G. Unal, L. Carminati -CREATED: September, 2004 - -PURPOSE: 'geometrical' methods used by the LArBarrelPresamplerCalculator. - These original methods (previously in LArBarrelPresampler Calculator) were - written by Bill Seligman - -UPDATES: - Calculate identifier method used by PresamplerCalibrationCalculator. - (sept 2004) - - Extended (added findCell method) to compute distance to electrode - (GU oct 2005). Also improved computation of etaBin taking into account - more correctly effect of tilted electrodes - -********************************************************************/ - -//#undef DEBUGHITS - -#include "LArG4Barrel/LArBarrelPresamplerGeometry.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include "LArG4Code/LArG4Identifier.h" - -#include "G4AffineTransform.hh" -#include "G4NavigationHistory.hh" - -#include "G4ThreeVector.hh" -#include "G4StepPoint.hh" -#include "G4Step.hh" - -#include "G4ios.hh" -#include "globals.hh" - -#include <cmath> -#include <limits.h> -#include <iostream> - -namespace LArG4 { - -namespace BarrelPresampler { - -Geometry* Geometry::m_instance = 0; - -Geometry* Geometry::GetInstance() -{ - if (m_instance == 0) - { - m_instance = new Geometry(); - } - return m_instance; -} - -// ================================================================== -// initialize geometry parameters -// this should at some stage be taken from a database... -Geometry::Geometry() -{ -#include "PresParameterDef.icc" - - // Access source of detector parameters. - m_parameters = LArVG4DetectorParameters::GetInstance(); - - // position of mother volume inside nominal Atlas frame - m_zpres=1549.*CLHEP::mm; - // compute positions of end of modules and of first cathode in a module in - // nominal Atlas coordinates - double eps=0.007*CLHEP::mm; - m_zminPS=3.00*CLHEP::mm; // FIXME this should come from database - m_end_module[0]=(m_mod[0][0]*m_cmm+2*eps)+m_zminPS+eps; - for (int i=1;i<8;i++) m_end_module[i]=m_end_module[i-1]+(m_mod[i][0]*m_cmm+2*eps)+eps; -#ifdef DEBUGHITS - for (int i=0;i<8;i++) { - std::cout << "Module lenght " << m_mod[0][0]*m_cmm+2*eps << std::endl; - std::cout << "End of Module " << m_end_module[i] << std::endl; - } -#endif - - m_cat_th=m_cathode_th*m_cmm; - m_first_cathod[0]=m_zminPS+m_mod[0][5]*m_cmm+m_cat_th/2.+2*eps; - for (int i=1;i<8;i++) m_first_cathod[i]=m_end_module[i-1]+m_mod[i][5]*m_cmm+m_cat_th/2.+2*eps; - -#ifdef DEBUGHITS - for (int i=0;i<8;i++) std::cout << "position of first cathode " << m_first_cathod[i] << std::endl; -#endif - - // number of cells in eta per module - for (int i=0;i<7;i++) m_ncell_module[i]=8; - m_ncell_module[7]=5; - - // electrode tild in rad - for (int i=0;i<8;i++) m_tilt[i]=m_mod[i][3]*CLHEP::deg; - - // number of gaps per cell module 7 is somewhat pathological (last cell is shorter) - for (int i=0;i<7;i++) m_ngap_cell[i]=(int)((m_mod[i][1]+0.1)/m_ncell_module[i]); - m_ngap_cell[7]=18; -#ifdef DEBUGHITS - for (int i=0;i<8;i++) std::cout << "ngap per cell " << m_ngap_cell[i] << std::endl; -#endif - - // pitch in z of gaps - for (int i=0;i<8;i++) m_pitch[i]=m_mod[i][4]*m_cmm; - - // LAr total gap - m_halfThickLAr = 0.5*13.*CLHEP::mm; - - m_xElec=0; - m_sampling=0; - m_region=0; - m_phiBin=0; - m_module=0; - m_gap=0; - m_etaBin=0; - m_distElec=0.; - m_dist=0.; - itb=0; -} - -//===================================================================================== -Geometry::~Geometry() {;} - -//====================================================================================== -// -// The following method computes the identifiers in the Presampler volume: -// -// 1) Navigate through the volumes hierarchy -// -// 2) Calculate identifier using the CalculatePSActiveIdentifier method if the -// hit is in the Module volume and CalculatePS_DMIdentifier if the hit is -// in some dead region -// -//====================================================================================== - -LArG4Identifier Geometry::CalculateIdentifier(const G4Step* a_step, std::string strDetector ) -{ - const static G4String fullPSName = "LAr::Barrel::Presampler"; - const static G4String fullCryoName = "LAr::TBBarrel::Cryostat::LAr"; - const static G4String fullModuleName = "LAr::Barrel::Presampler::Module"; - - // Get all the required information from the current step - const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); - G4int ndep = g4navigation->GetDepth(); - G4int iactive = -999; - itb = 0 ; - G4int idep = -999; - - //Now navigate through the volumes hierarchy - G4VPhysicalVolume* v1; - if(strDetector=="") - for (G4int ii=0;ii<=ndep;ii++) { - v1 = g4navigation->GetVolume(ii); - if (v1->GetName()==fullPSName) idep=ii; // half barrel - else if (v1->GetName()==fullCryoName) itb=1; // TB or not ? - else if (v1->GetName()==fullModuleName) iactive=1; - } - else - for (G4int ii=0;ii<=ndep;ii++) { - v1 = g4navigation->GetVolume(ii); - if (v1->GetName()==G4String(strDetector+"::LAr::Barrel::Presampler")) idep=ii; // half barrel - else if (v1->GetName()==G4String(strDetector+"::LAr::TBBarrel::Cryostat::LAr")) itb=1; // TB or not ? - else if (v1->GetName()==G4String(strDetector+"::LAr::Barrel::Presampler::Module")) iactive=1; - } - - if (idep < 0) std::abort(); - - if ( iactive > 0 ) { - return CalculatePSActiveIdentifier( a_step , idep , itb ); - } - return CalculatePS_DMIdentifier( a_step , idep , itb); -} - -// ========================================================================================== -// calculate identifier from a G4 step in the PS active region -// This function should always return a valid identifier which can be used for calibration hit -// even if the hit is not really in the "fiducial" active part - -LArG4Identifier Geometry::CalculatePSActiveIdentifier(const G4Step* a_step, const G4int ind, const G4int itb) -{ - LArG4Identifier PSActiveID = LArG4Identifier(); - - G4ThreeVector p = (a_step->GetPostStepPoint()->GetPosition() + a_step->GetPreStepPoint()->GetPosition()) * 0.5; - -#ifdef DEBUGHITS - std::cout << "Position of the step in the ATLAS frame (x,y,z) --> " << p.x() << " " << p.y() << " " << p.z() << std::endl; - std::cout << "Eta and Phi in the atlas frame --> " << p.eta() << " " << p.phi() << std::endl; -#endif - -// to get coordinates in the Presampler frame - - const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); - G4ThreeVector ploc = g4navigation->GetTransform(ind).TransformPoint(p); - - G4int zSide; - - /*bool status=*/findCell(ploc.x(),ploc.y(),ploc.z()); - -// in TB case, only 1 side, -// in Atlas case, use overall z to decide side - if (itb==0) { - if (p.z() > 0.) - { - zSide = 1; - } - else - { - zSide = -1; - } - } - else - { - zSide = 1; - } - - if( zSide == -1 ) -//following code for an Y-axis rotation to define the side C half-barrel - { - m_phiBin = 31 - m_phiBin; - if(m_phiBin < 0 ) m_phiBin += 64; - } - - // Append the cell ID to the (empty) identifier. - PSActiveID << 4 // LArCalorimeter - << 1 // LArEM - << zSide - << m_sampling - << m_region - << m_etaBin - << m_phiBin; - -#ifdef DEBUGHITS - std::cout << "Here the identifier for the presampler ACTIVE ----> " << std::endl; - std::cout << "m_zSide ----> " << zSide << std::endl; - std::cout << "m_sampling ----> " << m_sampling << std::endl; - std::cout << "m_region ----> " << m_region << std::endl; - std::cout << "m_etaBin ----> " << m_etaBin << std::endl; - std::cout << "m_phiBin ----> " << m_phiBin << std::endl; -#endif - - return PSActiveID ; -} - -//========================================================================================== - -LArG4Identifier Geometry::CalculatePS_DMIdentifier(const G4Step* a_step, const G4int ind, const G4int itb) -{ - - /****************************************************************************** - CaloDM_ID identifier: - - detector_system/subdet/type/sampling/region/eta/phi - detector system = 10 -> Calorimeters - subdet = +/-4 -> LAr dead materials - type = 1 -> dead materials outside accordion and active presampler layers - sampling = 1 -> dead materials in front and in active LAr calorimeters - (starting from front warm cryostat walls) - regions: = 0 barrel warm wall and solenoid in front of the barrel presampler, 0 < |eta| < 1.5 - = 1 barrel cryostat cold wall in front of the barrel presampler, 0 < |eta| < 1.5 - = 2 all materials in front of the barrel presampler at radius larger than cold wall - outer radius, 0 < |eta| < 1.5 - = 3 all materials from the active layer of the barrel presampler to the active layer - of accordion, 0 < |eta| < 1.5 - - ---> Granularity : deta 0.1 granularity within region - dphi pi/32 ~ 0.1 granularity within region - - ***********************************************************************************/ - - LArG4Identifier PS_DM_ID = LArG4Identifier(); - - G4ThreeVector p = (a_step->GetPostStepPoint()->GetPosition() + a_step->GetPreStepPoint()->GetPosition()) * 0.5; - -#ifdef DEBUGHITS - std::cout << "Position of the step in the ATLAS frame (x,y,z) --> " << p.x() << " " << p.y() << " " << p.z() << std::endl; - std::cout << "Eta and Phi in the atlas frame --> " << p.eta() << " " << p.phi() << std::endl; -#endif - -// to get coordinates in local half barrel frame, independently -// of overall presampler position/rotation - - const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); - G4ThreeVector ploc = g4navigation->GetTransform(ind).TransformPoint(p); - G4double radius=sqrt(ploc.x()*ploc.x() + ploc.y()*ploc.y()); - -// shift z such that z=0 is eta=0 in Atlas standard frame - G4ThreeVector ploc2(ploc.x(),ploc.y(),ploc.z()+m_zpres+m_zminPS); - -#ifdef DEBUGHITS - std::cout << "Position of the step after traslation (x,y,z) --> " << ploc2.x() << " " << ploc2.y() << " " << ploc2.z() << std::endl; - std::cout << "Eta and Phi after translation --> " << ploc2.eta() << " " << ploc2.phi() << std::endl; -#endif - - // 01-Feb-2001 WGS: Add zSide calculation. - G4int zSide = INT_MIN; // Initialize to a default, incorrect value. - -// in TB case, only 1 side, -// in Atlas case, use overall z to decide side - if (itb==0) { - if (p.z() > 0.) - { - zSide = 1; - } - else - { - zSide = -1; - } - } - else - { - zSide = 1; - } - - // eta,phi in "local" half barrel coordinates - G4double phi = ploc2.phi(); - G4double eta = ploc2.eta(); - - if ( phi < 0. ) phi += 2.*M_PI; - //G4double z2=fabs(ploc2.z()); - - // chek if the hit is in front of the active layer of the presampler in order to distinguish - // between regin 2 and 3: WARNING the method is temporary! - // PSModuleRmean = 1420 is the distance between the middle of the active layer (LAr) of the PS - // modules and the interaction point - - const G4int numberPhiMod = 32; - const G4double dphi = ( 2.*M_PI ) / numberPhiMod; - const G4double inv_dphi = 1. / dphi; - const G4double PSModuleRmean = 1420 ; - G4double phicheck = phi - int(phi * inv_dphi) * dphi - (dphi /2.); - G4double Rcheck = PSModuleRmean / cos(phicheck); - if (radius > Rcheck) { - m_region = 3; - } else { - m_region = 2; - } - - const G4double detaDM = 0.1 ; - const G4double dphiDM = ( 2 * M_PI ) / 64. ; - - m_phiBin = G4int( phi * (1. / dphiDM) ); - m_etaBin = G4int( eta * (1. / detaDM) ); - - if( zSide == -1 ) - { - m_phiBin = 31 - m_phiBin; - if(m_phiBin < 0 ) m_phiBin += 64; - } - - // 07-Jul-2005 WGS: Handle an extremely rare rounding problem. - if ( m_phiBin == 64 ) m_phiBin = 0; - - // Fill identifier. - PS_DM_ID << 10 // ATLAS - << zSide*4 // LArEM - << 1 - << 1 - << m_region - << m_etaBin - << m_phiBin; - -#ifdef DEBUGHITS - std::cout << "Here the identifier for the presampler DEAD materials ---->" << std::endl; - std::cout << "m_zSide ----> " << zSide*4 << std::endl; - std::cout << "region ----> " << m_region << std::endl; - std::cout << "etaBin ----> " << m_etaBin << std::endl; - std::cout << "phiBin ----> " << m_phiBin << std::endl; -#endif - - return PS_DM_ID ; -} - -//=============================================================================== -// bool findCell(xloc,yloc,zloc) -// -// From local PS coordinates (half barrel tube mother volume) -// compute etaBin,phiBin,sampling,region -// as well as gap number, distance to closest electrode and projection -// along electrode axis -// -// Takes into account for complexity of eta segmentation -// -// Return true if where are really within the 13mm LAr gap -// Return false for the few steps which are in the safety region at the -// edges of module -// Assume that hit is in the "active" LAr - -// note that here phiBin is computed for the + half barrel -// some care has to be taken to convert to the - half barrel, taking into -// account the rotation - -// findCell always fill valids m_region, m_sampling , m_etaBin, m_phiBin -// it returns true if the hit is in the normal 13mm Ar gap, within a real module -// it returns false otherwise -// - -bool Geometry::findCell(G4double xloc,G4double yloc,G4double zloc) -{ - - m_sampling = 0; - m_region = 0; - - // eta,phi in "local" Atlas like half barrel coordinates - G4double phi = atan2(yloc,xloc); - if ( phi < 0. ) phi += 2.*M_PI; - G4double z2=fabs(zloc+m_zpres+m_zminPS); - - // According to the memo, phi is divided into 64 regions [0..63]. - const G4int numberPhiBins = 64; - const G4double dphi = ( 2.*M_PI ) / numberPhiBins; - const G4double inv_dphi = 1. / dphi; - // Convert phi into integer bins. - m_phiBin = G4int( phi * inv_dphi ); - if (m_phiBin >63) m_phiBin=63; - if (m_phiBin <0) m_phiBin=0; - -// if inside LAr but outside a module, returns some etaBin value for -// the DM identifier, but function return false to veto this step -// in the normal calculator - if (z2 < m_zminPS ) { - m_etaBin=0; - return false; - } - if (z2 > m_end_module[7]) { - m_etaBin=60; - return false; - } - -// find in which module in z the hit is - m_module=0; - for (int i=1;i<8;i++) { - if (m_first_cathod[i]>=z2) break; - m_module++; - } - if (m_module <0 || m_module > 7) - { - G4cerr << "LArBarrelPresampler: invalid module/hit " << m_module << " " << z2 << G4endl; - if (m_module<0) m_etaBin=0; - if (m_module>7) m_etaBin=60; - return false; - } - -// compute signed distance from middle of active layer along layer height axis - G4int isect=G4int(phi*m_nsectors/(2.*M_PI)); - G4double phi0= ((double)isect+0.5)*2.*M_PI/((double) m_nsectors); - static const G4double r0=1420.4*CLHEP::mm; // FIXME should be recomputed from database - m_dist=(xloc*cos(phi0)+yloc*sin(phi0)-r0); - -#ifdef DEBUGHITS - std::cout << "sector number, dist along height " << isect << " " << m_dist << std::endl; - std::cout << "z2,module number,m_first_cathod " << z2 << " " << m_module << " " - << m_first_cathod[m_module] << std::endl; -#endif - - bool status=true; - if (fabs(m_dist)>m_halfThickLAr) { -#ifdef DEBUGHITS - std::cout << "Outside normal LAr 13mm gap " << std::endl, -#endif - status=false; - } - -// compute z distance from first cathode of module to step, taking into -// account the m_tilt angle of the cathode - G4double deltaz=z2-(m_first_cathod[m_module]+m_dist*tan(m_tilt[m_module])); - if (deltaz<0 ) { - if (m_module>0) { - m_module=m_module-1; - deltaz=z2-(m_first_cathod[m_module]+m_dist*tan(m_tilt[m_module])); - } - else deltaz=0; - } - -// compute gap number - m_gap = ((int)(deltaz/m_pitch[m_module])); - -#ifdef DEBUGHITS - std::cout << "deltaz from first cathode,gap number " << deltaz << " " << m_gap << std::endl; -#endif - -// compute cell number in eta - m_etaBin= m_gap/m_ngap_cell[m_module]; -#ifdef DEBUGHITS - std::cout << "etaBin inside module " << m_etaBin; -#endif - if (m_etaBin >= m_ncell_module[m_module]) m_etaBin=m_ncell_module[m_module]-1; - - for (int i=0;i<m_module;i++) m_etaBin=m_etaBin+m_ncell_module[i]; -#ifdef DEBUGHITS - std::cout << " final etaBin " << m_etaBin << std::endl; -#endif - - if (m_etaBin < 0 || m_etaBin > 60) { - std::cout << "LArBarrelPresamplerGeometry::findCell etaBin outside range " << m_etaBin << std::endl; - } - -// z of the centre of the anode of the gap - G4double zmiddle=m_first_cathod[m_module]+((double)(m_gap+0.5))*m_pitch[m_module]; - -// compute step position in electrode reference frame -// m_distElec => signed distance to electrode -// m_xElec => projection along electrode axis - m_xElec=m_dist*cos(m_tilt[m_module])+(z2-zmiddle)*sin(m_tilt[m_module]); - m_distElec=(z2-zmiddle)*cos(m_tilt[m_module]) - m_dist*sin(m_tilt[m_module]); -#ifdef DEBUGHITS - std::cout << "zmiddle,xloc,yloc " << zmiddle << " " << m_distElec << " " << m_xElec << std::endl; -#endif - - return status; -} - -} //end of BarrelPresampler namespace - -} // end of LArG4 namespace diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cxx new file mode 100644 index 000000000000..ae7d711f7513 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.cxx @@ -0,0 +1,483 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: LArBarrelPresamplerGeometry.cxx +PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel + +AUTHORS: G. Unal, L. Carminati +CREATED: September, 2004 + +PURPOSE: 'geometrical' methods used by the LArBarrelPresamplerCalculator. + These original methods (previously in LArBarrelPresampler Calculator) were + written by Bill Seligman + +UPDATES: - Calculate identifier method used by PresamplerCalibrationCalculator. + (sept 2004) + - Extended (added findCell method) to compute distance to electrode + (GU oct 2005). Also improved computation of etaBin taking into account + more correctly effect of tilted electrodes + +********************************************************************/ + +//#undef DEBUGHITS + +#include "LArBarrelPresamplerGeometry.h" +#include "LArG4Code/LArVG4DetectorParameters.h" +#include "LArG4Code/LArG4Identifier.h" + +#include "G4AffineTransform.hh" +#include "G4NavigationHistory.hh" + +#include "G4ThreeVector.hh" +#include "G4StepPoint.hh" +#include "G4Step.hh" + +#include "G4ios.hh" +#include "globals.hh" + +#include <cmath> +#include <limits.h> +#include <iostream> + +namespace LArG4 { + + namespace BarrelPresampler { + + Geometry::Geometry(const std::string& name, ISvcLocator *pSvcLocator) + : AthService(name, pSvcLocator) + , m_detectorName("LArMgr") + // , m_testbeam(false) + { + declareProperty("DetectorName",m_detectorName); + // declareProperty("TestBeam", m_testbeam); + } + + //===================================================================================== + Geometry::~Geometry() {;} + + // ================================================================== + /** initialize geometry parameters + this should at some stage be taken from a database... */ + StatusCode Geometry::initialize() + { +#include "PresParameterDef.icc" + + /** Access source of detector parameters. */ + m_parameters = LArVG4DetectorParameters::GetInstance(); + + /** position of mother volume inside nominal Atlas frame */ + m_zpres=1549.*CLHEP::mm; + /** compute positions of end of modules and of first cathode in + a module in nominal Atlas coordinates */ + const double eps=0.007*CLHEP::mm; + m_zminPS=3.00*CLHEP::mm; // FIXME this should come from database + m_end_module[0]=(m_mod[0][0]*m_cmm+2*eps)+m_zminPS+eps; + for (int i=1;i<8;i++) m_end_module[i]=m_end_module[i-1]+(m_mod[i][0]*m_cmm+2*eps)+eps; +#ifdef DEBUGHITS + for (int i=0;i<8;i++) { + ATH_MSG_VERBOSE("Module length " << m_mod[0][0]*m_cmm+2*eps); + ATH_MSG_VERBOSE("End of Module " << m_end_module[i]); + } +#endif + + m_cat_th=m_cathode_th*m_cmm; + m_first_cathod[0]=m_zminPS+m_mod[0][5]*m_cmm+m_cat_th/2.+2*eps; + for (int i=1;i<8;i++) m_first_cathod[i]=m_end_module[i-1]+m_mod[i][5]*m_cmm+m_cat_th/2.+2*eps; + +#ifdef DEBUGHITS + for (int i=0;i<8;i++) ATH_MSG_VERBOSE("position of first cathode " << m_first_cathod[i]); +#endif + + // number of cells in eta per module + for (int i=0;i<7;i++) m_ncell_module[i]=8; + m_ncell_module[7]=5; + + // electrode tild in rad + for (int i=0;i<8;i++) m_tilt[i]=m_mod[i][3]*CLHEP::deg; + + // number of gaps per cell module 7 is somewhat pathological (last cell is shorter) + for (int i=0;i<7;i++) m_ngap_cell[i]=(int)((m_mod[i][1]+0.1)/m_ncell_module[i]); + m_ngap_cell[7]=18; +#ifdef DEBUGHITS + for (int i=0;i<8;i++) ATH_MSG_VERBOSE("ngap per cell " << m_ngap_cell[i]); +#endif + + // pitch in z of gaps + for (int i=0;i<8;i++) m_pitch[i]=m_mod[i][4]*m_cmm; + + // LAr total gap + m_halfThickLAr = 0.5*13.*CLHEP::mm; + + return StatusCode::SUCCESS; + } + + // ==================================================================================== + + StatusCode Geometry::queryInterface( const InterfaceID & riid, void** ppvInterface ) + { + if ( ILArBarrelPresamplerGeometry::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<ILArBarrelPresamplerGeometry*>(this); + addRef(); + return StatusCode::SUCCESS; + } + /** Interface is not directly available : try out a base class */ + return AthService::queryInterface(riid, ppvInterface); + } + + //====================================================================================== + /** + The following method computes the identifiers in the Presampler volume: + + 1) Navigate through the volumes hierarchy + + 2) Calculate identifier using the CalculatePSActiveIdentifier method if the + hit is in the Module volume and CalculatePS_DMIdentifier if the hit is + in some dead region + */ + //====================================================================================== + + LArG4Identifier Geometry::CalculateIdentifier(const G4Step* a_step) const + { + const static G4String fullPSName = (m_detectorName.empty()) ? "LAr::Barrel::Presampler" : G4String(m_detectorName+"::LAr::Barrel::Presampler"); + const static G4String fullCryoName = (m_detectorName.empty()) ? "LAr::TBBarrel::Cryostat::LAr" : G4String(m_detectorName+"::LAr::TBBarrel::Cryostat::LAr"); + const static G4String fullModuleName = (m_detectorName.empty()) ? "LAr::Barrel::Presampler::Module" : G4String(m_detectorName+"::LAr::Barrel::Presampler::Module"); + + /** Get all the required information from the current step */ + const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); + const G4int ndep = g4navigation->GetDepth(); + bool iactive(false); + bool isTestBeam(false); + G4int idep(-999); + + /** Now navigate through the volumes hierarchy */ + for (G4int ii=0;ii<=ndep;ii++) { + // FIXME Need to find a way to avoid these string-comparisons + const G4String& vname = g4navigation->GetVolume(ii)->GetName(); + if (idep<0 && vname==fullPSName) idep=ii; // half barrel + else if (!isTestBeam && vname==fullCryoName) isTestBeam=true; // TB or not ? + else if (!iactive && vname==fullModuleName) iactive=true; + } + + if (idep < 0) std::abort(); + + if ( iactive ) { + return this->CalculatePSActiveIdentifier( a_step , idep , isTestBeam ); + } + return this->CalculatePS_DMIdentifier( a_step , idep , isTestBeam); + } + + // ========================================================================================== + /** calculate identifier from a G4 step in the PS active region + This function should always return a valid identifier which can be + used for calibration hit even if the hit is not really in the + "fiducial" active part */ + + LArG4Identifier Geometry::CalculatePSActiveIdentifier(const G4Step* a_step, const G4int ind, const bool isTestBeam) const + { + LArG4Identifier PSActiveID = LArG4Identifier(); + + const G4ThreeVector p = (a_step->GetPostStepPoint()->GetPosition() + a_step->GetPreStepPoint()->GetPosition()) * 0.5; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Position of the step in the ATLAS frame (x,y,z) --> " << p.x() << " " << p.y() << " " << p.z()); + ATH_MSG_VERBOSE("Eta and Phi in the atlas frame --> " << p.eta() << " " << p.phi()); +#endif + + /* to get coordinates in the Presampler frame */ + + const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); + const G4ThreeVector ploc = g4navigation->GetTransform(ind).TransformPoint(p); + + const G4int zSide(this->determineZSide(isTestBeam, p.z())); + + CalcData currentCellData; + (void)this->findCell(currentCellData,ploc.x(),ploc.y(),ploc.z()); + + if( zSide == -1 ) + /** following code for an Y-axis rotation to define the side C half-barrel */ + { + currentCellData.phiBin = 31 - currentCellData.phiBin; + if(currentCellData.phiBin < 0 ) currentCellData.phiBin += 64; + } + + /** Append the cell ID to the (empty) identifier. */ + PSActiveID << 4 // LArCalorimeter + << 1 // LArEM + << zSide + << currentCellData.sampling + << currentCellData.region + << currentCellData.etaBin + << currentCellData.phiBin; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Here the identifier for the presampler ACTIVE ----> "); + ATH_MSG_VERBOSE("m_zSide ----> " << zSide); + ATH_MSG_VERBOSE("m_sampling ----> " << currentCellData.sampling); + ATH_MSG_VERBOSE("m_region ----> " << currentCellData.region); + ATH_MSG_VERBOSE("currentCellData.etaBin ----> " << currentCellData.etaBin); + ATH_MSG_VERBOSE("currentCellData.phiBin ----> " << currentCellData.phiBin); +#endif + + return PSActiveID ; + } + + //========================================================================================== + + LArG4Identifier Geometry::CalculatePS_DMIdentifier(const G4Step* a_step, const G4int ind, const bool isTestBeam) const + { + + /****************************************************************************** + CaloDM_ID identifier: + + detector_system/subdet/type/sampling/region/eta/phi + detector system = 10 -> Calorimeters + subdet = +/-4 -> LAr dead materials + type = 1 -> dead materials outside accordion and active presampler layers + sampling = 1 -> dead materials in front and in active LAr calorimeters + (starting from front warm cryostat walls) + regions: = 0 barrel warm wall and solenoid in front of the barrel presampler, 0 < |eta| < 1.5 + = 1 barrel cryostat cold wall in front of the barrel presampler, 0 < |eta| < 1.5 + = 2 all materials in front of the barrel presampler at radius larger than cold wall + outer radius, 0 < |eta| < 1.5 + = 3 all materials from the active layer of the barrel presampler to the active layer + of accordion, 0 < |eta| < 1.5 + + ---> Granularity : deta 0.1 granularity within region + dphi pi/32 ~ 0.1 granularity within region + + ***********************************************************************************/ + + const G4ThreeVector p = (a_step->GetPostStepPoint()->GetPosition() + a_step->GetPreStepPoint()->GetPosition()) * 0.5; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Position of the step in the ATLAS frame (x,y,z) --> " << p.x() << " " << p.y() << " " << p.z()); + ATH_MSG_VERBOSE("Eta and Phi in the atlas frame --> " << p.eta() << " " << p.phi()); +#endif + + /** to get coordinates in local half barrel frame, independently + of overall presampler position/rotation */ + + const G4NavigationHistory* g4navigation = a_step->GetPreStepPoint()->GetTouchable()->GetHistory(); + const G4ThreeVector ploc = g4navigation->GetTransform(ind).TransformPoint(p); + const G4double radius=sqrt(ploc.x()*ploc.x() + ploc.y()*ploc.y()); + + /** shift z such that z=0 is eta=0 in Atlas standard frame*/ + const G4ThreeVector ploc2(ploc.x(),ploc.y(),ploc.z()+m_zpres+m_zminPS); + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Position of the step after traslation (x,y,z) --> " << ploc2.x() << " " << ploc2.y() << " " << ploc2.z()); + ATH_MSG_VERBOSE("Eta and Phi after translation --> " << ploc2.eta() << " " << ploc2.phi()); +#endif + + // 01-Feb-2001 WGS: Add zSide calculation. + const G4int zSide(this->determineZSide(isTestBeam, p.z())); + + /** eta,phi in "local" half barrel coordinates */ + const G4double phi = (ploc2.phi() < 0.) ? ploc2.phi()+2.*M_PI : ploc2.phi(); + const G4double eta = ploc2.eta(); + //G4double z2=fabs(ploc2.z()); + + /** check if the hit is in front of the active layer of the + presampler in order to distinguish between regin 2 and 3: + WARNING the method is temporary! + + PSModuleRmean = 1420 is the distance between the middle of the + active layer (LAr) of the PS modules and the interaction + point */ + + const G4int numberPhiMod = 32; + const G4double dphi = ( 2.*M_PI ) / numberPhiMod; + const G4double inv_dphi = 1. / dphi; + const G4double PSModuleRmean = 1420 ; + const G4double phicheck = phi - int(phi * inv_dphi) * dphi - (dphi /2.); + const G4double Rcheck = PSModuleRmean / cos(phicheck); + CalcData currentCellData; + if (radius > Rcheck) { + currentCellData.region = 3; + } else { + currentCellData.region = 2; + } + + const G4double detaDM = 0.1 ; + const G4double dphiDM = ( 2 * M_PI ) / 64. ; + + currentCellData.phiBin = G4int( phi * (1. / dphiDM) ); + currentCellData.etaBin = G4int( eta * (1. / detaDM) ); + + if( zSide == -1 ) + { + currentCellData.phiBin = 31 - currentCellData.phiBin; + if(currentCellData.phiBin < 0 ) currentCellData.phiBin += 64; + } + + // 07-Jul-2005 WGS: Handle an extremely rare rounding problem. + if ( currentCellData.phiBin == 64 ) currentCellData.phiBin = 0; + + /** Fill identifier.*/ + LArG4Identifier PS_DM_ID = LArG4Identifier(); + PS_DM_ID << 10 // ATLAS + << zSide*4 // LArEM + << 1 + << 1 + << currentCellData.region + << currentCellData.etaBin + << currentCellData.phiBin; + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Here the identifier for the presampler DEAD materials ---->"); + ATH_MSG_VERBOSE("m_zSide ----> " << zSide*4); + ATH_MSG_VERBOSE("region ----> " << currentCellData.region); + ATH_MSG_VERBOSE("etaBin ----> " << currentCellData.etaBin); + ATH_MSG_VERBOSE("phiBin ----> " << currentCellData.phiBin); +#endif + + return PS_DM_ID ; + } + + /**=============================================================================== + bool findCell(xloc,yloc,zloc) const + + From local PS coordinates (half barrel tube mother volume) + compute etaBin,phiBin,sampling,region + as well as gap number, distance to closest electrode and projection + along electrode axis + + Takes into account for complexity of eta segmentation + + Return true if where are really within the 13mm LAr gap + Return false for the few steps which are in the safety region at the + edges of module + Assume that hit is in the "active" LAr + + note that here phiBin is computed for the + half barrel + some care has to be taken to convert to the - half barrel, taking into + account the rotation + + findCell always fills valid currentCellData.region, + currentCellData.sampling, currentCellData.etaBin, + currentCellData.phiBin it returns true if the hit is in the + normal 13mm Ar gap, within a real module it returns false + otherwise + */ + + bool Geometry::findCell(CalcData & currentCellData, G4double xloc,G4double yloc,G4double zloc) const + { + + currentCellData.sampling = 0; + currentCellData.region = 0; + + /** eta,phi in "local" Atlas like half barrel coordinates */ + G4double phi = atan2(yloc,xloc); + if ( phi < 0. ) phi += 2.*M_PI; + const G4double z2=fabs(zloc+m_zpres+m_zminPS); + + /** According to the memo, phi is divided into 64 regions [0..63]. */ + const G4int numberPhiBins = 64; + const G4double dphi = ( 2.*M_PI ) / numberPhiBins; + const G4double inv_dphi = 1. / dphi; + /** Convert phi into integer bins. */ + currentCellData.phiBin = G4int( phi * inv_dphi ); + if (currentCellData.phiBin >63) currentCellData.phiBin=63; + if (currentCellData.phiBin <0) currentCellData.phiBin=0; + + /** if inside LAr but outside a module, returns some etaBin + value for the DM identifier, but function return false to veto + this step in the normal calculator */ + if (z2 < m_zminPS ) { + currentCellData.etaBin=0; + return false; + } + if (z2 > m_end_module[7]) { + currentCellData.etaBin=60; + return false; + } + + /** find in which module in z the hit is */ + currentCellData.module=0; + for (int i=1;i<8;i++) { + if (m_first_cathod[i]>=z2) break; + currentCellData.module++; + } + if (currentCellData.module <0 || currentCellData.module > 7) + { + G4cerr << "LArBarrelPresampler: invalid module/hit " << currentCellData.module << " " << z2 << G4endl; + if (currentCellData.module<0) currentCellData.etaBin=0; + if (currentCellData.module>7) currentCellData.etaBin=60; + return false; + } + + /** compute signed distance from middle of active layer along layer height axis */ + const G4int isect=G4int(phi*m_nsectors/(2.*M_PI)); + const G4double phi0= ((double)isect+0.5)*2.*M_PI/((double) m_nsectors); + static const G4double r0=1420.4*CLHEP::mm; // FIXME should be recomputed from database + currentCellData.dist=(xloc*cos(phi0)+yloc*sin(phi0)-r0); + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("sector number, dist along height " << isect << " " << currentCellData.dist); + ATH_MSG_VERBOSE("z2,module number,m_first_cathod " << z2 << " " << currentCellData.module << " " + << m_first_cathod[currentCellData.module]); +#endif + + /** compute z distance from first cathode of module to step, + taking into account the m_tilt angle of the cathode */ + G4double deltaz=z2-(m_first_cathod[currentCellData.module]+currentCellData.dist*tan(m_tilt[currentCellData.module])); + if (deltaz<0 ) { + if (currentCellData.module>0) { + currentCellData.module=currentCellData.module-1; + deltaz=z2-(m_first_cathod[currentCellData.module]+currentCellData.dist*tan(m_tilt[currentCellData.module])); + } + else deltaz=0; + } + + /** compute gap number */ + currentCellData.gap = ((int)(deltaz/m_pitch[currentCellData.module])); + +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("deltaz from first cathode,gap number " << deltaz << " " << currentCellData.gap); +#endif + + /** compute cell number in eta */ + currentCellData.etaBin= currentCellData.gap/m_ngap_cell[currentCellData.module]; +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("etaBin inside module " << currentCellData.etaBin); +#endif + if (currentCellData.etaBin >= m_ncell_module[currentCellData.module]) currentCellData.etaBin=m_ncell_module[currentCellData.module]-1; + + for (int i=0;i<currentCellData.module;i++) currentCellData.etaBin=currentCellData.etaBin+m_ncell_module[i]; +#ifdef DEBUGHITS + ATH_MSG_VERBOSE(" final etaBin " << currentCellData.etaBin); +#endif + + if (currentCellData.etaBin < 0 || currentCellData.etaBin > 60) { + ATH_MSG_WARNING("LArBarrelPresamplerGeometry::findCell etaBin outside range " << currentCellData.etaBin); + } + + /** z of the centre of the anode of the gap */ + const G4double zmiddle=m_first_cathod[currentCellData.module]+((double)(currentCellData.gap+0.5))*m_pitch[currentCellData.module]; + + /** compute step position in electrode reference frame + currentCellData.distElec => signed distance to electrode + currentCellData.xElec => projection along electrode axis */ + currentCellData.xElec=currentCellData.dist*cos(m_tilt[currentCellData.module])+(z2-zmiddle)*sin(m_tilt[currentCellData.module]); + currentCellData.distElec=(z2-zmiddle)*cos(m_tilt[currentCellData.module]) - currentCellData.dist*sin(m_tilt[currentCellData.module]); +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("zmiddle,xloc,yloc " << zmiddle << " " << currentCellData.distElec << " " << currentCellData.xElec); +#endif + + bool status=true; + if (fabs(currentCellData.dist)>m_halfThickLAr) { +#ifdef DEBUGHITS + ATH_MSG_VERBOSE("Outside normal LAr 13mm gap "), +#endif + status=false; + } + + return status; + } + + } /** end of BarrelPresampler namespace */ + +} /** end of LArG4 namespace */ diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.h new file mode 100644 index 000000000000..a60c48100aa9 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArBarrelPresamplerGeometry.h @@ -0,0 +1,88 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArBarrelPresamplerGeometry.hh + +#ifndef LARG4BARREL_LARBARRELPRESAMPLERGEOMETRY_H +#define LARG4BARREL_LARBARRELPRESAMPLERGEOMETRY_H + +#include "ILArBarrelPresamplerGeometry.h" +#include "AthenaBaseComps/AthService.h" + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArVG4DetectorParameters.h" + +#include "globals.hh" + + +// Forward declarations. +class LArG4Identifier; +class G4Step; + +namespace LArG4 { + + namespace BarrelPresampler { + + class Geometry: public AthService, virtual public ILArBarrelPresamplerGeometry { + + public: + + //constructor + Geometry(const std::string& name, ISvcLocator * pSvcLocator); + + virtual ~Geometry(); + + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; + + virtual StatusCode initialize() override final; + + virtual LArG4Identifier CalculateIdentifier( const G4Step* ) const override final; + virtual bool findCell(CalcData & currentCellData, G4double xloc,G4double yloc,G4double zloc) const override final; + + private: + LArG4Identifier CalculatePSActiveIdentifier( const G4Step* , const G4int indPS , const bool itb ) const; + LArG4Identifier CalculatePS_DMIdentifier( const G4Step* , const G4int indPS , const bool itb) const; + + inline G4int determineZSide(const bool isTestBeam, const double zCoord) const { + // in TB case, only 1 side, + // in Atlas case, use overall z to decide side + if (isTestBeam) { return 1; } + if (zCoord > 0.) { return 1; } + return -1; + } + + // detector name, for translated geometry + std::string m_detectorName; + +#include "PresParameterDef.h" + + // end z of the various modules + G4double m_end_module[8]; + G4double m_zminPS; + G4double m_zpres; + G4double m_cat_th; + // z of first cathode in each module + G4double m_first_cathod[8]; + // tilt of electrodes + G4double m_tilt[8]; + // number of gaps per cell + G4int m_ngap_cell[8]; + // pitch in z of gaps + G4double m_pitch[8]; + // number of cells per modules + G4int m_ncell_module[8]; + // total LAr thickness + G4double m_halfThickLAr; + + // Pointer to detector parameters routine. + LArVG4DetectorParameters* m_parameters; + + } ; + + } //end of Barrel namespace + +} // end of LArG4 namespace + +#endif // LARG4BARREL_LARBARRELPRESAMPLERGEOMETRY_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cc deleted file mode 100644 index 005af8ecb91f..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cc +++ /dev/null @@ -1,99 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/LArCoudeAbsorbers.h" - -LArCoudeAbsorbers* LArCoudeAbsorbers::s_instance=0; - -PhysicalVolumeAccessor* LArCoudeAbsorbers::s_theCoudes=0; - -LArCoudeAbsorbers* LArCoudeAbsorbers::GetInstance(std::string strDetector) -{ - if (s_instance==0) { - s_instance = new LArCoudeAbsorbers(strDetector); - } - return s_instance; -} - - -LArCoudeAbsorbers::LArCoudeAbsorbers(std::string strDetector) -{ - if (s_theCoudes==0) - { - if (strDetector=="") { - s_theCoudes= - new PhysicalVolumeAccessor("LAr::EMB::STAC", - "LAr::EMB::ThinAbs::CornerDownFold"); - s_theCoudes->SetPhysicalVolumeList("LAr::EMB::ThinAbs::CornerUpFold"); - } - else { - s_theCoudes= - new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", - strDetector+"::LAr::EMB::ThinAbs::CornerDownFold"); - s_theCoudes->SetPhysicalVolumeList(strDetector+"::LAr::EMB::ThinAbs::CornerUpFold"); - } - } - - m_filled=false; -// std::cout << " *** List of Fold Absorbers " << std::endl; - for (int stackid=0; stackid<15; stackid++) { - for (int cellid=0; cellid<1024; cellid++) { - m_xcent[cellid][stackid] = XCentCoude(stackid,cellid); - m_ycent[cellid][stackid] = YCentCoude(stackid,cellid); - m_phirot[cellid][stackid] = PhiRot(stackid,cellid); -// std::cout << "cell,stack,x,y,phirot " -// << cellid << " " -// << stackid << " " -// << m_xcent[cellid][stackid] << " " -// << m_ycent[cellid][stackid] << " " -// << m_phirot[cellid][stackid] -// <<std::endl; - } - } - m_filled=true; -} -double LArCoudeAbsorbers::XCentCoude(int stackid, int cellid) -{ - if (m_filled) { - return m_xcent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - return tv.x(); - } -} -double LArCoudeAbsorbers::YCentCoude(int stackid, int cellid) -{ - if (m_filled) { - return m_ycent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - return tv.y(); - } -} -double LArCoudeAbsorbers::PhiRot(int stackid, int cellid) -{ - if (m_filled) { - return m_phirot[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4RotationMatrix *rm=pv->GetRotation(); - double alpha; - if (!rm) alpha=0.; - else alpha = rm->phiX(); - if (pv->GetName().find("DownFold") != std::string::npos) alpha=alpha-3.14159; - // old way was assuming we start with a down fold if (stackid%2==0) alpha=alpha-3.14159; - return alpha; - } -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx new file mode 100644 index 000000000000..29383f8fc005 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.cxx @@ -0,0 +1,99 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCoudeAbsorbers.h" + +LArCoudeAbsorbers* LArCoudeAbsorbers::s_instance=nullptr; + +PhysicalVolumeAccessor* LArCoudeAbsorbers::s_theCoudes=nullptr; + +LArCoudeAbsorbers* LArCoudeAbsorbers::GetInstance(std::string strDetector) +{ + if (s_instance==nullptr) { + s_instance = new LArCoudeAbsorbers(strDetector); + } + return s_instance; +} + + +LArCoudeAbsorbers::LArCoudeAbsorbers(std::string strDetector) +{ + if (s_theCoudes==nullptr) + { + if (strDetector=="") { + s_theCoudes= + new PhysicalVolumeAccessor("LAr::EMB::STAC", + "LAr::EMB::ThinAbs::CornerDownFold"); + s_theCoudes->SetPhysicalVolumeList("LAr::EMB::ThinAbs::CornerUpFold"); + } + else { + s_theCoudes= + new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", + strDetector+"::LAr::EMB::ThinAbs::CornerDownFold"); + s_theCoudes->SetPhysicalVolumeList(strDetector+"::LAr::EMB::ThinAbs::CornerUpFold"); + } + } + + m_filled=false; + // std::cout << " *** List of Fold Absorbers " << std::endl; + for (int stackid=0; stackid<15; stackid++) { + for (int cellid=0; cellid<1024; cellid++) { + m_xcent[cellid][stackid] = XCentCoude(stackid,cellid); + m_ycent[cellid][stackid] = YCentCoude(stackid,cellid); + m_phirot[cellid][stackid] = PhiRot(stackid,cellid); + // std::cout << "cell,stack,x,y,phirot " + // << cellid << " " + // << stackid << " " + // << m_xcent[cellid][stackid] << " " + // << m_ycent[cellid][stackid] << " " + // << m_phirot[cellid][stackid] + // <<std::endl; + } + } + m_filled=true; +} +double LArCoudeAbsorbers::XCentCoude(int stackid, int cellid) const +{ + if (m_filled) { + return m_xcent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + return tv.x(); + } +} +double LArCoudeAbsorbers::YCentCoude(int stackid, int cellid) const +{ + if (m_filled) { + return m_ycent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + return tv.y(); + } +} +double LArCoudeAbsorbers::PhiRot(int stackid, int cellid) const +{ + if (m_filled) { + return m_phirot[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4RotationMatrix *rm=pv->GetRotation(); + double alpha; + if (!rm) alpha=0.; + else alpha = rm->phiX(); + if (pv->GetName().find("DownFold") != std::string::npos) alpha=alpha-3.14159; + // old way was assuming we start with a down fold if (stackid%2==0) alpha=alpha-3.14159; + return alpha; + } +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.h new file mode 100644 index 000000000000..c34d6299f5bf --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeAbsorbers.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4BARREL_LArCoudeAbsorbers_H +#define LARG4BARREL_LArCoudeAbsorbers_H + +#include "PhysicalVolumeAccessor.h" +#include <string> + +class LArCoudeAbsorbers { +private: + static PhysicalVolumeAccessor* s_theCoudes; + double m_xcent[1024][15]; + double m_ycent[1024][15]; + double m_phirot[1024][15]; + bool m_filled; + static LArCoudeAbsorbers* s_instance; +public: + static LArCoudeAbsorbers* GetInstance(std::string strDetector="") ; + double XCentCoude(int stackid, int cellid) const; + double YCentCoude(int stackid, int cellid) const; + double PhiRot(int stackid, int cellid) const; +protected: + LArCoudeAbsorbers(std::string strDetector="") ; +}; + +#endif // LARG4BARREL_LArCoudeAbsorbers_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cc deleted file mode 100644 index 5b1e22ad914b..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/LArCoudeElectrodes.h" - -LArCoudeElectrodes* LArCoudeElectrodes::s_instance=0; - -PhysicalVolumeAccessor* LArCoudeElectrodes::s_theCoudes=0; - -LArCoudeElectrodes* LArCoudeElectrodes::GetInstance(std::string strDetector) -{ - if (s_instance==0) { - s_instance = new LArCoudeElectrodes(strDetector); - } - return s_instance; -} - - -LArCoudeElectrodes::LArCoudeElectrodes(std::string strDetector) -{ - if (s_theCoudes==0) - { - if (strDetector=="") { - s_theCoudes= - new PhysicalVolumeAccessor("LAr::EMB::STAC", - "LAr::EMB::Electrode::CornerDownFold"); - s_theCoudes->SetPhysicalVolumeList("LAr::EMB::Electrode::CornerUpFold"); - } - else { - s_theCoudes= - new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", - strDetector+"::LAr::EMB::Electrode::CornerDownFold"); - s_theCoudes->SetPhysicalVolumeList(strDetector+"::LAr::EMB::Electrode::CornerUpFold"); - } - } - m_filled=false; -// std::cout << " *** List of fold electrodes " << std::endl; - for (int stackid=0; stackid<15; stackid++) { - for (int cellid=0; cellid<1024; cellid++) { - m_xcent[cellid][stackid] = XCentCoude(stackid,cellid); - m_ycent[cellid][stackid] = YCentCoude(stackid,cellid); - m_phirot[cellid][stackid] = PhiRot(stackid,cellid); -// std::cout << "cell,stack,x,y,phirot " -// << cellid << " " -// << stackid << " " -// << m_xcent[cellid][stackid] << " " -// << m_ycent[cellid][stackid] << " " -// << m_phirot[cellid][stackid] -// <<std::endl; - - } - } - m_filled=true; -} -double LArCoudeElectrodes::XCentCoude(int stackid, int cellid) -{ - if (m_filled) { - return m_xcent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - return tv.x(); - } -} -double LArCoudeElectrodes::YCentCoude(int stackid, int cellid) -{ - if (m_filled) { - return m_ycent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - return tv.y(); - } -} -double LArCoudeElectrodes::PhiRot(int stackid, int cellid) -{ - if (m_filled) { - return m_phirot[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4RotationMatrix *rm=pv->GetRotation(); - double alpha; - if (!rm) alpha=0.; - else alpha = rm->phiX(); -// for down fold - if (pv->GetName().find("DownFold") != std::string::npos) alpha=alpha-3.14159; - // old way was assuming we start with a down fold if (stackid%2==0) alpha=alpha-3.14159; - return alpha; - } -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx new file mode 100644 index 000000000000..0a1d773381d6 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.cxx @@ -0,0 +1,100 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCoudeElectrodes.h" + +LArCoudeElectrodes* LArCoudeElectrodes::s_instance=nullptr; + +PhysicalVolumeAccessor* LArCoudeElectrodes::s_theCoudes=nullptr; + +LArCoudeElectrodes* LArCoudeElectrodes::GetInstance(std::string strDetector) +{ + if (s_instance==nullptr) { + s_instance = new LArCoudeElectrodes(strDetector); + } + return s_instance; +} + + +LArCoudeElectrodes::LArCoudeElectrodes(std::string strDetector) +{ + if (s_theCoudes==nullptr) + { + if (strDetector=="") { + s_theCoudes= + new PhysicalVolumeAccessor("LAr::EMB::STAC", + "LAr::EMB::Electrode::CornerDownFold"); + s_theCoudes->SetPhysicalVolumeList("LAr::EMB::Electrode::CornerUpFold"); + } + else { + s_theCoudes= + new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", + strDetector+"::LAr::EMB::Electrode::CornerDownFold"); + s_theCoudes->SetPhysicalVolumeList(strDetector+"::LAr::EMB::Electrode::CornerUpFold"); + } + } + m_filled=false; + // std::cout << " *** List of fold electrodes " << std::endl; + for (int stackid=0; stackid<15; stackid++) { + for (int cellid=0; cellid<1024; cellid++) { + m_xcent[cellid][stackid] = XCentCoude(stackid,cellid); + m_ycent[cellid][stackid] = YCentCoude(stackid,cellid); + m_phirot[cellid][stackid] = PhiRot(stackid,cellid); + // std::cout << "cell,stack,x,y,phirot " + // << cellid << " " + // << stackid << " " + // << m_xcent[cellid][stackid] << " " + // << m_ycent[cellid][stackid] << " " + // << m_phirot[cellid][stackid] + // <<std::endl; + + } + } + m_filled=true; +} +double LArCoudeElectrodes::XCentCoude(int stackid, int cellid) const +{ + if (m_filled) { + return m_xcent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + return tv.x(); + } +} +double LArCoudeElectrodes::YCentCoude(int stackid, int cellid) const +{ + if (m_filled) { + return m_ycent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + return tv.y(); + } +} +double LArCoudeElectrodes::PhiRot(int stackid, int cellid) const +{ + if (m_filled) { + return m_phirot[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4RotationMatrix *rm=pv->GetRotation(); + double alpha; + if (!rm) alpha=0.; + else alpha = rm->phiX(); + // for down fold + if (pv->GetName().find("DownFold") != std::string::npos) alpha=alpha-3.14159; + // old way was assuming we start with a down fold if (stackid%2==0) alpha=alpha-3.14159; + return alpha; + } +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.h new file mode 100644 index 000000000000..d532ea802026 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudeElectrodes.h @@ -0,0 +1,28 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4BARREL_LArCoudeElectrodes_H +#define LARG4BARREL_LArCoudeElectrodes_H + +#include "PhysicalVolumeAccessor.h" +#include <string> + +class LArCoudeElectrodes { +private: + static PhysicalVolumeAccessor* s_theCoudes; + double m_xcent[1024][15]; + double m_ycent[1024][15]; + double m_phirot[1024][15]; + bool m_filled; + static LArCoudeElectrodes* s_instance; +public: + static LArCoudeElectrodes* GetInstance(std::string strDetector="") ; + double XCentCoude(int stackid, int cellid) const; + double YCentCoude(int stackid, int cellid) const; + double PhiRot(int stackid, int cellid) const; +protected: + LArCoudeElectrodes(std::string strDetector="") ; +}; + +#endif // LARG4BARREL_LArCoudeElectrodes_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cc deleted file mode 100644 index 589df6718a8b..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cc +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/LArCoudes.h" - -PhysicalVolumeAccessor* LArCoudes::s_theCoudes=0; - -LArCoudes::LArCoudes(std::string strDetector) -{ - if (s_theCoudes==0) - { - if(strDetector=="") - { - s_theCoudes= - new PhysicalVolumeAccessor("LAr::EMB::STAC", - "LAr::EMB::Electrode::CornerDownFold"); - s_theCoudes->SetPhysicalVolumeList("LAr::EMB::Electrode::CornerUpFold"); - } - else - { - s_theCoudes= - new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", - strDetector+"::LAr::EMB::Electrode::CornerDownFold"); - s_theCoudes->SetPhysicalVolumeList(strDetector+"::LAr::EMB::Electrode::CornerUpFold"); - } - } -} -double LArCoudes::XCentCoude(int stackid, int cellid) -{ - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) std::abort(); - const G4ThreeVector& tv=pv->GetTranslation(); - return tv.x(); -} -double LArCoudes::YCentCoude(int stackid, int cellid) -{ - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); - if (!pv) std::abort(); - const G4ThreeVector& tv=pv->GetTranslation(); - return tv.y(); -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cxx new file mode 100644 index 000000000000..74335fda64e8 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.cxx @@ -0,0 +1,44 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArCoudes.h" + +PhysicalVolumeAccessor* LArCoudes::s_theCoudes=nullptr; + +LArCoudes::LArCoudes(std::string strDetector) +{ + if (s_theCoudes==nullptr) + { + if(strDetector=="") + { + s_theCoudes= + new PhysicalVolumeAccessor("LAr::EMB::STAC", + "LAr::EMB::Electrode::CornerDownFold"); + s_theCoudes->SetPhysicalVolumeList("LAr::EMB::Electrode::CornerUpFold"); + } + else + { + s_theCoudes= + new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", + strDetector+"::LAr::EMB::Electrode::CornerDownFold"); + s_theCoudes->SetPhysicalVolumeList(strDetector+"::LAr::EMB::Electrode::CornerUpFold"); + } + } +} +double LArCoudes::XCentCoude(int stackid, int cellid) const +{ + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) std::abort(); + const G4ThreeVector& tv=pv->GetTranslation(); + return tv.x(); +} +double LArCoudes::YCentCoude(int stackid, int cellid) const +{ + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theCoudes->GetPhysicalVolume(id); + if (!pv) std::abort(); + const G4ThreeVector& tv=pv->GetTranslation(); + return tv.y(); +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.h new file mode 100644 index 000000000000..ef47d013179d --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArCoudes.h @@ -0,0 +1,19 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4BARREL_LArCoudes_H +#define LARG4BARREL_LArCoudes_H + +#include "PhysicalVolumeAccessor.h" + +class LArCoudes { +private: + static PhysicalVolumeAccessor* s_theCoudes; +public: + LArCoudes(std::string strDetector="") ; + double XCentCoude(int stackid, int cellid) const; + double YCentCoude(int stackid, int cellid) const; +}; + +#endif // LARG4BARREL_LArCoudes_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cc deleted file mode 100644 index d79c0fb4aaaa..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cc +++ /dev/null @@ -1,165 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/LArStraightAbsorbers.h" -#include "G4LogicalVolume.hh" -#include "G4VSolid.hh" -#include "G4Trap.hh" -#include "LArG4Code/LArVG4DetectorParameters.h" - -LArStraightAbsorbers* LArStraightAbsorbers::s_instance=0; - -PhysicalVolumeAccessor* LArStraightAbsorbers::s_theAbsorbers=0; - -LArStraightAbsorbers* LArStraightAbsorbers::GetInstance(std::string strDetector) -{ - if (s_instance==0) { - s_instance = new LArStraightAbsorbers(strDetector); - } - return s_instance; -} - - -LArStraightAbsorbers::LArStraightAbsorbers(std::string strDetector) -{ - LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); - if (parameters->GetValue("LArEMBPhiAtCurvature",0)>0.) m_parity=0; // first wave goes up - else m_parity=1; // first wave goes down - - if (s_theAbsorbers==0) { - if (strDetector=="") - s_theAbsorbers = new PhysicalVolumeAccessor("LAr::EMB::STAC", - "LAr::EMB::ThinAbs::Straight"); - else - s_theAbsorbers = new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", - strDetector+"::LAr::EMB::ThinAbs::Straight"); - } - m_filled=false; -// std::cout << " *** List of Straight absorbers " << std::endl; - for (int stackid=0; stackid<14; stackid++) { - for (int cellid=0; cellid<1024; cellid++) { - m_xcent[cellid][stackid] = XCentAbs(stackid,cellid); - m_ycent[cellid][stackid] = YCentAbs(stackid,cellid); - double slant=SlantAbs(stackid,cellid); - m_cosu[cellid][stackid] = cos(slant); - m_sinu[cellid][stackid] = sin(slant); - m_halflength[cellid][stackid] = HalfLength(stackid,cellid); -// std::cout << "cell,stack,x,y,slant,HalfL " -// << cellid << " " -// << stackid << " " -// << m_xcent[cellid][stackid] << " " -// << m_ycent[cellid][stackid] << " " -// << slant << " " -// << m_halflength[cellid][stackid] -// <<std::endl; - - } - } - m_filled=true; -} -double LArStraightAbsorbers::XCentAbs(int stackid, int cellid) -{ - if (m_filled) { - return m_xcent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - const G4VPhysicalVolume *pv2=s_theAbsorbers->GetPhysicalVolume(1000000+id); - if (!pv2) return tv.x(); - else { - const G4ThreeVector& tv2=pv2->GetTranslation(); - const G4LogicalVolume* lv = pv->GetLogicalVolume(); - const G4Trap* trap = (G4Trap*) lv->GetSolid(); - const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); - const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); - double xl1=trap->GetYHalfLength1(); - double xl2=trap2->GetYHalfLength1(); - double x = (tv.x()*xl1+tv2.x()*xl2)/(xl1+xl2); - return x; - } - } -} -double LArStraightAbsorbers::YCentAbs(int stackid, int cellid) -{ - if (m_filled) { - return m_ycent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - const G4VPhysicalVolume *pv2=s_theAbsorbers->GetPhysicalVolume(1000000+id); - if (!pv2) return tv.y(); - else { - const G4ThreeVector& tv2=pv2->GetTranslation(); - const G4LogicalVolume* lv = pv->GetLogicalVolume(); - const G4Trap* trap = (G4Trap*) lv->GetSolid(); - const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); - const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); - double xl1=trap->GetYHalfLength1(); - double xl2=trap2->GetYHalfLength1(); - double y = (tv.y()*xl1+tv2.y()*xl2)/(xl1+xl2); - return y; - - } - } -} -double LArStraightAbsorbers::SlantAbs(int stackid, int cellid) -{ - // both stackid and cellid start from 0 in the following code - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4RotationMatrix *rm=pv->GetRotation(); - double Slant; - Slant = (stackid%2 ==m_parity) ? 180*CLHEP::deg-(rm->thetaY()):(rm->thetaY())-180*CLHEP::deg; - if((stackid%2 == m_parity) && (rm->phiY() > 0)) Slant = 360.*CLHEP::deg - Slant; - if((stackid%2 == (1-m_parity)) && (rm->phiY() < 0)) Slant = - Slant; - return Slant; -} -double LArStraightAbsorbers::HalfLength(int stackid, int cellid) -{ - if (m_filled) { - return m_halflength[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4LogicalVolume* lv = pv->GetLogicalVolume(); - const G4Trap* trap = (G4Trap*) lv->GetSolid(); - const G4VPhysicalVolume *pv2=s_theAbsorbers->GetPhysicalVolume(1000000+id); - if (!pv2) return trap->GetYHalfLength1(); - else { - const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); - const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); - return (trap->GetYHalfLength1()+trap2->GetYHalfLength1()); - } - } - -} - -double LArStraightAbsorbers::Cosu(int stackid, int cellid) -{ - if (m_filled) { - return m_cosu[cellid][stackid]; - } - else { - return cos(SlantAbs(stackid,cellid)); - } -} -double LArStraightAbsorbers::Sinu(int stackid, int cellid) -{ - if (m_filled) { - return m_sinu[cellid][stackid]; - } - else { - return sin(SlantAbs(stackid,cellid)); - } -} - diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx new file mode 100644 index 000000000000..5fd9066bcf12 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.cxx @@ -0,0 +1,164 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArStraightAbsorbers.h" +#include "G4LogicalVolume.hh" +#include "G4VSolid.hh" +#include "G4Trap.hh" +#include "LArG4Code/LArVG4DetectorParameters.h" + +LArStraightAbsorbers* LArStraightAbsorbers::s_instance=nullptr; + +PhysicalVolumeAccessor* LArStraightAbsorbers::s_theAbsorbers=nullptr; + +LArStraightAbsorbers* LArStraightAbsorbers::GetInstance(std::string strDetector) +{ + if (s_instance==nullptr) { + s_instance = new LArStraightAbsorbers(strDetector); + } + return s_instance; +} + + +LArStraightAbsorbers::LArStraightAbsorbers(std::string strDetector) +{ + LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); + if (parameters->GetValue("LArEMBPhiAtCurvature",0)>0.) m_parity=0; // first wave goes up + else m_parity=1; // first wave goes down + + if (s_theAbsorbers==nullptr) { + if (strDetector=="") + s_theAbsorbers = new PhysicalVolumeAccessor("LAr::EMB::STAC", + "LAr::EMB::ThinAbs::Straight"); + else + s_theAbsorbers = new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", + strDetector+"::LAr::EMB::ThinAbs::Straight"); + } + m_filled=false; + // std::cout << " *** List of Straight absorbers " << std::endl; + for (int stackid=0; stackid<14; stackid++) { + for (int cellid=0; cellid<1024; cellid++) { + m_xcent[cellid][stackid] = XCentAbs(stackid,cellid); + m_ycent[cellid][stackid] = YCentAbs(stackid,cellid); + double slant=SlantAbs(stackid,cellid); + m_cosu[cellid][stackid] = cos(slant); + m_sinu[cellid][stackid] = sin(slant); + m_halflength[cellid][stackid] = HalfLength(stackid,cellid); + // std::cout << "cell,stack,x,y,slant,HalfL " + // << cellid << " " + // << stackid << " " + // << m_xcent[cellid][stackid] << " " + // << m_ycent[cellid][stackid] << " " + // << slant << " " + // << m_halflength[cellid][stackid] + // <<std::endl; + + } + } + m_filled=true; +} +double LArStraightAbsorbers::XCentAbs(int stackid, int cellid) const +{ + if (m_filled) { + return m_xcent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + const G4VPhysicalVolume *pv2=s_theAbsorbers->GetPhysicalVolume(1000000+id); + if (!pv2) return tv.x(); + else { + const G4ThreeVector& tv2=pv2->GetTranslation(); + const G4LogicalVolume* lv = pv->GetLogicalVolume(); + const G4Trap* trap = (G4Trap*) lv->GetSolid(); + const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); + const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); + double xl1=trap->GetYHalfLength1(); + double xl2=trap2->GetYHalfLength1(); + double x = (tv.x()*xl1+tv2.x()*xl2)/(xl1+xl2); + return x; + } + } +} +double LArStraightAbsorbers::YCentAbs(int stackid, int cellid) const +{ + if (m_filled) { + return m_ycent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + const G4VPhysicalVolume *pv2=s_theAbsorbers->GetPhysicalVolume(1000000+id); + if (!pv2) return tv.y(); + else { + const G4ThreeVector& tv2=pv2->GetTranslation(); + const G4LogicalVolume* lv = pv->GetLogicalVolume(); + const G4Trap* trap = (G4Trap*) lv->GetSolid(); + const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); + const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); + double xl1=trap->GetYHalfLength1(); + double xl2=trap2->GetYHalfLength1(); + double y = (tv.y()*xl1+tv2.y()*xl2)/(xl1+xl2); + return y; + + } + } +} +double LArStraightAbsorbers::SlantAbs(int stackid, int cellid) const +{ + // both stackid and cellid start from 0 in the following code + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4RotationMatrix *rm=pv->GetRotation(); + double Slant; + Slant = (stackid%2 ==m_parity) ? 180*CLHEP::deg-(rm->thetaY()):(rm->thetaY())-180*CLHEP::deg; + if((stackid%2 == m_parity) && (rm->phiY() > 0)) Slant = 360.*CLHEP::deg - Slant; + if((stackid%2 == (1-m_parity)) && (rm->phiY() < 0)) Slant = - Slant; + return Slant; +} +double LArStraightAbsorbers::HalfLength(int stackid, int cellid) const +{ + if (m_filled) { + return m_halflength[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theAbsorbers->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4LogicalVolume* lv = pv->GetLogicalVolume(); + const G4Trap* trap = (G4Trap*) lv->GetSolid(); + const G4VPhysicalVolume *pv2=s_theAbsorbers->GetPhysicalVolume(1000000+id); + if (!pv2) return trap->GetYHalfLength1(); + else { + const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); + const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); + return (trap->GetYHalfLength1()+trap2->GetYHalfLength1()); + } + } + +} + +double LArStraightAbsorbers::Cosu(int stackid, int cellid) const +{ + if (m_filled) { + return m_cosu[cellid][stackid]; + } + else { + return cos(SlantAbs(stackid,cellid)); + } +} +double LArStraightAbsorbers::Sinu(int stackid, int cellid) const +{ + if (m_filled) { + return m_sinu[cellid][stackid]; + } + else { + return sin(SlantAbs(stackid,cellid)); + } +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.h new file mode 100644 index 000000000000..3c01efaf57e7 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightAbsorbers.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4BARREL_LArStraightAbsorbers_H +#define LARG4BARREL_LArStraightAbsorbers_H + +#include "PhysicalVolumeAccessor.h" +#include <string> + +class LArStraightAbsorbers { +private: + static PhysicalVolumeAccessor* s_theAbsorbers; + double m_xcent[1024][14]; + double m_ycent[1024][14]; + double m_cosu[1024][14]; + double m_sinu[1024][14]; + double m_halflength[1024][14]; + bool m_filled; + static LArStraightAbsorbers* s_instance; + int m_parity; +public: + static LArStraightAbsorbers* GetInstance(std::string strDetector="") ; + double XCentAbs(int stackid, int cellid) const; + double YCentAbs(int stackid, int cellid) const; + double SlantAbs(int stackid, int cellid) const; + double HalfLength(int stackid, int cellid) const; + double Cosu(int stackid, int cellid) const; + double Sinu(int stackid, int cellid) const; +protected: + LArStraightAbsorbers(std::string strDetector="") ; +}; + +#endif // LARG4BARREL_LArStraightAbsorbers_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cc deleted file mode 100644 index b7bbffada7dc..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cc +++ /dev/null @@ -1,164 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/LArStraightElectrodes.h" -#include "G4LogicalVolume.hh" -#include "G4VSolid.hh" -#include "G4Trap.hh" -#include "LArG4Code/LArVG4DetectorParameters.h" - -LArStraightElectrodes* LArStraightElectrodes::s_instance=0; - -PhysicalVolumeAccessor* LArStraightElectrodes::s_theElectrodes=0; - -LArStraightElectrodes* LArStraightElectrodes::GetInstance(std::string strDetector) -{ - if (s_instance==0) { - s_instance = new LArStraightElectrodes(strDetector); - } - return s_instance; -} - -LArStraightElectrodes::LArStraightElectrodes(std::string strDetector) -{ - LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); - if (parameters->GetValue("LArEMBPhiAtCurvature",0)>0.) m_parity=0; // first wave goes up - else m_parity=1; // first wave goes down - - if (s_theElectrodes==0) { - if (strDetector=="") - s_theElectrodes=new PhysicalVolumeAccessor("LAr::EMB::STAC", - "LAr::EMB::Electrode::Straight"); - else - s_theElectrodes=new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", - strDetector+"::LAr::EMB::Electrode::Straight"); - } -// std::cout << "*** List of StraightElectrodes " << s_theElectrodes << std::endl; - m_filled=false; - for (int stackid=0; stackid<14; stackid++) { - for (int cellid=0; cellid<1024; cellid++) { - m_xcent[cellid][stackid] = XCentEle(stackid,cellid); - m_ycent[cellid][stackid] = YCentEle(stackid,cellid); - double slant=SlantEle(stackid,cellid); - m_cosu[cellid][stackid] = cos(slant); - m_sinu[cellid][stackid] = sin(slant); - m_halflength[cellid][stackid] = HalfLength(stackid,cellid); -// std::cout << "cell,stack,x,y,slant,HalfL " -// << cellid << " " -// << stackid << " " -// << m_xcent[cellid][stackid] << " " -// << m_ycent[cellid][stackid] << " " -// << slant << " " -// << m_halflength[cellid][stackid] -// <<std::endl; - } - } - m_filled=true; -} - -double LArStraightElectrodes::XCentEle(int stackid, int cellid) -{ - if (m_filled) { - return m_xcent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - const G4VPhysicalVolume *pv2=s_theElectrodes->GetPhysicalVolume(1000000+id); - if (!pv2) return tv.x(); - else { - const G4ThreeVector& tv2=pv2->GetTranslation(); - const G4LogicalVolume* lv = pv->GetLogicalVolume(); - const G4Trap* trap = (G4Trap*) lv->GetSolid(); - const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); - const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); - double xl1=trap->GetYHalfLength1(); - double xl2=trap2->GetYHalfLength1(); - double x = (tv.x()*xl1+tv2.x()*xl2)/(xl1+xl2); - return x; - } - - } -} -double LArStraightElectrodes::YCentEle(int stackid, int cellid) -{ - if (m_filled) { - return m_ycent[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4ThreeVector& tv=pv->GetTranslation(); - const G4VPhysicalVolume *pv2=s_theElectrodes->GetPhysicalVolume(1000000+id); - if (!pv2) return tv.y(); - else { - const G4ThreeVector& tv2=pv2->GetTranslation(); - const G4LogicalVolume* lv = pv->GetLogicalVolume(); - const G4Trap* trap = (G4Trap*) lv->GetSolid(); - const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); - const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); - double xl1=trap->GetYHalfLength1(); - double xl2=trap2->GetYHalfLength1(); - double y = (tv.y()*xl1+tv2.y()*xl2)/(xl1+xl2); - return y; - - } - - } -} -double LArStraightElectrodes::SlantEle(int stackid, int cellid) -{ - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4RotationMatrix *rm=pv->GetRotation(); - double Slant; - Slant = (stackid%2 ==m_parity) ? 180*CLHEP::deg-(rm->thetaY()):(rm->thetaY())-180*CLHEP::deg; - if((stackid%2 == m_parity) && (rm->phiY() > 0)) Slant = 360.*CLHEP::deg - Slant; - if((stackid%2 == (1-m_parity)) && (rm->phiY() < 0)) Slant = - Slant; - return Slant; -} -double LArStraightElectrodes::HalfLength(int stackid, int cellid) -{ - if (m_filled) { - return m_halflength[cellid][stackid]; - } - else { - int id=cellid+stackid*10000; - const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); - if (!pv) return 0.; - const G4LogicalVolume* lv = pv->GetLogicalVolume(); - const G4Trap* trap = (G4Trap*) lv->GetSolid(); - const G4VPhysicalVolume *pv2=s_theElectrodes->GetPhysicalVolume(1000000+id); - if (!pv2) return trap->GetYHalfLength1(); - else { - const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); - const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); - return (trap->GetYHalfLength1()+trap2->GetYHalfLength1()); - } - - } -} -double LArStraightElectrodes::Cosu(int stackid, int cellid) -{ - if (m_filled) { - return m_cosu[cellid][stackid]; - } - else { - return cos(SlantEle(stackid,cellid)); - } -} -double LArStraightElectrodes::Sinu(int stackid, int cellid) -{ - if (m_filled) { - return m_sinu[cellid][stackid]; - } - else { - return sin(SlantEle(stackid,cellid)); - } -} - diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx new file mode 100644 index 000000000000..b3b841d48124 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.cxx @@ -0,0 +1,163 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArStraightElectrodes.h" +#include "G4LogicalVolume.hh" +#include "G4VSolid.hh" +#include "G4Trap.hh" +#include "LArG4Code/LArVG4DetectorParameters.h" + +LArStraightElectrodes* LArStraightElectrodes::s_instance=nullptr; + +PhysicalVolumeAccessor* LArStraightElectrodes::s_theElectrodes=nullptr; + +LArStraightElectrodes* LArStraightElectrodes::GetInstance(std::string strDetector) +{ + if (s_instance==nullptr) { + s_instance = new LArStraightElectrodes(strDetector); + } + return s_instance; +} + +LArStraightElectrodes::LArStraightElectrodes(std::string strDetector) +{ + LArVG4DetectorParameters* parameters = LArVG4DetectorParameters::GetInstance(); + if (parameters->GetValue("LArEMBPhiAtCurvature",0)>0.) m_parity=0; // first wave goes up + else m_parity=1; // first wave goes down + + if (s_theElectrodes==nullptr) { + if (strDetector=="") + s_theElectrodes=new PhysicalVolumeAccessor("LAr::EMB::STAC", + "LAr::EMB::Electrode::Straight"); + else + s_theElectrodes=new PhysicalVolumeAccessor(strDetector+"::LAr::EMB::STAC", + strDetector+"::LAr::EMB::Electrode::Straight"); + } + // std::cout << "*** List of StraightElectrodes " << s_theElectrodes << std::endl; + m_filled=false; + for (int stackid=0; stackid<14; stackid++) { + for (int cellid=0; cellid<1024; cellid++) { + m_xcent[cellid][stackid] = XCentEle(stackid,cellid); + m_ycent[cellid][stackid] = YCentEle(stackid,cellid); + double slant=SlantEle(stackid,cellid); + m_cosu[cellid][stackid] = cos(slant); + m_sinu[cellid][stackid] = sin(slant); + m_halflength[cellid][stackid] = HalfLength(stackid,cellid); + // std::cout << "cell,stack,x,y,slant,HalfL " + // << cellid << " " + // << stackid << " " + // << m_xcent[cellid][stackid] << " " + // << m_ycent[cellid][stackid] << " " + // << slant << " " + // << m_halflength[cellid][stackid] + // <<std::endl; + } + } + m_filled=true; +} + +double LArStraightElectrodes::XCentEle(int stackid, int cellid) const +{ + if (m_filled) { + return m_xcent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + const G4VPhysicalVolume *pv2=s_theElectrodes->GetPhysicalVolume(1000000+id); + if (!pv2) return tv.x(); + else { + const G4ThreeVector& tv2=pv2->GetTranslation(); + const G4LogicalVolume* lv = pv->GetLogicalVolume(); + const G4Trap* trap = (G4Trap*) lv->GetSolid(); + const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); + const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); + double xl1=trap->GetYHalfLength1(); + double xl2=trap2->GetYHalfLength1(); + double x = (tv.x()*xl1+tv2.x()*xl2)/(xl1+xl2); + return x; + } + + } +} +double LArStraightElectrodes::YCentEle(int stackid, int cellid) const +{ + if (m_filled) { + return m_ycent[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4ThreeVector& tv=pv->GetTranslation(); + const G4VPhysicalVolume *pv2=s_theElectrodes->GetPhysicalVolume(1000000+id); + if (!pv2) return tv.y(); + else { + const G4ThreeVector& tv2=pv2->GetTranslation(); + const G4LogicalVolume* lv = pv->GetLogicalVolume(); + const G4Trap* trap = (G4Trap*) lv->GetSolid(); + const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); + const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); + double xl1=trap->GetYHalfLength1(); + double xl2=trap2->GetYHalfLength1(); + double y = (tv.y()*xl1+tv2.y()*xl2)/(xl1+xl2); + return y; + + } + + } +} +double LArStraightElectrodes::SlantEle(int stackid, int cellid) const +{ + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4RotationMatrix *rm=pv->GetRotation(); + double Slant; + Slant = (stackid%2 ==m_parity) ? 180*CLHEP::deg-(rm->thetaY()):(rm->thetaY())-180*CLHEP::deg; + if((stackid%2 == m_parity) && (rm->phiY() > 0)) Slant = 360.*CLHEP::deg - Slant; + if((stackid%2 == (1-m_parity)) && (rm->phiY() < 0)) Slant = - Slant; + return Slant; +} +double LArStraightElectrodes::HalfLength(int stackid, int cellid) const +{ + if (m_filled) { + return m_halflength[cellid][stackid]; + } + else { + int id=cellid+stackid*10000; + const G4VPhysicalVolume *pv=s_theElectrodes->GetPhysicalVolume(id); + if (!pv) return 0.; + const G4LogicalVolume* lv = pv->GetLogicalVolume(); + const G4Trap* trap = (G4Trap*) lv->GetSolid(); + const G4VPhysicalVolume *pv2=s_theElectrodes->GetPhysicalVolume(1000000+id); + if (!pv2) return trap->GetYHalfLength1(); + else { + const G4LogicalVolume* lv2 = pv2->GetLogicalVolume(); + const G4Trap* trap2 = (G4Trap*) lv2->GetSolid(); + return (trap->GetYHalfLength1()+trap2->GetYHalfLength1()); + } + + } +} +double LArStraightElectrodes::Cosu(int stackid, int cellid) const +{ + if (m_filled) { + return m_cosu[cellid][stackid]; + } + else { + return cos(SlantEle(stackid,cellid)); + } +} +double LArStraightElectrodes::Sinu(int stackid, int cellid) const +{ + if (m_filled) { + return m_sinu[cellid][stackid]; + } + else { + return sin(SlantEle(stackid,cellid)); + } +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.h b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.h new file mode 100644 index 000000000000..0bdddddbd079 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/LArStraightElectrodes.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4BARREL_LArStraightElectrodes_H +#define LARG4BARREL_LArStraightElectrodes_H + +#include "PhysicalVolumeAccessor.h" +#include <string> + +class LArStraightElectrodes { +private: + static PhysicalVolumeAccessor* s_theElectrodes; + double m_xcent[1024][14]; + double m_ycent[1024][14]; + double m_cosu[1024][14]; + double m_sinu[1024][14]; + double m_halflength[1024][14]; + bool m_filled; + static LArStraightElectrodes* s_instance; + int m_parity; +public: + static LArStraightElectrodes* GetInstance(std::string strDetector="") ; + double XCentEle(int stackid, int cellid) const; + double YCentEle(int stackid, int cellid) const; + double SlantEle(int stackid, int cellid) const; + double HalfLength(int stackid, int cellid) const; + double Cosu(int stackid, int cellid) const; + double Sinu(int stackid, int cellid) const; +protected: + LArStraightElectrodes(std::string strDetector=""); +}; + +#endif // LARG4BARREL_LArStraightElectrodes_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cc deleted file mode 100644 index 7ab8aaf7eb2e..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/MapEta.h" - -// For reading the data files in Athena. -#ifndef LARG4_STAND_ALONE -#include "PathResolver/PathResolver.h" -#endif - -#include <iostream> -#include <iomanip> -#include <sstream> -#include <fstream> - -MapEta::MapEta(int isampling) -{ - m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; - m_nx=0; - m_ny=0; - m_init=0; - m_resp=0; - m_xt0=0; - m_xt1=0; - m_xt2=0; - Initialize(isampling); -} - -MapEta::~MapEta() -{ - if (m_resp) delete [] m_resp; - if (m_xt0) delete [] m_xt0; - if (m_xt1) delete [] m_xt1; - if (m_xt2) delete [] m_xt2; -} - - -void MapEta::SetDirectory(std::string dir) -{ - m_directory=dir; -} - -void MapEta::Initialize(int isampling) -{ - if (m_init==1) return; - if (isampling < 1 || isampling >3) return; - std::ostringstream fn; - if (isampling==1) fn<<"deta_strip.map"; - if (isampling==2) fn<<"deta_middle.map"; - if (isampling==3) fn<<"eta_trans.map"; - std::string filename = fn.str(); - filename=filename.substr(0,15); - std::string fileLocation; -#ifdef LARG4_STAND_ALONE - // The stand-alone program expects to find the file via AFS. - fileLocation = m_directory + "/" + filename; -#else - // In Athena, the PathResolver tool will find the file for us. - std::cout << "filename " << filename << std::endl; - //std::string larLocation = PathResolver::find_directory("lar","DATAPATH"); - //fileLocation=larLocation+"/calo_data/"+filename; - std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA"); - fileLocation=larLocation+"/"+filename; - std::cout << "fileLocation " << fileLocation << std::endl; -#endif - - std::ifstream in(fileLocation.c_str()); - if (in) - { - in>>m_nx>>m_xmin>>m_xmax>>m_ny>>m_ymin>>m_ymax; - if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000){//coverity issue. This is a tainted variable protection, 10000 can be changed if required. - //std::cout<<"nx"<<";"<<"ny="<<m_nx<<";"<<m_ny<<std::endl; - m_deltax=(m_xmax-m_xmin)/((float) m_nx); - m_deltay=(m_ymax-m_ymin)/((float) m_ny); - // what is written as xmax in the map is x of last point + delta x - // (such that npoint = (xmax-xmin)/deltax - // to get the real last point in the map we should subtract deltax - m_xmax = m_xmax - m_deltax; - m_ymax = m_ymax - m_deltay; - m_resp = new float[m_ny*m_nx]; - m_xt0 = new float[m_ny*m_nx]; - m_xt1 = new float[m_ny*m_nx]; - m_xt2 = new float[m_ny*m_nx]; - int ii,jj; - for (int ix=0;ix<m_nx;ix++) { - for (int iy=0;iy<m_ny;iy++) { - in>>ii>>jj>>m_resp[ix+iy*m_nx]>>m_xt0[ix+iy*m_nx]>>m_xt1[ix+iy*m_nx]>>m_xt2[ix+iy*m_nx]; - if (ii != ix || jj != iy) std::cout << "MapEta: inconsistency when reading map..." << std::endl; - } - } - - std::cout << "Eta Map read " << " Nbins " << m_nx << " " << m_ny - << " bin size*1000 " << 1000*m_deltax << " " << 1000*m_deltay - << " X range " << m_xmin << " " << m_xmax - << " Y range " << m_ymin << " " << m_ymax << std::endl; - m_init=1; - } - else{ - std::cout << "Error in MapEta::Initialize: nx or ny out of limits." << std::endl; - return; - } - } - else{ - std::cout << "Error in MapEta::Initialize: The file could not be open." << std::endl; - return; - } -} - -void MapEta::GetData(double x,double y,double* resp, double* xt0, double* xt1, double* xt2) -{ - *resp=1; - *xt0=1; - *xt1=0; - *xt2=0; - if (m_nx==0 || m_ny ==0) return; - if (x<m_xmin ) x=m_xmin+0.01*m_deltax; - if (x>=m_xmax) x=m_xmax-0.01*m_deltax; - if (y<m_ymin ) y=m_ymin+0.01*m_deltay; - if (y>=m_ymax) y=m_ymax-0.01*m_deltay; - - int ix,iy; - ix = (int) ((x-m_xmin)/m_deltax); - iy = (int) ((y-m_ymin)/m_deltay); - float x0 = ((float) ix)*m_deltax+m_xmin; - float x1 = x0+m_deltax; - float y0 = ((float) iy)*m_deltay+m_ymin; - float y1 = y0+m_deltay; - - - if (ix<0 || ix+1 >= m_nx || iy<0 || iy+1 >= m_ny) { - std::cout << "MapEta: Out of range " << ix << " " << iy << std::endl; - return; - } - double w[4]; - w[0]=(x1-x)*(y1-y); - w[1]=(x-x0)*(y1-y); - w[2]=(x1-x)*(y-y0); - w[3]=(x-x0)*(y-y0); - - double sumw=0.; - *resp=0; - *xt0=0; - for (int i=0;i<2;i++) { - for (int j=0;j<2;j++) { - int n=ix+i+(iy+j)*m_nx; - int m=i+2*j; - sumw +=w[m]; - *resp += m_resp[n]*w[m]; - *xt0 += m_xt0[n]*w[m]; - *xt1 += m_xt1[n]*w[m]; - *xt2 += m_xt2[n]*w[m]; - } - } - const double inv_sumw = 1. / sumw; - if (sumw>0.) { - *resp = *resp*inv_sumw; - *xt0 = *xt0*inv_sumw; - *xt1 = *xt1*inv_sumw; - *xt2 = *xt2*inv_sumw; - } - -} -void MapEta::GetData0(double x,double y,double* resp) -{ - *resp=1; - if (m_nx==0 || m_ny ==0) return; - if (x<m_xmin ) x=m_xmin+0.01*m_deltax; - if (x>=m_xmax) x=m_xmax-0.01*m_deltax; - if (y<m_ymin ) y=m_ymin+0.01*m_deltay; - if (y>=m_ymax) y=m_ymax-0.01*m_deltay; - - int ix,iy; - ix = (int) ((x-m_xmin)/m_deltax); - iy = (int) ((y-m_ymin)/m_deltay); - float x0 = ((float) ix)*m_deltax+m_xmin; - float x1 = x0+m_deltax; - float y0 = ((float) iy)*m_deltay+m_ymin; - float y1 = y0+m_deltay; - - if (ix<0 || ix+1 >= m_nx || iy<0 || iy+1 >= m_ny) { - std::cout << "MapEta: Out of range " << ix << " " << iy << std::endl; - return; - } - double w[4]; - w[0]=(x1-x)*(y1-y); - w[1]=(x-x0)*(y1-y); - w[2]=(x1-x)*(y-y0); - w[3]=(x-x0)*(y-y0); - - double sumw=0.; - *resp = 0; - for (int i=0;i<2;i++) { - for (int j=0;j<2;j++) { - int n=ix+i+(iy+j)*m_nx; - int m=i+2*j; - sumw +=w[m]; - *resp += m_resp[n]*w[m]; - } - } - if (sumw>0.) *resp = *resp/sumw; - else *resp = 1; - -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx new file mode 100644 index 000000000000..e66cb1893870 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.cxx @@ -0,0 +1,204 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MapEta.h" + +// For reading the data files in Athena. +#ifndef LARG4_STAND_ALONE +#include "PathResolver/PathResolver.h" +#endif + +#include <iostream> +#include <iomanip> +#include <sstream> +#include <fstream> + +MapEta::MapEta(int isampling) +{ + m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; + m_nx=0; + m_ny=0; + m_init=0; + m_resp=0; + m_xt0=0; + m_xt1=0; + m_xt2=0; + Initialize(isampling); +} + +MapEta::~MapEta() +{ + if (m_resp) delete [] m_resp; + if (m_xt0) delete [] m_xt0; + if (m_xt1) delete [] m_xt1; + if (m_xt2) delete [] m_xt2; +} + + +void MapEta::SetDirectory(std::string dir) +{ + m_directory=dir; +} + +void MapEta::Initialize(int isampling) +{ + if (m_init==1) return; + if (isampling < 1 || isampling >3) return; + std::ostringstream fn; + if (isampling==1) fn<<"deta_strip.map"; + if (isampling==2) fn<<"deta_middle.map"; + if (isampling==3) fn<<"eta_trans.map"; + std::string filename = fn.str(); + filename=filename.substr(0,15); + std::string fileLocation; +#ifdef LARG4_STAND_ALONE + // The stand-alone program expects to find the file via AFS. + fileLocation = m_directory + "/" + filename; +#else + // In Athena, the PathResolver tool will find the file for us. + std::cout << "filename " << filename << std::endl; + //std::string larLocation = PathResolver::find_directory("lar","DATAPATH"); + //fileLocation=larLocation+"/calo_data/"+filename; + std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA"); + fileLocation=larLocation+"/"+filename; + std::cout << "fileLocation " << fileLocation << std::endl; +#endif + + std::ifstream in(fileLocation.c_str()); + if (in) + { + in>>m_nx>>m_xmin>>m_xmax>>m_ny>>m_ymin>>m_ymax; + if(m_nx>0 && m_ny>0 && m_nx<10000 && m_ny<10000){//coverity issue. This is a tainted variable protection, 10000 can be changed if required. + //std::cout<<"nx"<<";"<<"ny="<<m_nx<<";"<<m_ny<<std::endl; + m_deltax=(m_xmax-m_xmin)/((float) m_nx); + m_deltay=(m_ymax-m_ymin)/((float) m_ny); + // what is written as xmax in the map is x of last point + delta x + // (such that npoint = (xmax-xmin)/deltax + // to get the real last point in the map we should subtract deltax + m_xmax = m_xmax - m_deltax; + m_ymax = m_ymax - m_deltay; + m_resp = new float[m_ny*m_nx]; + m_xt0 = new float[m_ny*m_nx]; + m_xt1 = new float[m_ny*m_nx]; + m_xt2 = new float[m_ny*m_nx]; + int ii,jj; + for (int ix=0;ix<m_nx;ix++) { + for (int iy=0;iy<m_ny;iy++) { + in>>ii>>jj>>m_resp[ix+iy*m_nx]>>m_xt0[ix+iy*m_nx]>>m_xt1[ix+iy*m_nx]>>m_xt2[ix+iy*m_nx]; + if (ii != ix || jj != iy) std::cout << "MapEta: inconsistency when reading map..." << std::endl; + } + } + + std::cout << "Eta Map read " << " Nbins " << m_nx << " " << m_ny + << " bin size*1000 " << 1000*m_deltax << " " << 1000*m_deltay + << " X range " << m_xmin << " " << m_xmax + << " Y range " << m_ymin << " " << m_ymax << std::endl; + m_init=1; + } + else{ + std::cout << "Error in MapEta::Initialize: nx or ny out of limits." << std::endl; + return; + } + } + else{ + std::cout << "Error in MapEta::Initialize: The file could not be open." << std::endl; + return; + } +} + +void MapEta::GetData(double x,double y,double* resp, double* xt0, double* xt1, double* xt2) const +{ + *resp=1; + *xt0=1; + *xt1=0; + *xt2=0; + if (m_nx==0 || m_ny ==0) return; + if (x<m_xmin ) x=m_xmin+0.01*m_deltax; + if (x>=m_xmax) x=m_xmax-0.01*m_deltax; + if (y<m_ymin ) y=m_ymin+0.01*m_deltay; + if (y>=m_ymax) y=m_ymax-0.01*m_deltay; + + int ix,iy; + ix = (int) ((x-m_xmin)/m_deltax); + iy = (int) ((y-m_ymin)/m_deltay); + float x0 = ((float) ix)*m_deltax+m_xmin; + float x1 = x0+m_deltax; + float y0 = ((float) iy)*m_deltay+m_ymin; + float y1 = y0+m_deltay; + + + if (ix<0 || ix+1 >= m_nx || iy<0 || iy+1 >= m_ny) { + std::cout << "MapEta: Out of range " << ix << " " << iy << std::endl; + return; + } + double w[4]; + w[0]=(x1-x)*(y1-y); + w[1]=(x-x0)*(y1-y); + w[2]=(x1-x)*(y-y0); + w[3]=(x-x0)*(y-y0); + + double sumw=0.; + *resp=0; + *xt0=0; + for (int i=0;i<2;i++) { + for (int j=0;j<2;j++) { + int n=ix+i+(iy+j)*m_nx; + int m=i+2*j; + sumw +=w[m]; + *resp += m_resp[n]*w[m]; + *xt0 += m_xt0[n]*w[m]; + *xt1 += m_xt1[n]*w[m]; + *xt2 += m_xt2[n]*w[m]; + } + } + const double inv_sumw = 1. / sumw; + if (sumw>0.) { + *resp = *resp*inv_sumw; + *xt0 = *xt0*inv_sumw; + *xt1 = *xt1*inv_sumw; + *xt2 = *xt2*inv_sumw; + } + +} +void MapEta::GetData0(double x,double y,double* resp) const +{ + *resp=1; + if (m_nx==0 || m_ny ==0) return; + if (x<m_xmin ) x=m_xmin+0.01*m_deltax; + if (x>=m_xmax) x=m_xmax-0.01*m_deltax; + if (y<m_ymin ) y=m_ymin+0.01*m_deltay; + if (y>=m_ymax) y=m_ymax-0.01*m_deltay; + + int ix,iy; + ix = (int) ((x-m_xmin)/m_deltax); + iy = (int) ((y-m_ymin)/m_deltay); + float x0 = ((float) ix)*m_deltax+m_xmin; + float x1 = x0+m_deltax; + float y0 = ((float) iy)*m_deltay+m_ymin; + float y1 = y0+m_deltay; + + if (ix<0 || ix+1 >= m_nx || iy<0 || iy+1 >= m_ny) { + std::cout << "MapEta: Out of range " << ix << " " << iy << std::endl; + return; + } + double w[4]; + w[0]=(x1-x)*(y1-y); + w[1]=(x-x0)*(y1-y); + w[2]=(x1-x)*(y-y0); + w[3]=(x-x0)*(y-y0); + + double sumw=0.; + *resp = 0; + for (int i=0;i<2;i++) { + for (int j=0;j<2;j++) { + int n=ix+i+(iy+j)*m_nx; + int m=i+2*j; + sumw +=w[m]; + *resp += m_resp[n]*w[m]; + } + } + if (sumw>0.) *resp = *resp/sumw; + else *resp = 1; + +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/MapEta.h b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.h similarity index 55% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/MapEta.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.h index ab54ac602ca5..ad256366ca35 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/MapEta.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/MapEta.h @@ -2,12 +2,12 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef MapEta_H -#define MapEta_H +#ifndef LARG4BARREL_MapEta_H +#define LARG4BARREL_MapEta_H #include <string> -#define NMAP_ETA +#define NMAP_ETA class MapEta { private: @@ -25,13 +25,13 @@ public: MapEta(int isampling); void SetDirectory(std::string dir); void Initialize(int isampling); - int Nx() {return m_nx;} - int Ny() {return m_ny;} - float Xmin() {return m_xmin;} - float Xmax() {return m_xmax;} - float Ymin() {return m_ymin;} - float Ymax() {return m_ymax;} - void GetData(double x,double y, double* resp, double* xt0, double* xt1, double* xt2); - void GetData0(double x,double y, double* resp); + int Nx() const {return m_nx;} + int Ny() const {return m_ny;} + float Xmin() const {return m_xmin;} + float Xmax() const {return m_xmax;} + float Ymin() const {return m_ymin;} + float Ymax() const {return m_ymax;} + void GetData(double x,double y, double* resp, double* xt0, double* xt1, double* xt2) const; + void GetData0(double x,double y, double* resp) const; }; -#endif +#endif //LARG4BARREL_MapEta_H diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cc deleted file mode 100644 index 55a7395c1261..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cc +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/PhysicalVolumeAccessor.h" -#include "G4LogicalVolumeStore.hh" -#include <string> -#include <assert.h> - -G4LogicalVolume* PhysicalVolumeAccessor::GetLV(std::string name) -{ - G4LogicalVolumeStore *lvs=G4LogicalVolumeStore::GetInstance(); - for (unsigned int i=0;i<lvs->size();i++) - { - std::string lname=((lvs->operator[](i))->GetName()); - if (name==lname) - return (lvs->operator[](i)); - } -// std::cout<<"PhysicalVolumeAccessor::GetLV Warning!!! Volume "<<name -// <<" not found!!! returning 0"<<std::endl; - return 0; -} - -PhysicalVolumeAccessor::PhysicalVolumeAccessor(std::string name) -{ - m_theLogicalVolume=GetLV(name); -} - -PhysicalVolumeAccessor::PhysicalVolumeAccessor(std::string name, - std::string PVname) -{ - m_theLogicalVolume=GetLV(name); - assert (m_theLogicalVolume!=0); - for (int i=0;i<m_theLogicalVolume->GetNoDaughters();i++) - { - G4VPhysicalVolume *pv=m_theLogicalVolume->GetDaughter(i); - if (PVname==(pv->GetName())) - { - m_thePhysicalVolumes[pv->GetCopyNo()]=pv; - } - } -} - -const G4VPhysicalVolume* PhysicalVolumeAccessor::GetPhysicalVolume(int icopy) -{ - if (m_thePhysicalVolumes.find(icopy)!=m_thePhysicalVolumes.end()) - return m_thePhysicalVolumes[icopy]; - else - { -// std::cout<<"Physical Volume copy "<<icopy<<" not found in" -// <<m_theLogicalVolume->GetName()<<"!!! return 0"<<std::endl; - return 0; - } -} - -void PhysicalVolumeAccessor::SetPhysicalVolumeList(std::string name) -{ - // assert (m_thePhysicalVolumes.size()==0); - for (int i=0;i<m_theLogicalVolume->GetNoDaughters();i++) - { - G4VPhysicalVolume *pv=m_theLogicalVolume->GetDaughter(i); - if (name==(pv->GetName())) - { - m_thePhysicalVolumes[pv->GetCopyNo()]=pv; - } - } -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx new file mode 100644 index 000000000000..397f3d9a6d3f --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.cxx @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PhysicalVolumeAccessor.h" +#include "G4LogicalVolumeStore.hh" +#include <string> +#include <assert.h> + +G4LogicalVolume* PhysicalVolumeAccessor::GetLV(std::string name) +{ + G4LogicalVolumeStore *lvs=G4LogicalVolumeStore::GetInstance(); + for (unsigned int i=0;i<lvs->size();i++) + { + std::string lname=((lvs->operator[](i))->GetName()); + if (name==lname) + return (lvs->operator[](i)); + } + // std::cout<<"PhysicalVolumeAccessor::GetLV Warning!!! Volume "<<name + // <<" not found!!! returning nullptr"<<std::endl; + return nullptr; +} + +PhysicalVolumeAccessor::PhysicalVolumeAccessor(std::string name) +{ + m_theLogicalVolume=GetLV(name); +} + +PhysicalVolumeAccessor::PhysicalVolumeAccessor(std::string name, + std::string PVname) +{ + m_theLogicalVolume=GetLV(name); + assert (m_theLogicalVolume!=nullptr); + for (int i=0;i<m_theLogicalVolume->GetNoDaughters();i++) + { + G4VPhysicalVolume *pv=m_theLogicalVolume->GetDaughter(i); + if (PVname==(pv->GetName())) + { + m_thePhysicalVolumes[pv->GetCopyNo()]=pv; + } + } +} + +const G4VPhysicalVolume* PhysicalVolumeAccessor::GetPhysicalVolume(int icopy) const +{ + auto physVolIter = m_thePhysicalVolumes.find(icopy); + if (physVolIter!=m_thePhysicalVolumes.end()) + return physVolIter->second; + else + { + // std::cout<<"Physical Volume copy "<<icopy<<" not found in" + // <<m_theLogicalVolume->GetName()<<"!!! return nullptr"<<std::endl; + return nullptr; + } +} + +void PhysicalVolumeAccessor::SetPhysicalVolumeList(std::string name) +{ + // assert (m_thePhysicalVolumes.size()==0); + for (int i=0;i<m_theLogicalVolume->GetNoDaughters();i++) + { + G4VPhysicalVolume *pv=m_theLogicalVolume->GetDaughter(i); + if (name==(pv->GetName())) + { + m_thePhysicalVolumes[pv->GetCopyNo()]=pv; + } + } +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PhysicalVolumeAccessor.h b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.h similarity index 59% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PhysicalVolumeAccessor.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.h index d0885d4521ba..289fea44a399 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PhysicalVolumeAccessor.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PhysicalVolumeAccessor.h @@ -17,14 +17,14 @@ typedef std::map<int,G4VPhysicalVolume *, std::less<int> > PVMap; class PhysicalVolumeAccessor { public: - PhysicalVolumeAccessor(std::string); - PhysicalVolumeAccessor(std::string,const std::string); - const G4VPhysicalVolume* GetPhysicalVolume(int); - void SetPhysicalVolumeList(std::string); + PhysicalVolumeAccessor(std::string); + PhysicalVolumeAccessor(std::string,const std::string); + const G4VPhysicalVolume* GetPhysicalVolume(int) const; + void SetPhysicalVolumeList(std::string); private: - G4LogicalVolume* m_theLogicalVolume; - PVMap m_thePhysicalVolumes; - G4LogicalVolume *GetLV(std::string); + G4LogicalVolume* m_theLogicalVolume; + PVMap m_thePhysicalVolumes; + G4LogicalVolume *GetLV(std::string); }; diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PresParameterDef.h b/LArCalorimeter/LArG4/LArG4Barrel/src/PresParameterDef.h similarity index 100% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PresParameterDef.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/PresParameterDef.h diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cc deleted file mode 100644 index fc111f63a6a9..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cc +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -/******************************************************************** - -NAME: PresamplerCalibrationCalculator.cxx -PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel - -AUTHORS: G. Unal, L. Carminati (on a template from Bill Selingman) -CREATED: September, 2004 - -PURPOSE: This class calculates the values needed for calibration hits - in the barrel presampler of LAr calorimeter. This calculator is - called in calibration runs (see LArBarrelPresamplerSDConsultant) - for calibration hits in the presampler volume. - -UPDATES: - -********************************************************************/ - -// #define DEBUG_HITS - -#include "LArG4Barrel/PresamplerCalibrationCalculator.h" - -#include "LArG4Barrel/LArBarrelPresamplerGeometry.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" -#include <algorithm> - -namespace LArG4 { - - namespace BarrelPresampler { - - CalibrationCalculator::CalibrationCalculator() - : m_detectorName("LArMgr") - { - // Initialize the geometry calculator - m_geometryCalculator = Geometry::GetInstance(); - } - - CalibrationCalculator::~CalibrationCalculator() - { - } - - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { -#ifdef DEBUG_HITS - std::cout << "LArG4::Barrel::CalibrationCalculator::Process" - << " calling SimulationEnergies" << std::endl; -#endif - m_energyCalculator.Energies( a_step, m_energies ); - - // First, get the energy. - //m_energy = a_step->GetTotalEnergyDeposit(); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - m_identifier = m_geometryCalculator->CalculateIdentifier( a_step, m_detectorName ); - } - else - m_identifier = LArG4Identifier(); - - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::Barrel::CalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - - } // namespace Barrel - -} // namespace LAr diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cxx new file mode 100644 index 000000000000..31d4b8621458 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.cxx @@ -0,0 +1,108 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: PresamplerCalibrationCalculator.cxx +PACKAGE: offline/LArCalorimeter/LArG4/LArG4Barrel + +AUTHORS: G. Unal, L. Carminati (on a template from Bill Selingman) +CREATED: September, 2004 + +PURPOSE: This class calculates the values needed for calibration hits + in the barrel presampler of LAr calorimeter. This calculator is + called in calibration runs (see LArBarrelPresamplerSDConsultant) + for calibration hits in the presampler volume. + +UPDATES: + +********************************************************************/ + +// #define DEBUG_HITS + +#include "PresamplerCalibrationCalculator.h" + +#include "LArBarrelPresamplerGeometry.h" + +#include "LArG4Code/LArG4Identifier.h" + +#include "G4Step.hh" +#include "globals.hh" +#include <algorithm> + +namespace LArG4 { + + namespace BarrelPresampler { + + CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_geometryCalculator("LArBarrelPresamplerGeometry", name) + { + declareProperty("GeometryCalculator", m_geometryCalculator); + } + + StatusCode CalibrationCalculator::initialize() { + // Initialize the geometry calculator + ATH_CHECK(m_geometryCalculator.retrieve()); + return StatusCode::SUCCESS; + } + + CalibrationCalculator::~CalibrationCalculator() + { + } + + G4bool CalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { +#ifdef DEBUG_HITS + std::cout << "LArG4::Barrel::CalibrationCalculator::Process" + << " calling SimulationEnergies" << std::endl; +#endif + m_energyCalculator.Energies( step, energies ); + + // First, get the energy. + //m_energy = step->GetTotalEnergyDeposit(); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + identifier = m_geometryCalculator->CalculateIdentifier( step ); + } + else + identifier = LArG4Identifier(); + + +#ifdef DEBUG_HITS + G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "LArG4::Barrel::CalibrationCalculator::Process" + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; +#endif + + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; + + return true; + } + + } // namespace Barrel + +} // namespace LAr diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PresamplerCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.h similarity index 62% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PresamplerCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.h index 469eaed3f497..4efc7a760e89 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PresamplerCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PresamplerCalibrationCalculator.h @@ -2,7 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -// LArG4::BarrelPreampler::CalibrationCalculator +// LArG4::BarrelPreampler::CalibrationCalculator // This class calculates the values needed for calibration hits in the // simulation. @@ -10,8 +10,9 @@ #ifndef LArG4_BarrelPresampler_CalibrationCalculator_H #define LArG4_BarrelPresampler_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" +#include "ILArBarrelPresamplerGeometry.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -29,18 +30,19 @@ class G4Step; // Forward declaration for namespace CaloG4. namespace LArG4 { - + namespace BarrelPresampler { - + // Forward declaration class Geometry; - - class CalibrationCalculator : public VCalibrationCalculator { + + class CalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationCalculator(); + + CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -52,30 +54,17 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } ; - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; }; - - inline void detectorName(std::string name) { m_detectorName=name; } - private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + private: // Geometry calculator - Geometry* m_geometryCalculator; + ServiceHandle<ILArBarrelPresamplerGeometry> m_geometryCalculator; // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; - // detector name, for translated geometry - std::string m_detectorName; - }; } // namespace BarrelPresampler diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cc b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cc deleted file mode 100644 index a5e70c57ab68..000000000000 --- a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cc +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4Barrel/PsMap.h" -#include <iostream> -#include <sstream> -#ifndef LARG4_STAND_ALONE -#include "PathResolver/PathResolver.h" -#endif - -PsMap* PsMap::s_thePointer=0; - -PsMap::PsMap() -{ - m_module=-1; - m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; - -#ifndef LARG4_STAND_ALONE - //std::string larLocation = PathResolver::find_directory("lar","DATAPATH"); - std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA"); -#endif - - double xnorm=15.9; // nA/MeV normalisation for PS maps - - for (int imap=0;imap<5;imap++) { -// accordion folds - std::ostringstream fn; - fn << "presampler_"<<imap<<".map"; - std::string filename = fn.str(); - std::string fileLocation; -#ifdef LARG4_STAND_ALONE - fileLocation=m_directory+"/"+filename; -#else - //fileLocation=larLocation+"/calo_data/"+filename; - fileLocation=larLocation+"/"+filename; -#endif - CurrMap* cm = new CurrMap(fileLocation,xnorm); - int code=imap; - m_theMap[code]=cm; - } - m_curr=0; - -} - -PsMap* PsMap::GetPsMap() -{ - if (s_thePointer==0) s_thePointer=new PsMap(); - return s_thePointer; -} - -void PsMap::Reset() -{ - curr_map::iterator it=m_theMap.begin(); - while (it != m_theMap.end()) { - delete (*it).second; - m_theMap.erase(it++); - } -} - -void PsMap::SetMap(int module) -{ - if (m_module==module) return; - m_module=module; -// module 0 and 1 have their own maps (code = 0 and 1) -// module 2 and 3 have the same map (same geometry) with code 2 -// module 4 and 5 have the same map (same geometry) with code 3 -// module 6 and 7 have the same map (same geometry) with code 4 - int code = -1; - if (module==0 || module==1) code=module; - if (module > 1 && module < 8) code=(module-2)/2 + 2; - if (m_theMap.find(code) != m_theMap.end()) - m_curr = m_theMap[code]; - else { - std::cout << " Code " << code << " not found in map ..." << std::endl; - m_curr=0; - } -} - -void PsMap::SetDirectory(std::string dir) -{ - m_directory=dir; -} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx new file mode 100644 index 000000000000..e2dd31892069 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.cxx @@ -0,0 +1,83 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "PsMap.h" +#include <iostream> +#include <sstream> +#ifndef LARG4_STAND_ALONE +#include "PathResolver/PathResolver.h" +#endif + +PsMap* PsMap::s_thePointer=nullptr; + +PsMap::PsMap() +{ + m_module=-1; + m_directory="/afs/cern.ch/atlas/offline/data/lar/calo_data"; + +#ifndef LARG4_STAND_ALONE + //std::string larLocation = PathResolver::find_directory("lar","DATAPATH"); + std::string larLocation = PathResolver::find_directory("LArG4Barrel","ATLASCALDATA"); +#endif + + double xnorm=15.9; // nA/MeV normalisation for PS maps + + for (int imap=0;imap<5;imap++) { + // accordion folds + std::ostringstream fn; + fn << "presampler_"<<imap<<".map"; + std::string filename = fn.str(); + std::string fileLocation; +#ifdef LARG4_STAND_ALONE + fileLocation=m_directory+"/"+filename; +#else + //fileLocation=larLocation+"/calo_data/"+filename; + fileLocation=larLocation+"/"+filename; +#endif + CurrMap* cm = new CurrMap(fileLocation,xnorm); + int code=imap; + m_theMap[code]=cm; + } + m_curr=0; + +} + +PsMap* PsMap::GetPsMap() +{ + if (s_thePointer==nullptr) s_thePointer=new PsMap(); + return s_thePointer; +} + +void PsMap::Reset() +{ + curr_map::iterator it=m_theMap.begin(); + while (it != m_theMap.end()) { + delete (*it).second; + m_theMap.erase(it++); + } +} + +void PsMap::SetMap(int module) +{ + if (m_module==module) return; + m_module=module; + // module 0 and 1 have their own maps (code = 0 and 1) + // module 2 and 3 have the same map (same geometry) with code 2 + // module 4 and 5 have the same map (same geometry) with code 3 + // module 6 and 7 have the same map (same geometry) with code 4 + int code = -1; + if (module==0 || module==1) code=module; + if (module > 1 && module < 8) code=(module-2)/2 + 2; + if (m_theMap.find(code) != m_theMap.end()) + m_curr = m_theMap[code]; + else { + std::cout << " Code " << code << " not found in map ..." << std::endl; + m_curr=0; + } +} + +void PsMap::SetDirectory(std::string dir) +{ + m_directory=dir; +} diff --git a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PsMap.h b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h similarity index 76% rename from LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PsMap.h rename to LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h index b63272d1eb85..f3bec25de942 100644 --- a/LArCalorimeter/LArG4/LArG4Barrel/LArG4Barrel/PsMap.h +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/PsMap.h @@ -2,10 +2,10 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef PsMap_h -#define PsMap_h +#ifndef LARG4BARREL_PsMap_h +#define LARG4BARREL_PsMap_h -#include "LArG4Barrel/CurrMap.h" +#include "CurrMap.h" #include <map> #include <vector> @@ -20,7 +20,7 @@ class PsMap { void SetDirectory(std::string dir); void Reset(); void SetMap(int module); - CurrMap* Map() {return m_curr;} + CurrMap* Map() const {return m_curr;} private: PsMap(); static PsMap* s_thePointer; @@ -30,4 +30,4 @@ class PsMap { CurrMap* m_curr; int m_module; }; -#endif +#endif // LARG4BARREL_PsMap_h diff --git a/LArCalorimeter/LArG4/LArG4Barrel/src/components/LArG4Barrel_entries.cxx b/LArCalorimeter/LArG4/LArG4Barrel/src/components/LArG4Barrel_entries.cxx new file mode 100644 index 000000000000..5fa494d657b7 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Barrel/src/components/LArG4Barrel_entries.cxx @@ -0,0 +1,23 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" + +#include "../CryostatCalibrationCalculator.h" +#include "../CryostatCalibrationMixedCalculator.h" +#include "../LArBarrelCalculator.h" +#include "../LArBarrelPresamplerCalculator.h" +#include "../CryostatCalibrationLArCalculator.h" +#include "../DMCalibrationCalculator.h" +#include "../LArBarrelCalibrationCalculator.h" +#include "../PresamplerCalibrationCalculator.h" +#include "../LArBarrelGeometry.h" +#include "../LArBarrelPresamplerGeometry.h" + +DECLARE_SERVICE_FACTORY(LArG4::BarrelCryostat::CalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::BarrelCryostat::CalibrationMixedCalculator) +DECLARE_SERVICE_FACTORY(LArBarrelCalculator) +DECLARE_SERVICE_FACTORY(LArBarrelPresamplerCalculator) +DECLARE_SERVICE_FACTORY(LArG4::BarrelCryostat::CalibrationLArCalculator) +DECLARE_SERVICE_FACTORY(LArG4::DM::CalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::Barrel::CalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::BarrelPresampler::CalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::Barrel::Geometry) +DECLARE_SERVICE_FACTORY(LArG4::BarrelPresampler::Geometry) diff --git a/LArCalorimeter/LArG4/LArG4Code/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4Code/CMakeLists.txt index 5fa6d2b2e288..983c95848543 100644 --- a/LArCalorimeter/LArG4/LArG4Code/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4Code/CMakeLists.txt @@ -12,10 +12,12 @@ atlas_depends_on_subdirs( PUBLIC LArCalorimeter/LArGeoModel/LArGeoCode LArCalorimeter/LArSimEvent Simulation/G4Atlas/G4AtlasTools + Control/StoreGate + GaudiKernel PRIVATE Calorimeter/CaloIdentifier Control/AthenaKernel - Control/StoreGate + Control/CxxUtils Simulation/G4Sim/MCTruth ) # External dependencies: @@ -28,8 +30,15 @@ add_definitions(-DLARG4NOROOT) # Component(s) in the package: atlas_add_library( LArG4Code src/*.cc + src/*.cxx PUBLIC_HEADERS LArG4Code INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} CaloSimEvent LArGeoCode LArSimEvent CaloG4SimLib G4AtlasToolsLib StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES CaloIdentifier AthenaKernel MCTruth ) + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} CaloSimEvent LArGeoCode LArSimEvent CaloG4SimLib G4AtlasToolsLib StoreGateLib SGtests GaudiKernel + PRIVATE_LINK_LIBRARIES CaloIdentifier AthenaKernel CxxUtils MCTruth ) + +atlas_add_dictionary( LArG4CodeEnums + LArG4Code/LArG4EnumDefs.h + LArG4Code/selectionEnums.xml + INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} CaloSimEvent LArGeoCode LArSimEvent CaloG4SimLib G4AtlasToolsLib StoreGateLib SGtests GaudiKernel LArG4Code ) diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibSDTool.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibSDTool.h new file mode 100644 index 000000000000..7a9c19ee345b --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibSDTool.h @@ -0,0 +1,90 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4CODE_CALIBSDTOOL_H +#define LARG4CODE_CALIBSDTOOL_H + +/// @file CalibSDTool.h +/// @brief Defines the CalibSDTool class +/// @author Steve Farrell <Steven.Farrell@cern.ch> +/// @date 2016-03-26 + +// System includes +#include <string> +#include <vector> + +// G4Atlas includes +#include "G4AtlasTools/SensitiveDetectorBase.h" + +// Local includes +#include "LArG4CalibSD.h" + +// Forward declarations +class ILArCalibCalculatorSvc; +class LArEM_ID; +class LArFCAL_ID; +class LArHEC_ID; +class LArMiniFCAL_ID; +class CaloDM_ID; +class LArG4CalibSD; + +namespace LArG4 +{ + + /// @class CalibSDTool + /// @brief A base class for tools that manage LArG4CalibSDs. + /// + /// @todo Add more details. + /// + /// @author Steve Farrell <Steven.Farrell@cern.ch> + /// + class CalibSDTool : public SensitiveDetectorBase + { + + public: + + /// Constructor + CalibSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + /// Initialize the tool + StatusCode initialize() override final; + + /// Calls down to all the SDs to pack their hits into one collection + StatusCode Gather() override final; + + protected: + + /// Initialize Calculator Services + virtual StatusCode initializeCalculators() { return StatusCode::SUCCESS; } + + /// Helper method to create one SD + std::unique_ptr<LArG4CalibSD> + makeOneSD(const std::string& name, ILArCalibCalculatorSvc* calc, + const std::vector<std::string>& volumes) const; + + protected: + + /// @name configuration properties + /// @{ + + /// Are we set up to run with PID hits? + G4bool m_doPID; + + /// @} + + /// @name Calo identifier helpers + /// @{ + const LArEM_ID* m_larEmID; + const LArFCAL_ID* m_larFcalID; + const LArHEC_ID* m_larHecID; + const LArMiniFCAL_ID* m_larMiniFcalID; + const CaloDM_ID* m_caloDmID; + /// @} + + }; // class CalibSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalculatorSvc.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalculatorSvc.h new file mode 100755 index 000000000000..c14cfcdd7654 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalculatorSvc.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ILArCalculatorSvc.h +// Prepared in 2016 based on LArVCalculator from Bill Seligman + +#ifndef __ILARCALCULATORSVC_H__ +#define __ILARCALCULATORSVC_H__ + +#include "GaudiKernel/IService.h" + +#include "globals.hh" + +#include "LArG4Code/LArG4Identifier.h" + + +// Forward declaractions: +class G4Step; +class StatusCode; + +// struct to pass the hit info +struct LArHitData { LArG4Identifier id; G4double time; G4double energy; }; + +class ILArCalculatorSvc: virtual public IService { +public: + + ILArCalculatorSvc() {}; + static const InterfaceID& interfaceID() { + static const InterfaceID IID_ILArCalculatorSvc("ILArCalculatorSvc",1,0); + return IID_ILArCalculatorSvc; + } + + virtual ~ILArCalculatorSvc() {}; + + // "OOTcut" the time cut (ns) after which an energy deposit is + // considered to be out-of-time w.r.t. the event. + virtual G4float OOTcut() const = 0; + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const = 0; // units = ns + + //New interface, to pass the hit info directly + virtual G4bool Process (const G4Step*, std::vector<LArHitData>&) const = 0; + +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalibCalculatorSvc.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalibCalculatorSvc.h new file mode 100755 index 000000000000..2056488ad28a --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/ILArCalibCalculatorSvc.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ILArCalibCalculatorSvc.h +// Prepared in 2016 based on VCalibrationCalculator from Bill Seligman + +#ifndef __ILARCALIBCALCULATORSVC_H__ +#define __ILARCALIBCALCULATORSVC_H__ + +#include "GaudiKernel/IService.h" + +#include "globals.hh" + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArG4EnumDefs.h" + + +// Forward declaractions: +class G4Step; +class StatusCode; + +class ILArCalibCalculatorSvc: virtual public IService { +public: + + ILArCalibCalculatorSvc(){}; + static const InterfaceID& interfaceID() { + static const InterfaceID IID_ILArCalibCalculatorSvc("ILArCalibCalculatorSvc",1,0); + return IID_ILArCalibCalculatorSvc; + } + + virtual ~ILArCalibCalculatorSvc() {}; + + + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing process = LArG4::kEnergyAndID) const = 0; + + + +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalculatorSvcImp.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalculatorSvcImp.h new file mode 100644 index 000000000000..a3bdfc8fdac2 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalculatorSvcImp.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef __LARCALCULATORSVCIMP_H__ +#define __LARCALCULATORSVCIMP_H__ + +#include "ILArCalculatorSvc.h" +#include "AthenaBaseComps/AthService.h" + +class LArCalculatorSvcImp: public AthService, virtual public ILArCalculatorSvc { + +public: + + LArCalculatorSvcImp(const std::string& name, ISvcLocator * pSvcLocator); + + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; + +protected: + // Birks' law + bool m_BirksLaw; + + // Birks' law, constant k + double m_Birksk; + + // OOTcut + double m_OOTcut; + +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalibCalculatorSvcImp.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalibCalculatorSvcImp.h new file mode 100644 index 000000000000..9d1f63fcd508 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArCalibCalculatorSvcImp.h @@ -0,0 +1,20 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef __LARCALIBCALCULATORSVCIMP_H__ +#define __LARCALIBCALCULATORSVCIMP_H__ + +#include "ILArCalibCalculatorSvc.h" +#include "AthenaBaseComps/AthService.h" + +class LArCalibCalculatorSvcImp: public AthService, virtual public ILArCalibCalculatorSvc +{ +public: + LArCalibCalculatorSvcImp(const std::string& name, ISvcLocator * pSvcLocator); + + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4CalibSD.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4CalibSD.h index b5fe6f2d0568..c3a5effa7b89 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4CalibSD.h +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4CalibSD.h @@ -22,7 +22,8 @@ class LArHEC_ID; class LArMiniFCAL_ID; class CaloDM_ID; -namespace LArG4 { class VCalibrationCalculator; } +class ILArCalibCalculatorSvc; + class CaloCalibrationHitContainer; @@ -37,7 +38,7 @@ class LArG4CalibSD : public G4VSensitiveDetector public: /// Constructor - LArG4CalibSD(G4String a_name, LArG4::VCalibrationCalculator* calc, bool doPID=false); + LArG4CalibSD(G4String a_name, ILArCalibCalculatorSvc* calc, bool doPID=false); /// Destructor virtual ~LArG4CalibSD(); @@ -72,7 +73,7 @@ protected: protected: /// Member variable - the calculator we'll use - LArG4::VCalibrationCalculator * m_calculator; + ILArCalibCalculatorSvc * m_calculator; /// Count the number of invalid hits. G4int m_numberInvalidHits; diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4DetectorComponents.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4DetectorComponents.h deleted file mode 100644 index e32c29effdf7..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4DetectorComponents.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4DetectorComponents -// Maintain a list of detector components. -// 05-Jun-2003 Bill Seligman - -#ifndef __LArG4DetectorComponents_H__ -#define __LArG4DetectorComponents_H__ - -#include "LArG4Code/LArVolumeInterface.h" - -#include "globals.hh" - -#include <map> - - -class LArG4DetectorComponents -{ -public: - - enum EDetectorComponent { - kBarrelCryostat , // The entire barrel cryostat - kEndcapCryostat , // The entire endcap cryostat - kEMB , // The electromagnetic barrel calorimeter in the barrel cryostat - kEMBps , // The electromagnetic barrel pre-sampler in the barrel cryostat - kEMEC , // The electromagnetic endcap calorimeter in the endcap cryostat - kEMECps , // The electromagnetic endcap pre-sampler in the endcap cryostat - kFCAL , // The forward calorimeter in the endcap cryostat - kHEC // The hadrnic calorimeter in the endcap cryostat - }; - - virtual ~LArG4DetectorComponents(); - - // Accessor for pointer to the single instance of this class. - static LArG4DetectorComponents* GetInstance(); - - // If the user wishes to override the default detector components, - // they do so by editing the LArG4DetectorComponents.cc file, or by - // using the following method from the main program. These methods - // are "static" because I don't anticipate that there'll be multiple - // ATLAS detectors in one G4 simulation. - void SetDetectorComponent ( const EDetectorComponent, LArVolumeInterface* ); - LArVolumeInterface* GetDetectorComponent ( const EDetectorComponent ) const; - - // The positive (z>0) and negative (z<0) portions of the detector - // can be built separately. These access methods provides a common - // reference point for sub-detectors to know which half is being - // built. - G4bool zNeg() const { return m_zNeg; } - void SetzNeg( G4bool z ) { m_zNeg = z; } - -protected: - // The constructor is protected according to the standard singleton - // design pattern. - LArG4DetectorComponents(); - -private: - // Are we building the positive or the negative half of the - // detector? m_Zneg == true means that we're building the negative - // half. - static G4bool m_zNeg; - - // The list of volumes that will be assembled into the final - // detector description. - typedef std::map< EDetectorComponent, LArVolumeInterface* > m_detectorMap_t; - typedef m_detectorMap_t::const_iterator m_detectorMap_ptr; - m_detectorMap_t m_detectorMap; - -}; - -#endif // __LArG4DetectorComponents_H__ diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4EnumDefs.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4EnumDefs.h new file mode 100644 index 000000000000..ac7f8929a9ec --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4EnumDefs.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4CODE_LARG4ENUMDEFS_H +#define LARG4CODE_LARG4ENUMDEFS_H + +namespace LArG4 { + + enum eCalculatorProcessing { kEnergyAndID, kOnlyEnergy, kOnlyID }; + + enum EnergyCorrection_t { + EMEC_ECOR_ROPT, + EMEC_ECOR_OFF, + EMEC_ECOR_GADJ, + EMEC_ECOR_CHCL, + EMEC_ECOR_GADJ_OLD, + EMEC_ECOR_GADJ_E, + EMEC_ECOR_GADJ_S, + EMEC_ECOR_GADJ_SE, + EMEC_ECOR_CHCL1 + }; + + struct ROOT6_NamespaceAutoloadHook{}; +} +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SDTool.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SDTool.h index 5eb6a47dfa50..227b20aceb8e 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SDTool.h +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SDTool.h @@ -41,6 +41,8 @@ class LArG4SDTool : public SensitiveDetectorBase StatusCode initialize() override final; + virtual StatusCode initializeCalculators(){ return StatusCode::SUCCESS; } + /// Helper method to pass the ID helper pointers to the SDs. void setupHelpers( LArG4SimpleSD* ) const; /// Overload of the above method for calib SDs. diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SimpleSD.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SimpleSD.h index f7236a7c3eec..0e1448f788c7 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SimpleSD.h +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArG4SimpleSD.h @@ -20,7 +20,7 @@ class LArFCAL_ID; class LArHEC_ID; class LArMiniFCAL_ID; -class LArVCalculator; +class ILArCalculatorSvc; class LArHitContainer; class StoreGateSvc; @@ -43,7 +43,7 @@ public: }; /// Constructor - LArG4SimpleSD(G4String a_name, LArVCalculator* calc, + LArG4SimpleSD(G4String a_name, ILArCalculatorSvc* calc, const std::string& type="Default", const float width=2.5*CLHEP::ns); @@ -81,7 +81,7 @@ protected: G4int getTimeBin(G4double time) const; /// Member variable - the calculator we'll use - LArVCalculator * m_calculator; + ILArCalculatorSvc * m_calculator; /// Count the number of invalid hits. G4int m_numberInvalidHits; diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArHitMaker.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArHitMaker.h deleted file mode 100644 index 6f37b8dc5c97..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArHitMaker.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArHitMaker -// Created by F. Mazzucato September 2002 -// Modified 30-Apr-2003 Bill Seligman - -// Convert an EnergySpot into a LArG4-type hit. - -#ifndef LARG4CODE_LARHITMAKER_h -#define LARG4CODE_LARHITMAKER_h - -#include "G4TouchableHandle.hh" -#include "globals.hh" - -// Forward declarations -class EnergySpot; -class G4StepPoint; -class G4Step; -class G4Navigator; - -class LArHitMaker -{ -public: - LArHitMaker(); - virtual ~LArHitMaker(); - virtual void make(const EnergySpot& spot); - -private: - G4Step* m_fakeStep; - G4StepPoint* m_fakePreStepPoint; - G4StepPoint* m_fakePostStepPoint; - G4TouchableHandle m_touchableHandle; - G4Navigator* m_pNavigator; - G4bool m_naviSetup; - - G4String m_baseName; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVCalculator.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVCalculator.h deleted file mode 100644 index b8b02a449876..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVCalculator.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArVCalculator.hh -// Prepared 27-Jun-2001 Bill Seligman - -// This is an abstract base for a geometry calculator for ATLAS EM -// detectors. - -// A "calculator" is used in much the same way as a hand-held -// calculator might be. The user supplies a value and hits 'Enter' -// (i.e., invokes the Process() method). Then they read off whatever -// values are of interest. - -// 12-Jul-2002 WGS: Added access method to return an identifier. This -// replaces any other access methods for hit ID information. - -// 09-Jan-2002 WGS: Major modification -- The main calculation method -// FindCell(G4ThreeVector&) has been changed to Process(G4Step*). The -// reason for this change is that it became apparent the calculators -// needed more information than just the point of the energy deposit. - -// Also: since this class may also be used by the HEC, changed its -// named from LArVEMCalculator to LArVCalculator. - -#ifndef __LArVCalculator_H__ -#define __LArVCalculator_H__ - -#include "globals.hh" - -#include "LArG4Code/LArG4Identifier.h" - -// Forward declaractions: -class G4Step; - -// struct to pass the hit info -struct LArHitData { LArG4Identifier id; G4double time; G4double energy; }; - -class LArVCalculator { -public: - - virtual ~LArVCalculator() {}; - - // "OOTcut" the time cut (ns) after which an energy deposit is - // considered to be out-of-time w.r.t. the event. - virtual G4float OOTcut() const = 0; - - // 29-Mar-2002 WGS: The Process method now returns a boolean value. - // If it's true, the hit can be used by Geant4; if it's false, - // there's something wrong with the hit and it should be ignored. - virtual G4bool Process (const G4Step*) = 0; - - //New interface, to pass the hit info directly - virtual G4bool Process (const G4Step*, std::vector<LArHitData>&) = 0; - - // Override if your calculator will return multiple hits: - virtual int getNumHits() const {return 1;} - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier(int i=0) const = 0; - - // Routines added 09-Jan-2002 WGS: For some detectors, the - // determination of the time, energy deposition, or whether the hit - // was out-of-time is non-trivial, so these new methods were added. - virtual G4double time(int i=0) const = 0; // units = ns - virtual G4double energy(int i=0) const = 0; // units = native G4 unit of energy - virtual G4bool isInTime(int i=0) const = 0; - virtual G4bool isOutOfTime(int i=0) const = 0; - - -}; - -#endif // __LArVCalculator_H__ diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVolumeInterface.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVolumeInterface.h deleted file mode 100644 index 2edcd2573dae..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/LArVolumeInterface.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArVolumeInterface.h -// 09-Apr-2003 Bill Seligman - -// This is an interface for handling volumes inside LArG4. The idea -// is that each detector (or sub-detector) must return a -// logical-volume envelope, and the parent detector places it within a -// physical volume. - -#ifndef __LArVolumeInterface_h__ -#define __LArVolumeInterface_h__ - -#include "G4LogicalVolume.hh" - -class LArVolumeInterface { - -public: - - virtual ~LArVolumeInterface() {}; - - // Get a logical-volume envelope around the sub-element of the ATLAS - // detector. - virtual G4LogicalVolume* GetEnvelope() = 0; - -protected: - - // The constructor is protected to make sure no one creates an - // explicit LArVolumeInterface object. - LArVolumeInterface() {}; - -}; - -#endif // __LArVolumeInterface_h__ diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/OptionsStore.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/OptionsStore.h deleted file mode 100644 index 7e53b85c3a18..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/OptionsStore.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// OptionsStore -// 02-Oct-2003 Bill Seligman - -// This template class is actually a simple wrapper around a map. -// It's purpose is to provide a common code base for store run options -// for the LArG4Model and LArG4 packages (although it could be used -// by other packages). - -#ifndef __LArG4_OptionsStore_H__ -#define __LArG4_OptionsStore_H__ - -#include <map> -#include <string> -#include <iostream> - -#undef DEBUG_OPTIONS - -namespace LArG4 { - - template< typename EnumType > - class OptionsStore - { - public: - - virtual ~OptionsStore() {;} - - // Store and retrieve user options. Note that no attempt is made - // to validate the option strings; if the user supplies "parital" - // instead of "partial" this routine will not detect it. - virtual void SetOption( EnumType e, std::string value ); - virtual std::string GetOption( EnumType e ) const; - - protected: - - // The constructor is protected according to the standard - // singleton design pattern. However, any class that interits - // from this template will have to implement its own GetInstance() - // method. - OptionsStore(); - - private: - - // Define a map type to hold detector options; some associated - // types, and the map itself. - typedef typename std::map< EnumType, std::string > m_OptionsStoreMap_t; - typedef typename m_OptionsStoreMap_t::iterator m_OptionsStoreMap_ptr_t; - typedef typename m_OptionsStoreMap_t::const_iterator m_OptionsStoreMap_const_ptr_t; - m_OptionsStoreMap_t m_OptionsStoreMap; - }; - - - ///////////////////////////////////////////////////////////////////// - // Since this is a template class, its implementation also has to be - // in the header. - ///////////////////////////////////////////////////////////////////// - - - // Constructor - template < typename EnumType > - OptionsStore<EnumType>::OptionsStore() {;} - - - // Store an option in the internal table. - template < typename EnumType > - void OptionsStore<EnumType>::SetOption( EnumType e, std::string value ) - { - m_OptionsStoreMap[e] = value; - } - - - // Fetch an option from our internal table. (We get a little fancy - // here because, as an exercise, I want to maintain the "const" - // nature of the method without generating compiler warnings.) - template < typename EnumType > - std::string OptionsStore<EnumType>::GetOption( EnumType e ) const - { - m_OptionsStoreMap_const_ptr_t i = m_OptionsStoreMap.find(e); - -#ifdef DEBUG_OPTIONS - std::cout << "OptionsStore: Searching for " << e; -#endif - - if ( i == m_OptionsStoreMap.end() ) - { -#ifdef DEBUG_OPTIONS - std::cout << " and found nothing." << std::endl; -#endif - - return ""; - } - - else - { - // Reminder: - // i == a pointer to one entry in OptionsStoreMap - // (*i) = a pair<EnumType, std::string> - // (*i).second = a string, the value of the option. - -#ifdef DEBUG_OPTIONS - std::cout << " and found '" - << (*i).second - << "'" - << std::endl; -#endif - - return (*i).second; - } - } - -} // namespace LArG4 - -#endif // __LArG4_OptionsStore_H__ diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/RunOptions.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/RunOptions.h deleted file mode 100644 index 25ba5117a50e..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/RunOptions.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// RunOptions -// 30-Jun-2003 Bill Seligman - -#ifndef LArG4_RunOptions_H -#define LArG4_RunOptions_H - -// The LAr simulation has a number of user-specified options. This -// class stores and retrives the options specified by the user. For -// now, this routine is limited to those options which are in common -// to the stand-alone and Athena versions of LArG4Model; for example, the -// physics-list option is not in this class, because it's a LArG4 -// option in stand-alone mode, but a G4Svc option in Athena mode. - -// 21-Jul-2004 WGS: Add out-of-time cut option. - -#include "LArG4Code/OptionsStore.h" - -#include <map> -#include <string> - - -namespace LArG4 { - - // Define all the user options. Note that the simulation main - // routines (e.g., LArG4/LArG4Algs/src/LArG4Run.cxx and - // LArG4/LArG4App/LArG4App.cc) are responsible for - // supplying the default values for all these options. (In - // Athena, the default values are supplied by the jobOptions - // service; in stand-alone, they're supplied through the - // ParseOptions class.) - - enum ERunOptions { - - // Options that related to calibration studies - kCalibrationRun , // Whether this is a calibration run - - // Options that relate to the fast shower model - kEmbFastShowerModel , // Whether to use a fast-shower-model in the EMB - kEmecFastShowerModel , // Whether to use a fast-shower-model in the EMEC - kFcalFastShowerModel , // Whether to use a fast-shower-model in the FCAL - kHecFastShowerModel , // Whether to use a fast-shower-model in the HEC - kBuildFromNova, // Whether to build parameters from NOVA database. - kOutOfTimeCut // Out-of-time cut applied to energy deposits in hits - }; - - // Define the class that will store the run options. In this case, - // the class will be LArG4::RunOptions. - - class RunOptions : public LArG4::OptionsStore<ERunOptions> - { - public: - virtual ~RunOptions() {;} - - // Standard setup for the singleton design pattern. - static RunOptions* GetInstance() - { - static RunOptions s_instance; - return &s_instance; - } - - }; - - -} // namespace LArG4 - - -#endif // LArG4_RunOptions_H diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h new file mode 100644 index 000000000000..aab623292337 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/SDWrapper.h @@ -0,0 +1,106 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4CODE_SDWRAPPER_H +#define LARG4CODE_SDWRAPPER_H + +// System includes +#include <string> +#include <vector> +#include <memory> + +// External includes +#include "G4VSensitiveDetector.hh" + +// Framework includes +#include "StoreGate/WriteHandle.h" + + +// Forward declarations +class LArG4SimpleSD; +class LArHitContainer; +class LArG4CalibSD; +class CaloCalibrationHitContainer; + + +namespace LArG4 +{ + + namespace detail + { + + /// @class SDWrapper + /// @brief A template class which wraps multiple sensitive detectors. + /// + /// Allows for SD tools to manage several SDs which collaborate to fill one + /// hit container in a multi-threading-friendly way. The wrapper owns the + /// WriteHandle for the hit container and gathers hits from each SD at the + /// end of an event. + /// + /// The inheritance from G4VSensitiveDetector is merely a trick so the SD + /// tool can save this object in the SensitiveDetectorBase thread-local + /// container. It also allows to create the hit container at the right time + /// via the SD Initialize method invoked by Geant4. + /// + /// Clients shouldn't use this generic template directly, but should use + /// the explicitly allowed specializations given below. + /// + /// @author Steve Farrell <Steven.Farrell@cern.ch> + /// + template<class SDType, class HitContainerType> + class SDWrapper : public G4VSensitiveDetector + { + + public: + + /// Alias to the SD list type + using SDList_t = std::vector< std::unique_ptr<SDType> >; + + /// Construct the wrapper from the output collection name + SDWrapper(const std::string& name, const std::string& hitCollectionName); + + /// Add an SD to this wrapper + void addSD(std::unique_ptr<SDType> sd); + + /// Add a (non-owned) fast-sim SD by name + void addFastSimSD(const std::string& fastSimSDName); + + /// Beginning of G4 event; initialize the hit collection. + virtual void Initialize(G4HCofThisEvent*) override final; + + /// This method should not be called. It will throw. + virtual bool ProcessHits(G4Step*, G4TouchableHistory*) override final; + + /// Gather the hits into the WriteHandle from all the SDs + void EndOfAthenaEvent(); + + private: + + /// The hit container name + std::string m_hitCollName; + + /// The hit container handle + SG::WriteHandle<HitContainerType> m_hitColl; + + /// The list of sensitive detectors that I own and manage + SDList_t m_sdList; + + /// A fastsim SD name that I do not own but invoke in order to + /// share my hit container. For now I'm assuming there is only one. + std::string m_fastSimSDName; + + }; // class SDWrapper + + } // namespace detail + + + /// Template instantiation for LArG4SimpleSD + using SimpleSDWrapper = detail::SDWrapper<LArG4SimpleSD, LArHitContainer>; + + /// Template instantiation for LArG4CalibSD + using CalibSDWrapper = detail::SDWrapper<LArG4CalibSD, CaloCalibrationHitContainer>; + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/SimpleSDTool.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/SimpleSDTool.h new file mode 100644 index 000000000000..dc5685de2b08 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/SimpleSDTool.h @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4CODE_SIMPLESDTOOL_H +#define LARG4CODE_SIMPLESDTOOL_H + +/// @file SimpleSDTool.h +/// @brief Defines the SimpleSDTool class +/// @author Steve Farrell <Steven.Farrell@cern.ch> +/// @date 2016-03-26 + +// System includes +#include <string> +#include <vector> + +// G4Atlas includes +#include "G4AtlasTools/SensitiveDetectorBase.h" + +// Local includes +#include "LArG4SimpleSD.h" + +// Forward declarations +class ILArCalculatorSvc; +class LArEM_ID; +class LArFCAL_ID; +class LArHEC_ID; +class LArMiniFCAL_ID; +class LArG4SimpleSD; + +namespace LArG4 +{ + + /// @class SimpleSDTool + /// @brief A base class for tools that manage LArG4SimpleSDs. + /// + /// @todo Add more details. + /// + /// @author Steve Farrell <Steven.Farrell@cern.ch> + /// + class SimpleSDTool : public SensitiveDetectorBase + { + + public: + + /// Constructor + SimpleSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + /// Initialize the tool + StatusCode initialize() override final; + + /// Calls down to all the SDs to pack their hits into one collection + StatusCode Gather() override final; + + protected: + + /// Initialize Calculator Services + virtual StatusCode initializeCalculators() { return StatusCode::SUCCESS; } + + /// Helper method to create one SD + std::unique_ptr<LArG4SimpleSD> + makeOneSD(const std::string& name, ILArCalculatorSvc* calc, + const std::vector<std::string>& volumes) const; + + /// Are we handling frozen shower fast sim? + bool useFrozenShowers() const { return m_useFrozenShowers; } + + protected: + + /// @name configuration properties + /// @{ + + /// What time binning type for regular hits? + std::string m_timeBinType; + /// What time bin width for regular hits? + float m_timeBinWidth; + /// Is there going to be a fast simulation coming into this SD? + G4bool m_useFrozenShowers; + + /// @} + + /// @name Calo identifier helpers + /// @{ + const LArEM_ID* m_larEmID; + const LArFCAL_ID* m_larFcalID; + const LArHEC_ID* m_larHecID; + const LArMiniFCAL_ID* m_larMiniFcalID; + /// @} + + }; // class SimpleSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/VCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/VCalibrationCalculator.h deleted file mode 100644 index 57b0aad0b51a..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/VCalibrationCalculator.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// VCalibrationCalculator.h -// Prepared 08-Jan-2004 Bill Seligman - -// This is an abstract base for a calibration hit calculator in LArG4. - -// A "calculator" is used in much the same way as a hand-held -// calculator might be. The user supplies a value and hits 'Enter' -// (i.e., invokes the Process() method). Then they read off whatever -// values are of interest. - -#ifndef LArG4_VCalibrationCalculator_H -#define LArG4_VCalibrationCalculator_H - -#include "globals.hh" - -#include <vector> - -// Forward declaractions: -class LArG4Identifier; -class G4Step; - -namespace LArG4 { - - class VCalibrationCalculator { - public: - - virtual ~VCalibrationCalculator() {}; - - // The Process method returns a boolean value. If it's true, the - // hit can be used by Geant4; if it's false, there's something wrong - // with the energy deposit and it should be ignored. - - // For calibration work, most of the time we want the calculator - // to determine both the energy and the identifier. However, - // sometimes we want it calculate only the identifier (for escaped - // energy), or only the energy (no known application yet, but you - // can never tell). Use the enum to control any special - // processing. - - enum eCalculatorProcessing { kEnergyAndID, kOnlyEnergy, kOnlyID }; - - virtual G4bool Process (const G4Step*, - const eCalculatorProcessing = kEnergyAndID) = 0; - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const = 0; - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const = 0; - }; - -} // namespace LArG4 - -#endif // LArG4_VCalibrationCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/VolumeUtils.h b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/VolumeUtils.h new file mode 100644 index 000000000000..1ef713883e12 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/VolumeUtils.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4CODE_VOLUMEUTILS_H +#define LARG4CODE_VOLUMEUTILS_H + +/** + @file VolumeUtils.h + @brief Standalone functions for dealing with LAr G4 volumes + @author Steve Farrell <Steven.Farrell@cern.ch> + */ + +// System includes +#include <string> +#include <vector> + +// Gaudi includes +#include "GaudiKernel/MsgStream.h" + +namespace LArG4 +{ + + /** @brief Search for logical volumes in the G4 volume store. + * + * Uses the global G4LogicalVolumeStore to search the geometry. + * The pattern may contain '*' wildcards. + * + * @return a set of available volume names matching the wildcard pattern. + */ + std::set<std::string> findLogicalVolumes(const std::string& pattern); + + + /** @brief Search for multiple logical volumes in G4 volume store. + * + * This function does a search for each input pattern in the + * G4LogicalVolumeStore using the findLogicalVolumes function above. + * It uses the provided MsgStream object to print a warning for every + * pattern that yields zero matches. + * + * @return a list of available volume names matching the wildcard patterns. + */ + std::vector<std::string> + findLogicalVolumes(const std::vector<std::string>& patterns, + MsgStream& msg); + +} + +#endif diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/selectionEnums.xml b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/selectionEnums.xml new file mode 100644 index 000000000000..3827373bde95 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/LArG4Code/selectionEnums.xml @@ -0,0 +1,7 @@ +<lcgdict> + + <enum pattern="LArG4::*"/> + <variable pattern="LArG4::*"/> + <class name="LArG4::ROOT6_NamespaceAutoloadHook" /> + +</lcgdict> diff --git a/LArCalorimeter/LArG4/LArG4Code/cmt/requirements b/LArCalorimeter/LArG4/LArG4Code/cmt/requirements index 3a01e6fd98dd..de7d275d8453 100644 --- a/LArCalorimeter/LArG4/LArG4Code/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4Code/cmt/requirements @@ -7,27 +7,34 @@ author Mikhail Leltchouk <lelchuk@nevis.columbia.edu> # packages in LArG4. public -use AtlasPolicy AtlasPolicy-* -use LArGeoCode LArGeoCode-* LArCalorimeter/LArGeoModel -use AtlasCLHEP AtlasCLHEP-* External -use CaloG4Sim CaloG4Sim-* Calorimeter -use CaloSimEvent CaloSimEvent-* Calorimeter -use G4AtlasTools G4AtlasTools-* Simulation/G4Atlas -use Geant4 Geant4-* External -use LArSimEvent LArSimEvent-* LArCalorimeter +use AtlasPolicy AtlasPolicy-* +use AtlasReflex AtlasReflex-* External +use AthenaBaseComps AthenaBaseComps-* Control +use GaudiInterface GaudiInterface-* External +use LArGeoCode LArGeoCode-* LArCalorimeter/LArGeoModel +use AtlasCLHEP AtlasCLHEP-* External +use CaloG4Sim CaloG4Sim-* Calorimeter +use CaloSimEvent CaloSimEvent-* Calorimeter +use G4AtlasTools G4AtlasTools-* Simulation/G4Atlas +use Geant4 Geant4-* External +use LArSimEvent LArSimEvent-* LArCalorimeter +use StoreGate StoreGate-* Control private -use AthenaKernel AthenaKernel-* Control -use CaloIdentifier CaloIdentifier-* Calorimeter -use MCTruth MCTruth-* Simulation/G4Sim -use StoreGate StoreGate-* Control +use AthenaKernel AthenaKernel-* Control +use CxxUtils CxxUtils-* Control +use CaloIdentifier CaloIdentifier-* Calorimeter +use MCTruth MCTruth-* Simulation/G4Sim end_private # Add the compiler macro definitions for cmake (transparent to CMT) apply_pattern cmake_add_command command="add_definitions(-DLARG4NOROOT)" +apply_pattern lcgdict dict=LArG4CodeEnums selectionfile=selectionEnums.xml \ + headerfiles="../LArG4Code/LArG4EnumDefs.h" + # Build the library (and export the headers) -library LArG4Code *.cc +library LArG4Code *.cc *.cxx apply_pattern installed_library macro_append LArG4Code_cppflags " -DLARG4NOROOT " diff --git a/LArCalorimeter/LArG4/LArG4Code/src/CalibSDTool.cc b/LArCalorimeter/LArG4/LArG4Code/src/CalibSDTool.cc new file mode 100644 index 000000000000..bb2737267ea9 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/src/CalibSDTool.cc @@ -0,0 +1,119 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArG4Code/CalibSDTool.h" + +// Framework utilities +#include "CxxUtils/make_unique.h" + +// ID helper includes +#include "CaloIdentifier/CaloIdManager.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/LArFCAL_ID.h" +#include "CaloIdentifier/LArHEC_ID.h" +#include "CaloIdentifier/LArMiniFCAL_ID.h" +#include "CaloIdentifier/CaloDM_ID.h" + +// Local includes +#include "LArG4Code/SDWrapper.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" +#include "LArG4Code/VolumeUtils.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Tool constructor + //--------------------------------------------------------------------------- + CalibSDTool::CalibSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : SensitiveDetectorBase(type, name, parent), + m_doPID(false), + m_larEmID(nullptr), + m_larFcalID(nullptr), + m_larHecID(nullptr), + m_larMiniFcalID(nullptr), + m_caloDmID(nullptr) + { + declareProperty("ParticleID", m_doPID); + } + + //--------------------------------------------------------------------------- + // Initialize the tool + //--------------------------------------------------------------------------- + StatusCode CalibSDTool::initialize() + { + ATH_MSG_DEBUG( "Initializing " << name() ); + + const CaloIdManager* idMgr = nullptr; + CHECK( detStore()->retrieve(idMgr) ); + if( (m_larEmID = idMgr->getEM_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr EM ID helper"); + return StatusCode::FAILURE; + } + if( (m_larFcalID = idMgr->getFCAL_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr FCAL ID helper"); + return StatusCode::FAILURE; + } + if( (m_larHecID = idMgr->getHEC_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr HEC ID helper"); + return StatusCode::FAILURE; + } + if( (m_larMiniFcalID = idMgr->getMiniFCAL_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr Mini FCAL ID helper"); + return StatusCode::FAILURE; + } + if( (m_caloDmID = idMgr->getDM_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid CaloDM ID helper"); + return StatusCode::FAILURE; + } + + // No general volume list for SensitiveDetectorBase + m_noVolumes = true; + + ATH_CHECK(this->initializeCalculators()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Collect hits for this event + //--------------------------------------------------------------------------- + StatusCode CalibSDTool::Gather() + { + auto sdWrapper = dynamic_cast<CalibSDWrapper*>( getSD() ); + if(!sdWrapper) { + ATH_MSG_ERROR("Failed to cast SD to CalibSDWrapper"); + return StatusCode::FAILURE; + } + sdWrapper->EndOfAthenaEvent(); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create one calib SD + //--------------------------------------------------------------------------- + std::unique_ptr<LArG4CalibSD> + CalibSDTool::makeOneSD(const std::string& sdName, ILArCalibCalculatorSvc* calc, + const std::vector<std::string>& volumes) const + { + ATH_MSG_VERBOSE( name() << " makeOneSD" ); + + // Parse the wildcard patterns for existing volume names + auto parsedVolumes = findLogicalVolumes(volumes, msg()); + + // Create the calib SD + auto sd = CxxUtils::make_unique<LArG4CalibSD>(sdName, calc, m_doPID); + sd->setupHelpers(m_larEmID, m_larFcalID, m_larHecID, m_larMiniFcalID, m_caloDmID); + + // Assign the volumes to the SD + if( assignSD( sd.get(), parsedVolumes ).isFailure() ) { + // TODO: can I just return NULL here? + throw GaudiException("Failed to assign sd: " + sdName, + name(), StatusCode::FAILURE); + } + return std::move(sd); + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Code/src/CalibrationDefaultCalculator.cc b/LArCalorimeter/LArG4/LArG4Code/src/CalibrationDefaultCalculator.cc deleted file mode 100644 index 15c92c06d3d2..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/src/CalibrationDefaultCalculator.cc +++ /dev/null @@ -1,319 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::CalibrationDefaultCalculator -// Prepared 04-Mar-2004 Bill Seligman -// Modified 22-Sep-2004 Mikhail Leltchouk - -// The calibration studies rely on every volume in the simulation -// being made into a sensitive detector. There is a practical -// problem: What if we're still in the middle of developing code, and -// not every volume has been made sensitive yet? What if we've -// overlooked a volume? Or (the most common case), what if we have an -// energy deposit in a volume that is not being directly calibrated? - -// This class provides a "default behavior" for all energy deposits -// that are not made in a volume that's been made sensitive for -// calibration studies. - -// This class calculates the values needed for calibration hits in the -// simulation. - -#undef DEBUG_HITS -#undef DEBUG_VOLUMES - -#include "LArG4Code/CalibrationDefaultCalculator.h" -#include "LArG4Code/LArG4Identifier.h" - -#include "G4ThreeVector.hh" -#include "G4Step.hh" -#include "globals.hh" -#include "CLHEP/Units/PhysicalConstants.h" - -#include <cmath> -#include <string> -#include <climits> -#include <algorithm> -#include <set> -#include <numeric> - -#undef DEBUG_DMXYZ - -namespace LArG4 { - - CalibrationDefaultCalculator::CalibrationDefaultCalculator() - { - } - - - CalibrationDefaultCalculator::~CalibrationDefaultCalculator() - { - } - - - G4bool CalibrationDefaultCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else { - for (unsigned int i=0; i != 4; i++) m_energies.push_back(0.); - } - - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Call after volume-by-volume calls only if none of these calls assigned - // the SimulationEnergies::Energies of current step to identifier and one - // of the existing hit collections. - - static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. - static const double oneOverDphi = 32./M_PI; // 1/Dphi - static const int phiBinMax = 63; - static const double rhoAlignmentSafety = 50.*CLHEP::mm; - static const double zAlignmentSafety = 100.*CLHEP::mm; - static const double rhoCalorOut = 3885.*CLHEP::mm - rhoAlignmentSafety; - static const double zCalorOut = 6100.*CLHEP::mm - zAlignmentSafety; - static const double rhoInDetOut = 1150.*CLHEP::mm + rhoAlignmentSafety; - static const double zInDetOut = 3511.*CLHEP::mm + zAlignmentSafety; - static const double startZFCal1 = 4668.5 - zAlignmentSafety; - static const double z1BeforeFCal = 4225.5 + zAlignmentSafety; // - static const double z2BeforeFCal = 4557.5 + zAlignmentSafety; // - // Calculate the mid-point of the step, and the simple geometry variables. - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - G4double rho = p.perp(); - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - if ( phi<0. ) { phi += 2.*M_PI; } // Normalize for phiBin calculation - - G4int detector = 10; // calorimeter "dead" materials - - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int subdet = INT_MIN; - G4int type = INT_MIN; - G4int sampling = INT_MIN; - G4int region = INT_MIN; - G4int etaBin = INT_MIN; - G4int phiBin = INT_MIN; - - if ( eta > 5. ) // "forward" leakage - { - // subdet = +/-4, "+" or " -" according to sign of Z in World coorinate - subdet = ( p.z() > 0.) ? 4 : -4; - // type = 1, sampling = 3 leakage outside calorimeters: - type = 1; - sampling = 3; - if ( eta < 8.) // leakage between eta = 5 and 8 - { - region = 1; - etaBin = (int) ( ( eta - 5. ) * 0.5 * oneOverDeta ); - phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>phiBinMax) phiBin=phiBinMax; - } - else // "very forward" leakage eta >= 8. - { - region = 2; - etaBin = 0; // no eta-phi subdivision - phiBin = 0; - } - } - else if ( rho > rhoCalorOut || fabs( p.z() ) > zCalorOut ) - { - // type = 1, sampling = 3 leakage outside calorimeters: - type = 1; - sampling = 3; - region = 0; - phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>phiBinMax) phiBin=phiBinMax; - - if ( eta < 1.7) // leakage outside Tile - { - // subdet = +/-5, "+" or " -" according to sign of Z in World coorinate - subdet = ( p.z() > 0.) ? 5 : -5; - etaBin = (int) ( eta * oneOverDeta ); - } - else // leakage outside LAr HEC - { - // subdet = +/-4, "+" or " -" according to sign of Z in World coorinate - subdet = ( p.z() > 0.) ? 4 : -4; - etaBin = (int) ( ( eta - 1.7 ) * oneOverDeta ); - } // outside at eta covered by Tile or by LAr HEC - - } // leakage outside calorimeters: - - else if ( rho < rhoInDetOut && fabs( p.z() ) < zInDetOut ) - - { - subdet = ( p.z() > 0.) ? 4 : -4; - // type = 1, sampling = 0, region = 1-5 => Inner Detector - type = 1; - sampling = 0; - region = 5; // TRT support, cables, services - if ( rho < 980.*CLHEP::mm ) region = 4; // TRT - if ( rho < 650.*CLHEP::mm ) region = 3; // support - if ( rho < 540.*CLHEP::mm ) region = 2; // SCT - if ( rho < 270.*CLHEP::mm ) region = 1; // Pixels with support, beam pipe - etaBin = (int) ( eta * oneOverDeta ); - phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>phiBinMax) phiBin=phiBinMax; - - // g.p. 23.05.2011 beam pipe material outside of inner detector area close to FCal - } else if( fabs( p.z() ) >= zInDetOut) { - subdet = ( p.z() > 0.) ? 4 : -4; - phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>phiBinMax) phiBin=phiBinMax; - if(eta>=2.9 && eta<5.0) { - if(fabs(p.z()) < z1BeforeFCal) { - type = 1; - sampling = 1; - region = 7; - etaBin = (int) ( (eta-3.2) * oneOverDeta ); - } else if (fabs(p.z()) < z2BeforeFCal){ - type = 2; - sampling = 0; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } else if (fabs(p.z()) < startZFCal1) { - type = 2; - sampling = 1; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } - // g.p. back leakages in beam pipe - } else if ( eta >= 5. && eta < 8.0) { - type = 1; - sampling = 3; - region = 1; - etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); - } else if (eta>8.) { - type = 1; - sampling = 3; - region = 2; - etaBin = 0; - phiBin = 0; - } - if(etaBin<0) etaBin=0; - } - - - // If the point falls outside any of the above "if" - // statements, use a "none-of-the-above" identifier. - - if - ( subdet == INT_MIN || - type == INT_MIN || - sampling == INT_MIN || - region == INT_MIN || - etaBin == INT_MIN || - phiBin == INT_MIN ) - { -#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) - static std::set<G4String> volumeList; - G4String namePhys = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); - G4String nameLog = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); - - std::set<G4String>::iterator i = volumeList.find( nameLog ); - if ( i == volumeList.end() ) - { - volumeList.insert( nameLog ); - std::cout << "LArG4::CalibrationDefaultCalculator::Process" - << std::endl - << " default ID used in logical volume '" - << nameLog - << "'" - << std::endl - << " (each such volume is only listed once)" - << std::endl; - } - - static const G4int messageMax = 10; - static G4int messageCount = 0; - if ( messageCount++ < messageMax ) - { - std::cout << " detailed error (" << messageCount - << " of " << messageMax << " max displayed):" - << std::endl - << " G4Step at unexpected place: (x,y,z) [mm] = (" - << p.x()/mm << "," - << p.y()/mm << "," - << p.z()/mm - << "), eta=" << eta - << ", phi=" << phi - << ", rho=" << rho - << std::endl - << " in physical volume '" << namePhys << "'" - << std::endl - << " (subdet,type,sampling,region,etaBin,phiBin)=(" - << subdet << "," - << type << "," - << sampling << "," - << region << "," - << etaBin << "," - << phiBin - << "); using default ID" - << std::endl; - } -#endif - subdet = ( p.z() > 0.) ? 4 : -4; - type = 1; - sampling = 0; - region = 0; - etaBin = (int) ( eta * oneOverDeta ); - if ( etaBin > 49 ) etaBin = 49; - phiBin = (int) ( phi * oneOverDphi ); - if (phiBin>phiBinMax) phiBin=phiBinMax; -#ifdef DEBUG_DMXYZ - G4double energy = std::accumulate(m_energies.begin(),m_energies.end(), 0.); - if(energy > 1e-15) LArG4::CalibrationDefaultCalculator::Print("UNEXP DefaultCalculator",m_identifier,a_step,m_energies); -#endif - } - - // Create the LArG4Identifier. - m_identifier << detector - << subdet - << type - << sampling - << region - << etaBin - << phiBin; - } - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::CalibrationDefaultCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif -#ifdef DEBUG_DMXYZ -// LArG4::CalibrationDefaultCalculator::Print("DMXYZ DefaultCalculator",m_identifier,a_step,m_energies); -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc b/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc index 9f1b42fd3223..3ea60f5b1548 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/CalibrationHit.cc @@ -12,7 +12,7 @@ #include "G4Allocator.hh" #include "G4ios.hh" #include "globals.hh" -#include "AthenaKernel/Units.h" +#include "AthenaKernel/Units.h" namespace LArG4 { diff --git a/LArCalorimeter/LArG4/LArG4Code/src/EscapedEnergyProcessing.cc b/LArCalorimeter/LArG4/LArG4Code/src/EscapedEnergyProcessing.cc index 8651df642c86..0f4792416dad 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/EscapedEnergyProcessing.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/EscapedEnergyProcessing.cc @@ -18,7 +18,7 @@ #undef DEBUG_PROCESS -using namespace LArG4; +//using namespace LArG4; EscapedEnergyProcessing::EscapedEnergyProcessing(LArG4CalibSD* SD) : m_defaultSD(SD) diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArCalculatorSvcImp.cxx b/LArCalorimeter/LArG4/LArG4Code/src/LArCalculatorSvcImp.cxx new file mode 100644 index 000000000000..fb73b7c3788f --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/src/LArCalculatorSvcImp.cxx @@ -0,0 +1,30 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArG4Code/LArCalculatorSvcImp.h" + +#include "CLHEP/Units/SystemOfUnits.h" + +LArCalculatorSvcImp::LArCalculatorSvcImp(const std::string& name, ISvcLocator *pSvcLocator) + : AthService(name, pSvcLocator) + , m_BirksLaw(true) + , m_Birksk(0.0486) + , m_OOTcut(300*CLHEP::ns) +{ + declareProperty("BirksLaw",m_BirksLaw); + declareProperty("Birksk",m_Birksk); + declareProperty("OOTcut",m_OOTcut); +} + +StatusCode LArCalculatorSvcImp::queryInterface( const InterfaceID & riid, void** ppvInterface ) +{ + if ( ILArCalculatorSvc::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<ILArCalculatorSvc*>(this); + } else { + // Interface is not directly available : try out a base class + return AthService::queryInterface(riid, ppvInterface); + } + addRef(); + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArCalibCalculatorSvcImp.cxx b/LArCalorimeter/LArG4/LArG4Code/src/LArCalibCalculatorSvcImp.cxx new file mode 100644 index 000000000000..6deb8ce6a089 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/src/LArCalibCalculatorSvcImp.cxx @@ -0,0 +1,22 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArG4Code/LArCalibCalculatorSvcImp.h" + +LArCalibCalculatorSvcImp::LArCalibCalculatorSvcImp(const std::string& name, ISvcLocator *pSvcLocator) + : AthService(name, pSvcLocator) +{ +} + +StatusCode LArCalibCalculatorSvcImp::queryInterface( const InterfaceID & riid, void** ppvInterface ) +{ + if ( ILArCalibCalculatorSvc::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<ILArCalibCalculatorSvc*>(this); + } else { + // Interface is not directly available : try out a base class + return AthService::queryInterface(riid, ppvInterface); + } + addRef(); + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArG4CalibSD.cc b/LArCalorimeter/LArG4/LArG4Code/src/LArG4CalibSD.cc index 6b7a5145e8f9..4677d54edfd2 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/LArG4CalibSD.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/LArG4CalibSD.cc @@ -4,7 +4,7 @@ #include "LArG4Code/LArG4CalibSD.h" -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" #include "CaloIdentifier/LArID_Exception.h" #include "CaloIdentifier/LArEM_ID.h" #include "CaloIdentifier/LArFCAL_ID.h" @@ -18,7 +18,7 @@ #include "G4Step.hh" -LArG4CalibSD::LArG4CalibSD(G4String a_name, LArG4::VCalibrationCalculator* calc, bool doPID) +LArG4CalibSD::LArG4CalibSD(G4String a_name, ILArCalibCalculatorSvc* calc, bool doPID) : G4VSensitiveDetector(a_name) , m_calculator(calc) , m_numberInvalidHits(0) @@ -53,12 +53,15 @@ G4bool LArG4CalibSD::ProcessHits(G4Step* a_step,G4TouchableHistory*) // it occurred outside the sensitive region. If such a thing // happens, it means that the geometry definitions in the // detector-construction routine and the calculator do not agree.) - if(!(m_calculator->Process(a_step))) { + LArG4Identifier _identifier; + std::vector<G4double> _energies; + + if(!(m_calculator->Process(a_step, _identifier, _energies))) { m_numberInvalidHits++; return false; } - return SimpleHit( m_calculator->identifier() , m_calculator->energies() ); + return SimpleHit( _identifier , _energies ); } G4bool LArG4CalibSD::SimpleHit( const LArG4Identifier& a_ident , const std::vector<double>& energies ){ @@ -150,10 +153,13 @@ G4bool LArG4CalibSD::SimpleHit( const LArG4Identifier& a_ident , const std::vect G4bool LArG4CalibSD::SpecialHit(G4Step* a_step, const std::vector<G4double>& a_energies) { + LArG4Identifier _identifier; + std::vector<G4double> _vtmp; + // If we can't calculate the identifier, something is wrong. - if (!(m_calculator->Process( a_step, LArG4::VCalibrationCalculator::kOnlyID))) return false; + if (!(m_calculator->Process( a_step, _identifier, _vtmp, LArG4::kOnlyID))) return false; - return SimpleHit( m_calculator->identifier() , a_energies ); + return SimpleHit( _identifier , a_energies ); } diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArG4DetectorComponents.cc b/LArCalorimeter/LArG4/LArG4Code/src/LArG4DetectorComponents.cc deleted file mode 100644 index 3d36dbb3c601..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/src/LArG4DetectorComponents.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4DetectorComponents -// Maintain a list of detector components. -// 05-Jun-2003 Bill Seligman - -#include "LArG4Code/LArG4DetectorComponents.h" -#include "LArG4Code/LArVolumeInterface.h" - -#include <map> - -// Standard implementation of a singleton pattern. - -LArG4DetectorComponents* LArG4DetectorComponents::GetInstance() -{ - static LArG4DetectorComponents instance; - return &instance; -} - -G4bool LArG4DetectorComponents::m_zNeg = false; - -LArG4DetectorComponents::LArG4DetectorComponents() {;} - -LArG4DetectorComponents::~LArG4DetectorComponents() {;} - - -// Add a detector component to the list. -void LArG4DetectorComponents::SetDetectorComponent( const EDetectorComponent e, LArVolumeInterface* v ) -{ - m_detectorMap[e] = v; -} - - -// Fetch a component from the list. If we can't find it, just return -// a null pointer. -LArVolumeInterface* LArG4DetectorComponents::GetDetectorComponent( const EDetectorComponent e ) const -{ - m_detectorMap_ptr i = m_detectorMap.find(e); - - if ( i == m_detectorMap.end() ) - return 0; - - // Reminder: - // i == a pointer to one entry in detectorMap - // (*i) = a pair<EDetectorComponent, LArVolumeInterface*> - // (*i).second = a LArVolumeInterface* - - return (*i).second; -} diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArG4SDTool.cc b/LArCalorimeter/LArG4/LArG4Code/src/LArG4SDTool.cc index 73673ad394a7..2c1246ded1f9 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/LArG4SDTool.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/LArG4SDTool.cc @@ -43,29 +43,38 @@ LArG4SDTool::LArG4SDTool(const std::string& type, const std::string& name, const StatusCode LArG4SDTool::initialize() { const CaloIdManager* caloIdManager=nullptr; - CHECK( detStore()->retrieve(caloIdManager) ); - - // FIXME: why are we throwing from this method? Return StatusCode::FAILURE! - + ATH_CHECK( detStore()->retrieve(caloIdManager) ); m_larEmID = caloIdManager->getEM_ID(); if(m_larEmID==0) - throw std::runtime_error("LArG4SDTool: Invalid LAr EM ID helper"); - + { + ATH_MSG_ERROR("LArG4SDTool: Invalid LAr EM ID helper"); + return StatusCode::FAILURE; + } m_larFcalID = caloIdManager->getFCAL_ID(); if(m_larFcalID==0) - throw std::runtime_error("LArG4SDTool: Invalid FCAL ID helper"); - + { + ATH_MSG_ERROR("LArG4SDTool: Invalid FCAL ID helper"); + return StatusCode::FAILURE; + } m_larHecID = caloIdManager->getHEC_ID(); if(m_larHecID==0) - throw std::runtime_error("LArG4SDTool: Invalid HEC ID helper"); - + { + ATH_MSG_ERROR("LArG4SDTool: Invalid HEC ID helper"); + return StatusCode::FAILURE; + } m_larMiniFcalID = caloIdManager->getMiniFCAL_ID(); if(m_larMiniFcalID==0) - throw std::runtime_error("LArG4SDTool: Invalid Mini FCAL ID helper"); - + { + ATH_MSG_ERROR("LArG4SDTool: Invalid Mini FCAL ID helper"); + return StatusCode::FAILURE; + } m_caloDmID = caloIdManager->getDM_ID(); if(!m_caloDmID) - throw std::runtime_error("LArG4SDTool: Invalid CaloDM ID helper"); + { + ATH_MSG_ERROR("LArG4SDTool: Invalid CaloDM ID helper"); + return StatusCode::FAILURE; + } + ATH_CHECK(this->initializeCalculators()); return StatusCode::SUCCESS; } diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArG4SimpleSD.cc b/LArCalorimeter/LArG4/LArG4Code/src/LArG4SimpleSD.cc index f058fead8ccf..db4a6c31dcae 100644 --- a/LArCalorimeter/LArG4/LArG4Code/src/LArG4SimpleSD.cc +++ b/LArCalorimeter/LArG4/LArG4Code/src/LArG4SimpleSD.cc @@ -5,7 +5,7 @@ #include "LArG4Code/LArG4SimpleSD.h" #include "LArG4Code/LArG4Hit.h" -#include "LArG4Code/LArVCalculator.h" +#include "LArG4Code/ILArCalculatorSvc.h" #include "CaloIdentifier/CaloIdManager.h" #include "CaloIdentifier/LArID_Exception.h" #include "CaloIdentifier/LArEM_ID.h" @@ -20,7 +20,7 @@ #include "G4Step.hh" -LArG4SimpleSD::LArG4SimpleSD(G4String a_name, LArVCalculator* calc, const std::string& type, const float width) +LArG4SimpleSD::LArG4SimpleSD(G4String a_name, ILArCalculatorSvc* calc, const std::string& type, const float width) : G4VSensitiveDetector(a_name) , m_calculator(calc) , m_numberInvalidHits(0) @@ -95,7 +95,9 @@ G4bool LArG4SimpleSD::ProcessHits(G4Step* a_step,G4TouchableHistory*) // it occurred outside the sensitive region. If such a thing // happens, it means that the geometry definitions in the // detector-construction routine and the calculator do not agree.) - if(!(m_calculator->Process(a_step))) { + std::vector<LArHitData> hits; + + if(!(m_calculator->Process(a_step, hits))) { m_numberInvalidHits++; return false; } @@ -103,12 +105,18 @@ G4bool LArG4SimpleSD::ProcessHits(G4Step* a_step,G4TouchableHistory*) // A calculator can determine that a given energy deposit results // in more than one hit in the simulation. FOr each such hit... G4bool result = true; - for(int ihit=0; ihit<m_calculator->getNumHits(); ++ihit) { +// for(int ihit=0; ihit<m_calculator->getNumHits(); ++ihit) { +// // Ported in from the old LArG4HitMerger code +// result = result && SimpleHit( m_calculator->identifier(ihit) , +// m_calculator->time(ihit) , +// m_calculator->energy(ihit) ); +// } + for(const auto &ihit : hits) { // Ported in from the old LArG4HitMerger code - result = result && SimpleHit( m_calculator->identifier(ihit) , - m_calculator->time(ihit) , - m_calculator->energy(ihit) ); - } + result = result && SimpleHit( ihit.id , + ihit.time, + ihit.energy ); + } return result; } diff --git a/LArCalorimeter/LArG4/LArG4Code/src/LArHitMaker.cc b/LArCalorimeter/LArG4/LArG4Code/src/LArHitMaker.cc deleted file mode 100644 index 2025b2ec8ad4..000000000000 --- a/LArCalorimeter/LArG4/LArG4Code/src/LArHitMaker.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArHitMaker - -// Created by F. Mazzucato, September 2002 -// Modified my E.Barberio January 2003 -// LArG4 compatibility introduced 30-Apr-2003 Bill Seligman - -// 11-Aug-04 WGS: It appears that having more than one G4Navigator -// object in Geant4 may be a bad idea. Don't create a separate -// G4Navigator for this class; use the one in G4TransportationManager. - -#include "LArG4Code/LArHitMaker.h" -#include "LArG4Code/EnergySpot.h" - -#include "G4TransportationManager.hh" -#include "G4VSensitiveDetector.hh" -#include "G4TouchableHandle.hh" -#include "G4TouchableHistory.hh" -#include "G4Step.hh" -#include "G4StepPoint.hh" -#include "G4Navigator.hh" -#include "G4VPhysicalVolume.hh" - -#include "globals.hh" -#include "G4ios.hh" - -#undef DEBUG_FAST - -LArHitMaker::LArHitMaker() -{ - // Initialize the fake G4Step that we'll pass to the sensitive - // detector. - - m_fakeStep = new G4Step(); - m_fakePreStepPoint = m_fakeStep->GetPreStepPoint(); - m_fakePostStepPoint = m_fakeStep->GetPostStepPoint(); - m_touchableHandle = new G4TouchableHistory(); - m_pNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking(); - m_naviSetup = false; - m_baseName = "LAr"; -} - - -LArHitMaker::~LArHitMaker() -{ - // Cleanup pointers. - delete m_fakeStep; - delete m_pNavigator; -} - - -void LArHitMaker::make(const EnergySpot& a_spot) -{ - // ------------------- - // Locate the spot. Use m_naviSetup to test whether we've - // initialized the G4Navigator _after_ all the G4 geometry - // construction routines have executed. - // ------------------- -#ifdef DEBUG_FAST - G4cout << "LArHitMaker::make -- Begin Class." - << G4endl; -#endif - - if (!m_naviSetup) - { - m_pNavigator-> - LocateGlobalPointAndUpdateTouchable(a_spot.GetPosition(), - m_touchableHandle(), - false); - m_naviSetup = true; - } - else - { - m_pNavigator-> - LocateGlobalPointAndUpdateTouchable(a_spot.GetPosition(), - m_touchableHandle() ); - } - - //-------------------------------------- - // Fill the attributes of the G4Step needed - // by our sensitive detector: - //------------------------------------- -#ifdef DEBUG_FAST - G4cout << "LArHitMaker::make -- ready to fill step." - << G4endl; -#endif - - // Get the position and time from the energy spot. - G4ThreeVector p = a_spot.GetPosition(); - G4double t = a_spot.GetTime(); - - // set touchable volume at PreStepPoint: - m_fakePreStepPoint->SetTouchableHandle(m_touchableHandle); - m_fakePreStepPoint->SetPosition(p); - m_fakePreStepPoint->SetGlobalTime(t); - - - // WGS: Most of the calculators in LArG4 expect a PostStepPoint as - // well. For now, try setting this to be the same as the - // PreStepPoint. - - // AS move post step point a little bit to make Calculator happy - - m_fakePostStepPoint->SetTouchableHandle(m_touchableHandle); - m_fakePostStepPoint->SetPosition(p); - m_fakePostStepPoint->SetGlobalTime(t); - - // set total energy deposit: - m_fakeStep->SetTotalEnergyDeposit(a_spot.GetEnergy()); - //set very short step length - m_fakeStep->SetStepLength(1e-10); - //set pre and post step point - m_fakeStep->SetPreStepPoint(m_fakePreStepPoint); - m_fakeStep->SetPostStepPoint(m_fakePostStepPoint); - m_fakeStep->SetTrack(0); - - //-------------------------------------- - // Produce Hits - //-------------------------------------- - - // First, find out in which physical volume our hit is located. - G4VPhysicalVolume* pCurrentVolume = - m_fakeStep->GetPreStepPoint()->GetPhysicalVolume(); - - // If the volume is valid... - if ( pCurrentVolume != 0 ) { - - // for the time being create hits only in LAr volumes - if ( (pCurrentVolume->GetName()).substr(0,m_baseName.length()) == m_baseName ) - { - - // Is this volume associated with a sensitive detector? - G4VSensitiveDetector* pSensitive; - if (pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector()){ - pSensitive = pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector(); - } - else { - return; - } - - if ( pSensitive != 0 ) - { - // Create the actual hit. - pSensitive->Hit(m_fakeStep); - } - - else - { - // If we reach this point, then the EnergySpot was created - // outside of a sensitive region. - - } - } -#ifdef DEBUG_FAST - else - { - G4cout << "LArHitMaker::make - will not make hit in " - << pCurrentVolume->GetName() - << " since volume name does not begin with " - << m_baseName - << G4endl; - } -#endif - } -} diff --git a/LArCalorimeter/LArG4/LArG4Code/src/SDWrapper.cc b/LArCalorimeter/LArG4/LArG4Code/src/SDWrapper.cc new file mode 100644 index 000000000000..0182d8d6325b --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/src/SDWrapper.cc @@ -0,0 +1,133 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArG4Code/SDWrapper.h" + +// Geant4 includes +#include "G4SDManager.hh" + +// Framework utilities +#include "CxxUtils/make_unique.h" + +// Project includes +#include "LArSimEvent/LArHitContainer.h" +#include "CaloSimEvent/CaloCalibrationHitContainer.h" + +// Local includes +#include "LArG4Code/LArG4SimpleSD.h" +#include "LArG4Code/LArG4CalibSD.h" + +namespace LArG4 +{ + + namespace detail + { + + //------------------------------------------------------------------------- + // Construct with a hit collection name + //------------------------------------------------------------------------- + template<class SDType, class HitContainerType> + SDWrapper<SDType, HitContainerType>:: + SDWrapper(const std::string& name, const std::string& hitCollectionName) + : G4VSensitiveDetector(name), + m_hitCollName(hitCollectionName), + m_hitColl(hitCollectionName) + {} + + //------------------------------------------------------------------------- + // Add a unique SD to the list + //------------------------------------------------------------------------- + template<class SDType, class HitContainerType> + void SDWrapper<SDType, HitContainerType>:: + addSD(std::unique_ptr<SDType> sd) + { + m_sdList.push_back( std::move(sd) ); + } + + //------------------------------------------------------------------------- + // Add a fast-sim SD name + //------------------------------------------------------------------------- + template<class SDType, class HitContainerType> + void SDWrapper<SDType, HitContainerType>:: + addFastSimSD(const std::string& sdName) + { + // For now, assume only one fastsim SD + if(!m_fastSimSDName.empty()) { + G4cerr << GetName() << " \tERROR\t" << "Trying to add fastsim SD " + << sdName << " after " << m_fastSimSDName << G4endl; + throw std::runtime_error("More than one fastsim SD"); + } + m_fastSimSDName = sdName; + } + + //------------------------------------------------------------------------- + // Initialize the hit collection at the beginning of the G4 event + //------------------------------------------------------------------------- + template<class SDType, class HitContainerType> + void SDWrapper<SDType, HitContainerType>:: + Initialize(G4HCofThisEvent*) + { + if(!m_hitColl.isValid()) { + if(verboseLevel >= 5) { + G4cout << GetName() << " \tDEBUG\t" << "Initializing hit container: " + << m_hitCollName << G4endl; + } + m_hitColl = CxxUtils::make_unique<HitContainerType>(m_hitCollName); + } + } + + //------------------------------------------------------------------------- + // This should not be called + //------------------------------------------------------------------------- + template<class SDType, class HitContainerType> + bool SDWrapper<SDType, HitContainerType>:: + ProcessHits(G4Step*, G4TouchableHistory*) + { + G4ExceptionDescription description; + description << "ProcessHits: this SD shouldn't be assigned to volumes!"; + G4Exception(GetName(), "SDError", FatalException, description); + return false; + } + + //------------------------------------------------------------------------- + // Gather the hits into the WriteHandle from all the SDs + //------------------------------------------------------------------------- + template<class SDType, class HitContainerType> + void SDWrapper<SDType, HitContainerType>:: + EndOfAthenaEvent() + { + if(!m_hitColl.isValid()) { + G4cerr << GetName() << " \tERROR\t" << "Hit collection WriteHandle is " + << "invalid!" << G4endl; + throw std::runtime_error("Invalid hit container WriteHandle: " + + m_hitColl.name()); + } + // Loop over each SD and fill the container + for(auto& sd : m_sdList) { + sd->EndOfAthenaEvent( &*m_hitColl ); + } + // Gather frozen shower hits + if(!m_fastSimSDName.empty()) { + auto fastSD = dynamic_cast<SDType*> + ( G4SDManager::GetSDMpointer()->FindSensitiveDetector(m_fastSimSDName) ); + if(fastSD) { + fastSD->EndOfAthenaEvent( &*m_hitColl ); + } + else { + G4cerr << GetName() << " \tERROR\t" << "Failed to retrieve/cast " + << m_fastSimSDName << G4endl; + throw std::runtime_error("Failed to retrieve/cast " + m_fastSimSDName); + } + } + } + + //------------------------------------------------------------------------- + // Explit template instantiations + //------------------------------------------------------------------------- + template class SDWrapper<LArG4SimpleSD, LArHitContainer>; + template class SDWrapper<LArG4CalibSD, CaloCalibrationHitContainer>; + + } // namespace detail + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Code/src/SimpleSDTool.cc b/LArCalorimeter/LArG4/LArG4Code/src/SimpleSDTool.cc new file mode 100644 index 000000000000..6da1a418d4d4 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/src/SimpleSDTool.cc @@ -0,0 +1,122 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArG4Code/SimpleSDTool.h" + +// External includes +#include "CLHEP/Units/SystemOfUnits.h" + +// Framework includes +#include "CxxUtils/make_unique.h" + +// ID helper includes +#include "CaloIdentifier/CaloIdManager.h" +#include "CaloIdentifier/LArEM_ID.h" +#include "CaloIdentifier/LArFCAL_ID.h" +#include "CaloIdentifier/LArHEC_ID.h" +#include "CaloIdentifier/LArMiniFCAL_ID.h" + +// Local includes +#include "LArG4Code/LArG4SimpleSD.h" +#include "LArG4Code/SDWrapper.h" +#include "LArG4Code/VolumeUtils.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Tool constructor + //--------------------------------------------------------------------------- + SimpleSDTool::SimpleSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : SensitiveDetectorBase(type, name, parent), + m_timeBinType("Default"), + m_timeBinWidth(2.5*CLHEP::ns), + m_useFrozenShowers(false), + m_larEmID(nullptr), + m_larFcalID(nullptr), + m_larHecID(nullptr), + m_larMiniFcalID(nullptr) + { + declareProperty("TimeBinType", m_timeBinType); + declareProperty("TimeBinWidth", m_timeBinWidth); + declareProperty("UseFrozenShowers", m_useFrozenShowers); + } + + //--------------------------------------------------------------------------- + // Initialize the tool + //--------------------------------------------------------------------------- + StatusCode SimpleSDTool::initialize() + { + ATH_MSG_DEBUG( "Initializing " << name() ); + + const CaloIdManager* idMgr = nullptr; + CHECK( detStore()->retrieve(idMgr) ); + if( (m_larEmID = idMgr->getEM_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr EM ID helper"); + return StatusCode::FAILURE; + } + if( (m_larFcalID = idMgr->getFCAL_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr FCAL ID helper"); + return StatusCode::FAILURE; + } + if( (m_larHecID = idMgr->getHEC_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr HEC ID helper"); + return StatusCode::FAILURE; + } + if( (m_larMiniFcalID = idMgr->getMiniFCAL_ID()) == nullptr) { + ATH_MSG_ERROR("Invalid LAr Mini FCAL ID helper"); + return StatusCode::FAILURE; + } + + // No general volume list for SensitiveDetectorBase + m_noVolumes = true; + + ATH_CHECK(this->initializeCalculators()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Collect hits for this event + //--------------------------------------------------------------------------- + StatusCode SimpleSDTool::Gather() + { + ATH_MSG_DEBUG("Gathering hits to write out in " << name()); + auto sdWrapper = dynamic_cast<SimpleSDWrapper*>( getSD() ); + if(!sdWrapper) { + ATH_MSG_ERROR("Failed to cast SD to SimpleSDWrapper"); + return StatusCode::FAILURE; + } + sdWrapper->EndOfAthenaEvent(); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create one SD + //--------------------------------------------------------------------------- + std::unique_ptr<LArG4SimpleSD> + SimpleSDTool::makeOneSD(const std::string& sdName, ILArCalculatorSvc* calc, + const std::vector<std::string>& volumes) const + { + ATH_MSG_VERBOSE( name() << " makeOneSD" ); + + // Parse the wildcard patterns for existing volume names + auto parsedVolumes = findLogicalVolumes(volumes, msg()); + + // Create the simple SD + auto sd = CxxUtils::make_unique<LArG4SimpleSD> + (sdName, calc, m_timeBinType, m_timeBinWidth); + sd->setupHelpers(m_larEmID, m_larFcalID, m_larHecID, m_larMiniFcalID); + + // Assign the volumes to the SD + if( assignSD( sd.get(), parsedVolumes ).isFailure() ) { + // TODO: can I just return NULL here? + throw GaudiException("Failed to assign sd: " + sdName, + name(), StatusCode::FAILURE); + } + return std::move(sd); + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Code/src/VolumeUtils.cc b/LArCalorimeter/LArG4/LArG4Code/src/VolumeUtils.cc new file mode 100644 index 000000000000..2c7c1bb68fa8 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4Code/src/VolumeUtils.cc @@ -0,0 +1,86 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "LArG4Code/VolumeUtils.h" + +// STL includes +#include <set> + +// Geant4 includes +#include "G4LogicalVolumeStore.hh" + +namespace +{ + //--------------------------------------------------------------------------- + /// @brief Helper function for matching strings with wildcards. + /// It's a recursive function that checks if two given strings match. + /// The first string may contain wildcard characters. + //--------------------------------------------------------------------------- + bool matchStrings(const char* first, const char* second) + { + // If we reach at the end of both strings, we are done + if (*first == '\0' && *second == '\0') + return true; + + // Make sure that the characters after '*' are present in second string. + // This function assumes that the first string will not contain two + // consecutive '*' + if (*first == '*' && *(first+1) != '\0' && *second == '\0') + return false; + + // If the current characters of both strings match + if (*first == *second) + return matchStrings(first+1, second+1); + + // If there is *, then there are two possibilities + // a) We consider current character of second string + // b) We ignore current character of second string. + if (*first == '*') + return matchStrings(first+1, second) || matchStrings(first, second+1); + return false; + } +} + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Search for logical volumes in the G4 volume store + //--------------------------------------------------------------------------- + std::set<std::string> findLogicalVolumes(const std::string& pattern) + { + // Use a set because there can be multiple occurences with same name + std::set<std::string> foundVolumes; + + // Iterate over the G4 volumes and look for matches + auto logicalVolumeStore = G4LogicalVolumeStore::GetInstance(); + for(auto logvol : *logicalVolumeStore) { + if( matchStrings( pattern.data(), logvol->GetName() ) ) { + foundVolumes.insert( logvol->GetName() ); + } + } + + return foundVolumes; + } + + //--------------------------------------------------------------------------- + // Search for multiple logical volumes in the G4 volume store + //--------------------------------------------------------------------------- + std::vector<std::string> + findLogicalVolumes(const std::vector<std::string>& patterns, + MsgStream& msg) + { + std::set<std::string> parsedVolumes; + for(const auto& pattern : patterns) { + const auto patternVols = findLogicalVolumes(pattern); + if(patternVols.empty()) { + msg << MSG::WARNING << "No volume found matching pattern: " + << pattern << endreq; + } + parsedVolumes.insert( patternVols.begin(), patternVols.end() ); + } + return std::vector<std::string>( parsedVolumes.begin(), parsedVolumes.end() ); + } + +} diff --git a/LArCalorimeter/LArG4/LArG4EC/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4EC/CMakeLists.txt index 793305cdb2a4..31507d19fb51 100644 --- a/LArCalorimeter/LArG4/LArG4EC/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4EC/CMakeLists.txt @@ -6,18 +6,18 @@ atlas_subdir( LArG4EC ) # Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC +atlas_depends_on_subdirs( PRIVATE Calorimeter/CaloG4Sim DetectorDescription/GeoModel/GeoSpecialShapes LArCalorimeter/LArG4/LArG4Code LArCalorimeter/LArGeoModel/LArGeoCode - PRIVATE + Control/AthenaBaseComps Control/StoreGate Database/AthenaPOOL/RDBAccessSvc DetectorDescription/GeoModel/GeoModelInterfaces DetectorDescription/GeoModel/GeoModelUtilities GaudiKernel - LArCalorimeter/LArG4/LArG4RunControl + AthenaKernel LArCalorimeter/LArGeoModel/LArHV Tools/PathResolver ) @@ -29,12 +29,14 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_library( LArG4EC +atlas_add_component( LArG4EC src/*.cc + src/components/*.cxx PUBLIC_HEADERS LArG4EC INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} GeoSpecialShapes LArG4Code LArGeoCode CaloG4SimLib StoreGateLib SGtests + LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} AthenaBaseComps GeoSpecialShapes LArG4Code LArGeoCode CaloG4SimLib StoreGateLib SGtests PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${CLHEP_LIBRARIES} GeoModelUtilities GaudiKernel LArG4RunControl LArHV PathResolver ) +atlas_install_python_modules( python/*.py ) diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/EnergyCalculator.h b/LArCalorimeter/LArG4/LArG4EC/LArG4EC/EnergyCalculator.h deleted file mode 100644 index 164f573eae6a..000000000000 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/EnergyCalculator.h +++ /dev/null @@ -1,364 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// EnergyCalculator.h -// Prepared 10-Apr-2002 Bill Seligman -// from code written by Jozsef Toth. -// 07-May-2003 AMS: now EnergyCalculator is not a singleton -// 02-July-2003 J.T. Charge collection added -// 20-July-2004 J.T. FieldMapVersion variable is added -// 25-May-2005 J.T. -calling sequence of GapAdj changed -// -new variables and function for reading and handling -// values of HV of power supplies -// - IonReco :for suppress signal because of ion recombination -// - DriftVelo: Walkowiak's formula for drift velocity -// Sept-2006 J.T. - collect signal from the Barrette volume -// Nov -2006 J.T. - fieldmap array structures changed, -// - lengths defined dinamically -// - field map for first/last fold and for Barrett volume are included -// May 2009 AMS move to namespace LArG4::EC -// duplicated data members removed - -#ifndef LArG4_EC_EnergyCalculator_H -#define LArG4_EC_EnergyCalculator_H - -#include <string> -#include <stdexcept> - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" - -#include "GeoSpecialShapes/LArWheelCalculator.h" - -#include "G4ThreeVector.hh" -#include "globals.hh" - - -class LArG4BirksLaw; -class MsgStream; - - -namespace LArG4 { - class VCalibrationCalculator; - -namespace EC { - - -class EnergyCalculator : public LArVCalculator -{ - public: -///////////////////////////////////////////// -// The interface for LArVCalculator. - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step*, std::vector<LArHitData>&); - - virtual G4bool FindIdentifier(const G4Step *, std::vector<LArHitData>&, - G4ThreeVector &, G4ThreeVector &); - - virtual const LArG4Identifier& identifier(int i = 0) const { - if(i != 0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i = 0) const { - if(i != 0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i = 0) const { - if(i != 0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - } - virtual G4bool isInTime(int i = 0) const { - if(i != 0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime(int i = 0) const { - if(i != 0) throw std::range_error("Multiple hits not yet implemented"); - return(!m_isInTime); - } - - private: - - // The results of the Process calculation: - //LArG4Identifier m_identifier; - //G4double m_time; - //G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4bool m_isInTime; - G4int m_compartment; - - G4float m_OOTcut; - - public: - typedef enum { - EMEC_ECOR_ROPT, - EMEC_ECOR_OFF, - EMEC_ECOR_GADJ, - EMEC_ECOR_CHCL, - EMEC_ECOR_GADJ_OLD, - EMEC_ECOR_GADJ_E, - EMEC_ECOR_GADJ_S, - EMEC_ECOR_GADJ_SE, - EMEC_ECOR_CHCL1 - } EnergyCorrection_t; - - EnergyCalculator( - LArWheelCalculator::LArWheelCalculator_t, - EnergyCorrection_t corr = EMEC_ECOR_ROPT, - G4int zside = 1); - - virtual ~EnergyCalculator(); - - private: - - G4bool (EnergyCalculator::*Process_type) (const G4Step*, std::vector<LArHitData>&); - G4bool (EnergyCalculator::*FindIdentifier_type) ( - const G4Step *, - std::vector<LArHitData>&, - G4ThreeVector &, - G4ThreeVector &); - G4double (EnergyCalculator::*GetHV_Value_type) (const G4ThreeVector &p) const; - G4double (EnergyCalculator::*GetGapSize_type) (const G4ThreeVector &p) const; - G4double (EnergyCalculator::*distance_to_the_nearest_electrode_type) (const G4ThreeVector &p) const; - - G4bool Process_Default(const G4Step*, std::vector<LArHitData>&); - G4bool Process_Barrett(const G4Step*, std::vector<LArHitData>&); - G4bool FindIdentifier_Default(const G4Step *, std::vector<LArHitData>&, G4ThreeVector &, G4ThreeVector &); - G4bool FindIdentifier_Barrett(const G4Step *, std::vector<LArHitData>&, G4ThreeVector &, G4ThreeVector &); - G4bool FindDMIdentifier_Barrett(const G4Step* step, std::vector<LArHitData>&); - G4bool GetCompartment_Barrett(G4ThreeVector,G4double,G4double,G4double, - G4int &, G4int &) const; - G4double GetHV_Value_Default(const G4ThreeVector& p) const { return GetHV_Value(p);} - G4double GetHV_Value_Barrett(const G4ThreeVector& p) const; - G4double GetGapSize_Default(const G4ThreeVector &p) const { return GetGapSize(p);} // need to make const - G4double GetGapSize_Barrett(const G4ThreeVector &p) const; // need to make const - G4int GetPhiGap_Barrett(const G4ThreeVector &p) const; - G4double distance_to_the_nearest_electrode_Default(const G4ThreeVector &p) const - { return distance_to_the_nearest_electrode(p); } - G4double distance_to_the_nearest_electrode_Barrett(const G4ThreeVector &p) const; - - static VCalibrationCalculator* m_supportCalculator; - - static void SetConst_OuterBarrett(void); - static void SetConst_InnerBarrett(void); - G4bool GetVolumeIndex(const G4Step *) const; - static G4bool SetConstOuterBarrett; - static G4bool SetConstInnerBarrett; - static const G4double LongBarThickness;// = 20. *mm; - static const G4double ColdCorrection;// =1.0036256; - static const G4double StripWidth;// =3.*mm/ColdCorrection; - static const G4double KapGap;// =1.*mm/ColdCorrection; - static const G4double EdgeWidth;// =1.*mm; - static const G4double DistOfEndofCuFromBack;// =22.77*mm/ColdCorrection; - static const G4double DistOfStartofCuFromBack;//=31.*mm; // frontface of the barrette - static const G4double ZmaxOfSignal;// DistOfStartofCuFromBack - DistOfEndofCuFromBack + EdgeWidth; - static G4double RefzDist; // = dElecFocaltoWRP+dWRPtoFrontFace+WheelThickness+ // used as const after initialization - // +dWRPtoFrontFace+ LongBarThickness - // -DistOfEndofCuFromBack - static const G4double S3_Etalim[21]; - static const G4double Rmeas_outer[50]; - static const G4double Zmeas_outer[2]; - static G4double S3_Rlim[21]; - static G4double rlim[50]; - static G4double zlim[4]; - static G4int ModuleNumber,PhiDivNumber; - static G4double PhiStartOfPhiDiv; - -// ************************************************************************** - - EnergyCorrection_t m_correction_type; - - G4double (EnergyCalculator::*ecorr_method) (G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const - G4double dummy_correction_method(G4double e, const G4ThreeVector&, const G4ThreeVector&) // need to make const - { return e; } - G4double GapAdjustment_old(G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const - G4double GapAdjustment (G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const - G4double GapAdjustment_E (G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const - G4double GapAdjustment_s (G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const - G4double GapAdjustment__sE (G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const - G4double CalculateChargeCollection(G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const !!! - G4double CalculateChargeCollection1(G4double, const G4ThreeVector&, const G4ThreeVector&); // need to make const !!! - - G4double m_GApower; - -// ************************************************************************** -//Declaration of variables,functions for charge collection -//J.T -// ************************************************************************** - - -//variables specific for wheel geometry - G4int PhiGapNumber, PhiHalfGapNumber; - G4double WaveLength, FanEleThicknessOld,FanEleFoldRadiusOld; - G4int HalfWaveNumber, SignofZinHalfWave, SignofSlopeofHalfWave; - G4double SinPhiGap, CosPhiGap, ZinHalfWave; - G4double FanAbsThickness, FanEleThickness, HalfEleThickness; - G4double ElectrodeFanHalfThickness; - -//variables specific for Efield calculation - - static G4bool FieldMapsRead; - static G4String FieldMapVersion; - - static const G4double GridSize; - static const G4double AverageGap; - - struct Fold_Efield_Map{ - G4bool FieldMapPrepared; - G4double* FieldMap; // [NumberOfRadialLayers][ZYWeight][MaxNofPoints]; - G4double* MinZofLayer; //these are limits of the - G4double* MaxZofLayer; //area where the FieldMap can - G4double* MinYofLayer; //be used for interpolation - G4double* MaxYofLayer; - G4int* NofColofLayer; // a column is parallel to y - G4int* NofRowofLayer; // a row is parallel to z - G4int* NofPointsinLayer; - G4int* pLayer;}; - - struct Wheel_Efield_Map {G4bool FieldMapPrepared; - G4int NumberOfRadialLayer; - G4double* RadiusOfLayers; - G4double* FoldinAngleOfLayers; - G4double* HalfLArGapSizeOfLayers; - Fold_Efield_Map* Fold; - Fold_Efield_Map Fold0; - Fold_Efield_Map Fold1; - G4double GridShift;}; - - static Wheel_Efield_Map ChCollInner,ChCollOuter; - Wheel_Efield_Map* ChCollWheelType; - Fold_Efield_Map* ChCollFoldType; - G4int PointFoldMapArea; - - void CreateArrays(Wheel_Efield_Map &, G4int); - inline G4int Index(Fold_Efield_Map* foldmap, G4int i, G4int j, G4int k ) const - {return foldmap->pLayer[i]+j*foldmap->NofPointsinLayer[i]+k;}; - void SetFoldArea(G4double); - - G4double Ylimits[4]; - -//HV for current calculation - - static G4bool HVMapRead; - static G4String HVMapVersion; - static const G4double AverageHV; - static const G4double AverageEfield; - static const G4double AverageCurrent; - static const G4String HVEMECMapFileName; //{"HVEMECMap.dat"}; - - static const G4int NofAtlasSide = 2; - static const G4int NofEtaSection = 9; - static const G4int NofElectrodeSide = 2; - static const G4int NofElectrodesOut = 768; - static const G4double HV_Etalim[NofEtaSection+1]; // = {1.375,1.5,1.6,1.8,2.,2.1,2.3,2.5,2.8,3.2}; - static G4int HV_Start_phi[NofAtlasSide][NofEtaSection][NofElectrodeSide]; - static G4double HV_Values[NofAtlasSide][NofEtaSection][NofElectrodeSide][NofElectrodesOut]; - - static const G4double LArTemperature_ECC0;//={88.15}; //K - static const G4double LArTemperature_ECC1;//={88.37}; - static const G4double LArTemperature_ECC5;//={87.97}; - static const G4double LArTemperature_av ;// ={88.16}; - - G4int NofPhiSections; - G4int NumberOfElectrodesInPhiSection; - - void GetHVMap(const G4String); - G4double GetHV_Value(const G4ThreeVector& p) const; - G4double GetHV_Value_ChColl_Wheel( const G4ThreeVector& , G4int , G4int) const; - -//Efield in [kv/cm], driftvelo in [mm/microsec], Temperature in [K] - - inline static G4double IonReco(G4double Efield) { - if(Efield<=0.000001){return 0.;} - if(Efield>2.) {return (1./(1. +0.36/Efield));} - return (1./(1.04+0.28/Efield)); - } - - inline static G4double DriftVelo(G4double T, G4double Efield) { - if( Efield <= 0.000001) {return 0.;} - return ( (-0.01481*(T-90.371)+1.)* - ( 0.141*Efield*log(1.+12.4/Efield)+ - 1.627*pow(Efield,0.317) ) - -0.0075*(T-90.371) - ); - } - -// variables for phigap number comparison - - G4int calculatorPhiGap,chcollPhiGap; - -// functions specific for geometry - - void SetHalfWave(G4double); - void GetPhiGap(G4double *); // need to make const - void SetYlimitsofPhigapinWheel(G4double,G4double); - G4double YofSurface(G4double,G4double,G4double) const; - inline G4double YofNeutralFibre(G4double alpha,G4double rho) const{ - return YofSurface(alpha,rho,0.); - } - G4double FoldingAngle(G4double) const; - G4double HalfLArGapSize(G4double, G4double) const; - - // functions specific for charge coll. - - void IniGeomforFieldMaps(void); - void GetFieldMaps(const G4String); - void PrepareFieldMap(void); - G4double GetCurrent(G4double *,G4double *,G4double); - void TransformWheeltoFieldMap(G4double *,G4double *); - void SetYlimitsofPhigapinFieldMap(G4int); - void TransFromBarrtoWheel(G4double*, G4double*); - G4double GetWeightfromFieldMap(G4int,G4double,G4double); - G4double HalfLArGapSizeOld(G4double) const; - - static G4double CHC_Esr; - static const G4int CHCMaxPrint=00; - static G4int CHCIprint; - static G4double CHCEbad; - static G4double CHCEtotal; - static G4double CHCStotal; - - private: -// inline void vector_to_msg(G4ThreeVector &v) const; - - /* to be developed... - std::pair<double, double>DxToFans(Hep3Vector &p); - double XDistanceToTheNeutralFibre(const Hep3Vector& P) const; - */ - G4double GetGapSize(const G4ThreeVector &p) const; // need to make const - - // public: - G4double distance_to_the_nearest_electrode(const G4ThreeVector &p) const; - - LArG4BirksLaw *birksLaw; - LArWheelCalculator *m_lwc; - const LArWheelCalculator * lwc() const { return m_lwc; } - - MsgStream *m_msg; - - void get_HV_map_from_DB(void); - G4bool m_DB_HV; - -// Aug 2007 AMS, lost Aug 2008, restored May 2009 - LArWheelCalculator *m_electrode_calculator; - const LArWheelCalculator * elc() const { return m_electrode_calculator; } - - G4double GetCurrent1(const G4ThreeVector &, const G4ThreeVector &, G4double); // need to make const - G4double get_HV_value(const G4ThreeVector&, const std::pair<G4int, G4int> &) const; - - EnergyCalculator (const EnergyCalculator&); - EnergyCalculator& operator= (const EnergyCalculator&); -}; - -} // namespace EC -} // namespace LArG4 - -#endif // LArG4_EC_EnergyCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/IECPresamplerGeometry.h b/LArCalorimeter/LArG4/LArG4EC/LArG4EC/IECPresamplerGeometry.h new file mode 100644 index 000000000000..586ef532327f --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/LArG4EC/IECPresamplerGeometry.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// IGeometryCalculator.h +// Common interface for Geometry Calculator classes + +#ifndef __LARG4EC_IECPRESAMPLERGEOMETRY_H__ +#define __LARG4EC_IECPRESAMPLERGEOMETRY_H__ + +#include "GaudiKernel/IService.h" + +//#include "globals.hh" + +class LArG4Identifier; +class G4Step; + +namespace LArG4 +{ + + class IECPresamplerGeometry : virtual public IService + { + public: + IECPresamplerGeometry() {} + virtual ~IECPresamplerGeometry() {} + + static const InterfaceID& interfaceID() { + static const InterfaceID IID_IECPresamplerGeometry("IECPresamplerGeometry",1,0); + return IID_IECPresamplerGeometry; + } + + // Full identifier computation from a G4 step + virtual LArG4Identifier CalculateIdentifier( const G4Step*) const = 0; + }; +} +#endif //__LARG4EC_IECPRESAMPLERGEOMETRY_H__ diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/LArEndcapPresamplerCalculator.h b/LArCalorimeter/LArG4/LArG4EC/LArG4EC/LArEndcapPresamplerCalculator.h deleted file mode 100644 index e74ed01ee4f5..000000000000 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/LArEndcapPresamplerCalculator.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArEndcapPresamplerCalculator.hh -// Prepared 27-Dec-2002 Bill Seligman - -// This is a separate "calculator" class for the endcap presampler. -// For more information about what a "calculator" class does, see the -// documentation: LArG4/doc/LArG4.ps. - -#ifndef __LArEndcapPresamplerCalculator_H__ -#define __LArEndcapPresamplerCalculator_H__ - -#include "globals.hh" -#include "G4ThreeVector.hh" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include <stdexcept> -// Forward declarations. -class G4Step; -class LArG4BirksLaw; - -namespace LArG4 { - namespace EC { - class PresamplerGeometry; - } -} - -class LArEndcapPresamplerCalculator : public LArVCalculator { -public: - - // Accessor for pointer to the singleton. - static LArEndcapPresamplerCalculator* GetCalculator(); - - ~LArEndcapPresamplerCalculator(); - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double o){ m_OOTcut = o; } - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - - virtual G4bool Process(const G4Step*, std::vector<LArHitData>&); - - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - }; - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - -protected: - // The constructor is protected according to the singleton design - // pattern. - LArEndcapPresamplerCalculator(); - -private: - - // Pointer to geometry routine. - const LArG4::EC::PresamplerGeometry* m_geometry; - - // Store the out-of-time cut from the description: - G4float m_OOTcut; - - LArG4BirksLaw *birksLaw; - - // The results of the Process calculation: - //LArG4Identifier m_identifier; - //G4double m_time; - //G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4bool m_isInTime; - - LArEndcapPresamplerCalculator (const LArEndcapPresamplerCalculator&); - LArEndcapPresamplerCalculator& operator= (const LArEndcapPresamplerCalculator&); -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerGeometry.h b/LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerGeometry.h index e6a89954632b..f61e57cc5e75 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerGeometry.h +++ b/LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerGeometry.h @@ -17,9 +17,8 @@ #ifndef LArG4_EC_PresamplerGeometry_H #define LArG4_EC_PresamplerGeometry_H - -#include "G4ThreeVector.hh" -#include "globals.hh" +#include "LArG4EC/IECPresamplerGeometry.h" +#include "AthenaBaseComps/AthService.h" // Forward declarations. class LArG4Identifier; @@ -33,38 +32,37 @@ namespace LArG4 { namespace EC { - class PresamplerGeometry { + class PresamplerGeometry: public AthService, virtual public IECPresamplerGeometry { public: - // Standard implementation of a singleton pattern. - static const PresamplerGeometry* GetInstance(); + // Constructor + PresamplerGeometry(const std::string& name, ISvcLocator * pSvcLocator); + StatusCode initialize() override final; virtual ~PresamplerGeometry(); + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; + // 15-Jan-2002 WGS: A "lookup" function for detector measurements, // sizes, and other values. enum kValue { - rMinEndcapPresampler, - rMaxEndcapPresampler, - zEndcapPresamplerFrontFace, - zEndcapPresamplerBackFace, - EndcapPresamplerHalfThickness, - EndcapPresamplerZpositionInMother + rMinEndcapPresampler, + rMaxEndcapPresampler, + zEndcapPresamplerFrontFace, + zEndcapPresamplerBackFace, + EndcapPresamplerHalfThickness, + EndcapPresamplerZpositionInMother }; - G4double GetValue(const kValue) const; - // This is the "meat" of this class: calculate the identifier // given a G4Step. - LArG4Identifier CalculateIdentifier( const G4Step* ) const; - - protected: - // Constructor is protected according to the singleton pattern. - PresamplerGeometry(); + LArG4Identifier CalculateIdentifier( const G4Step* ) const override final; private: + double GetValue(const kValue) const; struct Clockwork; - Clockwork *c; + Clockwork *m_c; //FIXME is it really worth creating this struct on the heap? PresamplerGeometry (const PresamplerGeometry&); PresamplerGeometry& operator= (const PresamplerGeometry&); diff --git a/LArCalorimeter/LArG4/LArG4EC/cmt/requirements b/LArCalorimeter/LArG4/LArG4EC/cmt/requirements index 0f00097eb11d..c0475524be58 100755 --- a/LArCalorimeter/LArG4/LArG4EC/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4EC/cmt/requirements @@ -8,25 +8,27 @@ author Mikhail Leltchouk <lelchuk@nevis.columbia.edu> # liquid-argon endcap cryostat, pre-sampler, and calorimeter. use AtlasPolicy AtlasPolicy-* -use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use LArGeoCode LArGeoCode-* LArCalorimeter/LArGeoModel -use GeoSpecialShapes GeoSpecialShapes-* DetectorDescription/GeoModel - -use CaloG4Sim CaloG4Sim-* Calorimeter -use Geant4 Geant4-* External +use AthenaBaseComps AthenaBaseComps-* Control # Build the library (and export the headers) -library LArG4EC *.cc -apply_pattern installed_library +library LArG4EC *.cc -s=components *.cxx +apply_pattern component_library +apply_pattern declare_python_modules files="*.py" #======================================================= private -use AtlasCLHEP AtlasCLHEP-* External +use AthenaKernel AthenaKernel-* Control use GaudiInterface GaudiInterface-* External +use Geant4 Geant4-* External use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel use GeoModelUtilities GeoModelUtilities-* DetectorDescription/GeoModel use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL use PathResolver PathResolver-* Tools use StoreGate StoreGate-* Control -use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 +use AtlasCLHEP AtlasCLHEP-* External +#use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 use LArHV LArHV-* LArCalorimeter/LArGeoModel +use LArG4Code LArG4Code-* LArCalorimeter/LArG4 +use LArGeoCode LArGeoCode-* LArCalorimeter/LArGeoModel +use GeoSpecialShapes GeoSpecialShapes-* DetectorDescription/GeoModel +use CaloG4Sim CaloG4Sim-* Calorimeter diff --git a/LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfig.py b/LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfig.py new file mode 100644 index 000000000000..6629ae406042 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfig.py @@ -0,0 +1,112 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr +from LArG4EC import LArWheelCalculatorEnum +def getCalibrationCalculator(name="CalibrationCalculator", **kwargs): + return CfgMgr.LArG4__EC__CalibrationCalculator(name, **kwargs) + +def getEMECPosInnerWheelCalibrationCalculator(name="EMECPosInnerWheelCalibrationCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.InnerAbsorberWheel) + kwargs.setdefault("zSide", 1) + kwargs.setdefault("GeometryCalculator","EMECPosInnerWheelCorrOffCalculator") + return getCalibrationCalculator(name, **kwargs) + +def getEMECNegInnerWheelCalibrationCalculator(name="EMECNegInnerWheelCalibrationCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.InnerAbsorberWheel) + kwargs.setdefault("zSide", -1) + kwargs.setdefault("GeometryCalculator","EMECNegInnerWheelCorrOffCalculator") + return getCalibrationCalculator(name, **kwargs) + +def getEMECPosOuterWheelCalibrationCalculator(name="EMECPosOuterWheelCalibrationCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.OuterAbsorberWheel) + kwargs.setdefault("zSide", 1) + kwargs.setdefault("GeometryCalculator","EMECPosOuterWheelCorrOffCalculator") + return getCalibrationCalculator(name, **kwargs) + +def getEMECNegOuterWheelCalibrationCalculator(name="EMECNegOuterWheelCalibrationCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.OuterAbsorberWheel) + kwargs.setdefault("zSide", -1) + kwargs.setdefault("GeometryCalculator","EMECNegOuterWheelCorrOffCalculator") + return getCalibrationCalculator(name, **kwargs) + +def getEMECBackOuterBarretteCalibrationCalculator(name="EMECBackOuterBarretteCalibrationCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.BackOuterBarretteWheelCalib) + kwargs.setdefault("zSide", 1) + kwargs.setdefault("GeometryCalculator","EMECBackOuterBarretteCorrOffCalculator") + return getCalibrationCalculator(name, **kwargs) + +def getEMECPresamplerCalibrationCalculator(name="EMECPresamplerCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__EC__PresamplerCalibrationCalculator(name, **kwargs) + +def getEndcapCryostatCalibrationCalculator(name="EndcapCryostatCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__EndcapCryostat__CalibrationCalculator(name, **kwargs) + +def getEndcapCryostatCalibrationLArCalculator(name="EndcapCryostatCalibrationLArCalculator", **kwargs): + return CfgMgr.LArG4__EndcapCryostat__CalibrationLArCalculator(name, **kwargs) + +def getEndcapCryostatCalibrationMixedCalculator(name="EndcapCryostatCalibrationMixedCalculator", **kwargs): + return CfgMgr.LArG4__EndcapCryostat__CalibrationMixedCalculator(name, **kwargs) + +def getEMECSupportCalibrationCalculator(name="EMECSupportCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__EMECSupportCalibrationCalculator(name, **kwargs) + +def getEnergyCalculator(name="EnergyCalculator", **kwargs): + from AthenaCommon.SystemOfUnits import ns + kwargs.setdefault("OOTcut", 300.0*ns) + return CfgMgr.LArG4__EC__EnergyCalculator(name, **kwargs) + +def getEMECPosInnerWheelCalculator(name="EMECPosInnerWheelCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.InnerAbsorberWheel) + #kwargs.setdefault("EnergyCorrection", 8) #LArG4::EMEC_ECOR_CHCL1 + kwargs.setdefault("zSide", 1) + return getEnergyCalculator(name, **kwargs) + +def getEMECNegInnerWheelCalculator(name="EMECNegInnerWheelCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.InnerAbsorberWheel) + #kwargs.setdefault("EnergyCorrection", 8) #LArG4::EMEC_ECOR_CHCL1 + kwargs.setdefault("zSide", -1) + return getEnergyCalculator(name, **kwargs) + +def getEMECPosOuterWheelCalculator(name="EMECPosOuterWheelCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.OuterAbsorberWheel) + #kwargs.setdefault("EnergyCorrection", 8) #LArG4::EMEC_ECOR_CHCL1 + kwargs.setdefault("zSide", 1) + return getEnergyCalculator(name, **kwargs) + +def getEMECNegOuterWheelCalculator(name="EMECNegOuterWheelCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.OuterAbsorberWheel) + #kwargs.setdefault("EnergyCorrection", 8) #LArG4::EMEC_ECOR_CHCL1 + kwargs.setdefault("zSide", -1) + return getEnergyCalculator(name, **kwargs) + +def getEMECBackOuterBarretteCalculator(name="EMECBackOuterBarretteCalculator", **kwargs): + kwargs.setdefault("WheelType", LArWheelCalculatorEnum.BackOuterBarretteWheelCalib) + #kwargs.setdefault("EnergyCorrection", 8) #LArG4::EMEC_ECOR_CHCL1 + return getEnergyCalculator(name, **kwargs) + +def getEMECPosInnerWheelCorrOffCalculator(name="EMECPosInnerWheelCorrOffCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 1) #LArG4::EMEC_ECOR_OFF + return getEMECPosInnerWheelCalculator(name, **kwargs) + +def getEMECNegInnerWheelCorrOffCalculator(name="EMECNegInnerWheelCorrOffCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 1) #LArG4::EMEC_ECOR_OFF + return getEMECNegInnerWheelCalculator(name, **kwargs) + +def getEMECPosOuterWheelCorrOffCalculator(name="EMECPosOuterWheelCorrOffCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 1) #LArG4::EMEC_ECOR_OFF + return getEMECPosOuterWheelCalculator(name, **kwargs) + +def getEMECNegOuterWheelCorrOffCalculator(name="EMECNegOuterWheelCorrOffCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 1) #LArG4::EMEC_ECOR_OFF + return getEMECNegOuterWheelCalculator(name, **kwargs) + +def getEMECBackOuterBarretteCorrOffCalculator(name="EMECBackOuterBarretteCorrOffCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 1) #LArG4::EMEC_ECOR_OFF + return getEMECBackOuterBarretteCalculator(name, **kwargs) + +def getEMECPresamplerCalculator(name="EMECPresamplerCalculator", **kwargs): + return CfgMgr.LArEndcapPresamplerCalculator(name, **kwargs) + +def getEMECPresamplerGeometry(name="EMECPresamplerGeometry", **kwargs): + return CfgMgr.LArG4__EC__PresamplerGeometry(name, **kwargs) + diff --git a/LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfigDb.py b/LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfigDb.py new file mode 100644 index 000000000000..8c1a4e92d866 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/python/LArG4ECConfigDb.py @@ -0,0 +1,28 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addService + +addService("LArG4EC.LArG4ECConfig.getEMECPosInnerWheelCalibrationCalculator","EMECPosInnerWheelCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECNegInnerWheelCalibrationCalculator","EMECNegInnerWheelCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECPosOuterWheelCalibrationCalculator","EMECPosOuterWheelCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECNegOuterWheelCalibrationCalculator","EMECNegOuterWheelCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECBackOuterBarretteCalibrationCalculator","EMECBackOuterBarretteCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECPresamplerCalibrationCalculator","EMECPresamplerCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEndcapCryostatCalibrationCalculator","EndcapCryostatCalibrationCalculator") +addService("LArG4EC.LArG4ECConfig.getEndcapCryostatCalibrationLArCalculator","EndcapCryostatCalibrationLArCalculator") +addService("LArG4EC.LArG4ECConfig.getEndcapCryostatCalibrationMixedCalculator","EndcapCryostatCalibrationMixedCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECSupportCalibrationCalculator","EMECSupportCalibrationCalculator") + +addService("LArG4EC.LArG4ECConfig.getEMECPosInnerWheelCalculator","EMECPosInnerWheelCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECNegInnerWheelCalculator","EMECNegInnerWheelCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECPosOuterWheelCalculator","EMECPosOuterWheelCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECNegOuterWheelCalculator","EMECNegOuterWheelCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECBackOuterBarretteCalculator","EMECBackOuterBarretteCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECPosInnerWheelCorrOffCalculator","EMECPosInnerWheelCorrOffCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECNegInnerWheelCorrOffCalculator","EMECNegInnerWheelCorrOffCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECPosOuterWheelCorrOffCalculator","EMECPosOuterWheelCorrOffCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECNegOuterWheelCorrOffCalculator","EMECNegOuterWheelCorrOffCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECBackOuterBarretteCorrOffCalculator","EMECBackOuterBarretteCorrOffCalculator") +addService("LArG4EC.LArG4ECConfig.getEMECPresamplerCalculator","EMECPresamplerCalculator") + +addService("LArG4EC.LArG4ECConfig.getEMECPresamplerGeometry","EMECPresamplerGeometry") diff --git a/LArCalorimeter/LArG4/LArG4EC/python/LArWheelCalculatorEnum.py b/LArCalorimeter/LArG4/LArG4EC/python/LArWheelCalculatorEnum.py new file mode 100644 index 000000000000..b938beb82949 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/python/LArWheelCalculatorEnum.py @@ -0,0 +1,24 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# based on LArWheelCalculator_t enum defined in "GeoSpecialShapes/LArWheelCalculatorEnums.h +InnerAbsorberWheel=0 +OuterAbsorberWheel=1 +InnerElectrodWheel=2 +OuterElectrodWheel=3 +InnerAbsorberModule=4 +OuterAbsorberModule=5 +InnerElectrodModule=6 +OuterElectrodModule=7 +BackInnerBarretteWheel=8 +BackOuterBarretteWheel=9 +BackInnerBarretteWheelCalib=10 +BackOuterBarretteWheelCalib=11 +BackInnerBarretteModule=12 +BackOuterBarretteModule=13 +BackInnerBarretteModuleCalib=14 +BackOuterBarretteModuleCalib=15 +InnerGlueWheel=16 +OuterGlueWheel=17 +InnerLeadWheel=18 +OuterLeadWheel=19 + diff --git a/LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.cc index d7abbe9ac883..28628cee182f 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.cc @@ -6,10 +6,10 @@ #undef DEBUG_HITS -#include "LArG4EC/CalibrationCalculator.h" -#include "LArG4EC/EnergyCalculator.h" +#include "CalibrationCalculator.h" #include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/ILArCalculatorSvc.h" #include "G4Step.hh" #include "globals.hh" @@ -18,69 +18,120 @@ namespace LArG4 { namespace EC { - CalibrationCalculator::CalibrationCalculator(LArWheelCalculator::LArWheelCalculator_t t, int zside) + //CalibrationCalculator::CalibrationCalculator(LArG4::LArWheelCalculator_t t, int zside) + CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_wcalc_tProp(0) + , m_wcalc_t(LArG4::InnerAbsorberWheel) + , m_geometryCalculator("",name) { - // Make sure there are no uninitialized variables. - m_geometryCalculator = new EnergyCalculator(t, EnergyCalculator::EMEC_ECOR_OFF, zside); + declareProperty("WheelType", m_wcalc_tProp); + m_wcalc_tProp.declareUpdateHandler(&CalibrationCalculator::WheelTypeHandler, this); + declareProperty("zSide", m_zside=0); + declareProperty("GeometryCalculator",m_geometryCalculator); + } + + void CalibrationCalculator::WheelTypeHandler(Property&) + { + switch(m_wcalc_tProp.value()) + { + case 0: m_wcalc_t = LArG4::InnerAbsorberWheel; break; + case 1: m_wcalc_t = LArG4::OuterAbsorberWheel; break; + case 2: m_wcalc_t = LArG4::InnerElectrodWheel; break; + case 3: m_wcalc_t = LArG4::OuterElectrodWheel; break; + case 4: m_wcalc_t = LArG4::InnerAbsorberModule; break; + case 5: m_wcalc_t = LArG4::OuterAbsorberModule; break; + case 6: m_wcalc_t = LArG4::InnerElectrodModule; break; + case 7: m_wcalc_t = LArG4::OuterElectrodModule; break; + case 8: m_wcalc_t = LArG4::BackInnerBarretteWheel; break; + case 9: m_wcalc_t = LArG4::BackOuterBarretteWheel; break; + case 10: m_wcalc_t = LArG4::BackInnerBarretteWheelCalib; break; + case 11: m_wcalc_t = LArG4::BackOuterBarretteWheelCalib; break; + case 12: m_wcalc_t = LArG4::BackInnerBarretteModule; break; + case 13: m_wcalc_t = LArG4::BackOuterBarretteModule; break; + case 14: m_wcalc_t = LArG4::BackInnerBarretteModuleCalib; break; + case 15: m_wcalc_t = LArG4::BackOuterBarretteModuleCalib; break; + case 16: m_wcalc_t = LArG4::InnerGlueWheel; break; + case 17: m_wcalc_t = LArG4::OuterGlueWheel; break; + case 18: m_wcalc_t = LArG4::InnerLeadWheel; break; + case 19: m_wcalc_t = LArG4::OuterLeadWheel; break; + default: + { + std::ostringstream merr; + merr << + "CalibrationCalculator::WheelTypeHandler FATAL: invalid LArWheelCalculator_t specified " + << m_wcalc_tProp.value(); + std::cerr << merr.str() << std::endl; + throw GaudiException(merr.str(), "CalibrationCalculator::WheelTypeHandler", StatusCode::FAILURE); + } + } + } + + StatusCode CalibrationCalculator::initialize() { + ATH_CHECK(m_geometryCalculator.retrieve()); + + return StatusCode::SUCCESS; } CalibrationCalculator::~CalibrationCalculator() { // Clean up pointers. - delete m_geometryCalculator; + //delete m_geometryCalculator; } - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) + G4bool CalibrationCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const { // Use the calculators to determine the energies and the // identifier associated with this G4Step. Note that the // default is to process both the energy and the ID. - m_energies.clear(); + _energies.clear(); if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { + { #ifdef DEBUG_HITS - std::cout << "LArG4::EC::CalibrationCalculator::Process" - << " calling SimulationEnergies" - << " at m_energyCalculator=" - << m_energyCalculator - << std::endl; + std::cout << "LArG4::EC::CalibrationCalculator::Process" + << " calling SimulationEnergies" + << " at m_energyCalculator=" + << m_energyCalculator + << std::endl; #endif - m_energyCalculator.Energies( a_step, m_energies ); - } + m_energyCalculator.Energies( a_step, _energies ); + } else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) _energies.push_back( 0. ); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - (void)m_geometryCalculator->Process( a_step ); - m_identifier = m_geometryCalculator->identifier(); - } - else - m_identifier = LArG4Identifier(); + if ( a_process == kEnergyAndID || a_process == kOnlyID ) { + // Calculate the identifier. + //(void)m_geometryCalculator->Process( a_step ); + // _identifier = m_geometryCalculator->identifier(); + std::vector<LArHitData> hdata; + m_geometryCalculator->Process( a_step, hdata ); + _identifier = hdata[0].id; + } else + _identifier = LArG4Identifier(); #ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); + G4double energy = accumulate(_energies.begin(),_energies.end(),0.); std::cout << "LArG4::EC::CalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + << " ID=" << std::string(_identifier) + << " energy=" << energy + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")" + << std::endl; #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) { + if ( _identifier == LArG4Identifier() ) { std::cout << "return invalid from EmecCalibrationCalculator" << std::endl; - return false; + return false; } return true; diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.h similarity index 70% rename from LArCalorimeter/LArG4/LArG4EC/LArG4EC/CalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.h index 351e8a8c238b..ec7db1f2f3e2 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4EC/src/CalibrationCalculator.h @@ -19,7 +19,7 @@ #ifndef LArG4_EC_CalibrationCalculator_H #define LArG4_EC_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -32,6 +32,7 @@ // Forward declaractions: class G4Step; +class ILArCalculatorSvc; // Note the use of nested namespaces (mainly to prevent long names // like LArG4HECCalibrationCalculator). This class is contained in @@ -43,13 +44,16 @@ namespace LArG4 { // Forward declaration class Geometry; - class EnergyCalculator; - class CalibrationCalculator : public VCalibrationCalculator { + class CalibrationCalculator : public LArCalibCalculatorSvcImp { public: - CalibrationCalculator(LArWheelCalculator::LArWheelCalculator_t, int); + //CalibrationCalculator(LArWheelCalculator::LArWheelCalculator_t, int); + CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); virtual ~CalibrationCalculator(); + // Update handler + void WheelTypeHandler(Property&); + StatusCode initialize() override final; // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong @@ -62,22 +66,18 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; + + int m_zside; + UnsignedShortProperty m_wcalc_tProp; + LArG4::LArWheelCalculator_t m_wcalc_t; // Geometry calculator - EnergyCalculator* m_geometryCalculator; + ServiceHandle<ILArCalculatorSvc> m_geometryCalculator; // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; diff --git a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.cc index 9259dc85d4bf..5a527ef8d73f 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.cc @@ -4,30 +4,25 @@ // LArG4::EndcapCryostat::CalibrationCalculator // Prepared 13-Jan-2004 Bill Seligman -// 20-Jul-2004 M.Leltchouk - region and volume info definitions +// 20-Jul-2004 M.Leltchouk - region and volume info definitions // This class calculates the values needed for calibration hits in the // volumes: -// "LAr::Endcap::Cryostat::Cylinder" -// "LAr::Endcap::Cryostat::Cone" -// "LAr::Endcap::Cryostat::EmecHecLAr::Cylinder" -// "LAr::Endcap::Cryostat::EmecHecLAr::Sector" -// "LAr::Endcap::Cryostat::FcalLAr::Cylinder" -// "LAr::Endcap::Cryostat::FcalLAr::Sector" - -#define DEBUG_VOLUMES +// "LAr::Endcap::Cryostat::Cylinder" +// "LAr::Endcap::Cryostat::Cone" +// "LAr::Endcap::Cryostat::EmecHecLAr::Cylinder" +// "LAr::Endcap::Cryostat::EmecHecLAr::Sector" +// "LAr::Endcap::Cryostat::FcalLAr::Cylinder" +// "LAr::Endcap::Cryostat::FcalLAr::Sector" + +#undef DEBUG_VOLUMES #undef DEBUG_HITS #undef DEBUG_MAPS #undef DEBUG_DMXYZ -#ifdef DEBUG_DMXYZ -#include "LArG4Code/CalibrationDefaultCalculator.h" -#endif -#include "LArG4EC/CryostatCalibrationCalculator.h" -#include "LArG4EC/CryostatCalibrationLArCalculator.h" +#include "CryostatCalibrationCalculator.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" #include "G4Step.hh" #include "G4StepPoint.hh" @@ -42,8 +37,6 @@ namespace LArG4 { namespace EndcapCryostat { - VCalibrationCalculator* CalibrationCalculator::m_backupCalculator = 0; - /////////////////////////////////////////////////////////// // Tables /////////////////////////////////////////////////////////// @@ -109,211 +102,211 @@ namespace LArG4 { // ========== Sampling 1 ============= static const RegionInfo_t region016[] = - // inner warm and cold walls, cones - // region etamin etamax deta dphi + // inner warm and cold walls, cones + // region etamin etamax deta dphi { { 6, 1.3, 3.2, 0.1, M_PI/32. }, - { 7, 3.2, 5.0, 0.1, M_PI/32. } }; + { 7, 3.2, 5.0, 0.1, M_PI/32. } }; static const RegionInfo_t region017[] = - // inner warm and cold walls, cones - // region etamin etamax deta dphi - { { 7, 3.2, 5.0, 0.1, M_PI/32. } }; + // inner warm and cold walls, cones + // region etamin etamax deta dphi + { { 7, 3.2, 5.0, 0.1, M_PI/32. } }; // ========== Sampling 2 ============= static const RegionInfo_t region025[] = - // pieces at largest radius of inner warm and cold walls (info5) - // and CREK7 - front part of HEC supports (info7) - // region etamin etamax deta dphi + // pieces at largest radius of inner warm and cold walls (info5) + // and CREK7 - front part of HEC supports (info7) + // region etamin etamax deta dphi { { 5, 1.0, 1.7, 0.1, M_PI/32. } }; // ========== Sampling 3 ============= static const RegionInfo_t region030[] = - // warm and cold walls, shields behind HEC, FCAL (info, info8) - // region etamin etamax deta dphi + // warm and cold walls, shields behind HEC, FCAL (info, info8) + // region etamin etamax deta dphi { { 0, 1.7, 5.0, 0.1, M_PI/32. }, - { 1, 5.0, 8.0, 0.2, M_PI/32. } + { 1, 5.0, 8.0, 0.2, M_PI/32. } }; static const CopyNumberInfo_t info5[] = - // "LAr::Endcap::Cryostat::Cylinder" + // "LAr::Endcap::Cryostat::Cylinder" { - // ------------- region: inner warm and cold walls ------------ - // copy number range (low, high) - { 4, 6, - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region016)/sizeof(RegionInfo_t), - region016 } - }, - { 15, 15, - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region016)/sizeof(RegionInfo_t), - region016 } - }, - { 29, 29, - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region016)/sizeof(RegionInfo_t), - region016 } - }, - - // ------------- region: outer warm - cold piece ------------ - // copy number range (low, high) - { 11, 11, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region025)/sizeof(RegionInfo_t), - region025 } - }, + // ------------- region: inner warm and cold walls ------------ + // copy number range (low, high) + { 4, 6, + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region016)/sizeof(RegionInfo_t), + region016 } + }, + { 15, 15, + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region016)/sizeof(RegionInfo_t), + region016 } + }, + { 29, 29, + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region016)/sizeof(RegionInfo_t), + region016 } + }, + + // ------------- region: outer warm - cold piece ------------ + // copy number range (low, high) + { 11, 11, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region025)/sizeof(RegionInfo_t), + region025 } + }, // ----- region: warm and cold walls, shields behind HEC, FCAL - { 8, 8, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, - { 20, 21, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, - // ------------- region: warm and cold walls behind HEC, FCAL ---- - // copy number range (low, high) - { 25, 26, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, + { 8, 8, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, + { 20, 21, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, + // ------------- region: warm and cold walls behind HEC, FCAL ---- + // copy number range (low, high) + { 25, 26, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, }; static const CopyNumberInfo_t info6[] = - // "LAr::Endcap::Cryostat::Cone" + // "LAr::Endcap::Cryostat::Cone" { - // ------------- region: inner warm and cold walls ------------ - // copy number range (low, high) - { 1, 3, - // Det Sub Typ Sam - { 10, 4, 1, 1, - sizeof(region017)/sizeof(RegionInfo_t), - region017 } - }, + // ------------- region: inner warm and cold walls ------------ + // copy number range (low, high) + { 1, 3, + // Det Sub Typ Sam + { 10, 4, 1, 1, + sizeof(region017)/sizeof(RegionInfo_t), + region017 } + }, }; static const CopyNumberInfo_t info7[] = - // "LAr::Endcap::Cryostat::EmecHecLAr::Cylinder" + // "LAr::Endcap::Cryostat::EmecHecLAr::Cylinder" { - // ------------- region: warm and cold walls behind HEC, FCAL ---- - // copy number range (low, high) - { 17, 18, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, - { 22, 22, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, - { 23, 23, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region025)/sizeof(RegionInfo_t), - region025 } - }, - { 24, 24, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, - { 30, 30, - // Det Sub Typ Sam - { 10, 4, 1, 3, - sizeof(region030)/sizeof(RegionInfo_t), - region030 } - }, + // ------------- region: warm and cold walls behind HEC, FCAL ---- + // copy number range (low, high) + { 17, 18, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, + { 22, 22, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, + { 23, 23, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region025)/sizeof(RegionInfo_t), + region025 } + }, + { 24, 24, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, + { 30, 30, + // Det Sub Typ Sam + { 10, 4, 1, 3, + sizeof(region030)/sizeof(RegionInfo_t), + region030 } + }, }; static const CopyNumberInfo_t info8[] = - // "LAr::Endcap::Cryostat::EmecHecLAr::Sector" + // "LAr::Endcap::Cryostat::EmecHecLAr::Sector" { - // ------------- region: inner warm and cold walls ------------ - // copy number range (low, high) - { 7, 7, - // Det Sub Typ Sam - { 10, 4, 1, 2, - sizeof(region025)/sizeof(RegionInfo_t), - region025 } - }, + // ------------- region: inner warm and cold walls ------------ + // copy number range (low, high) + { 7, 7, + // Det Sub Typ Sam + { 10, 4, 1, 2, + sizeof(region025)/sizeof(RegionInfo_t), + region025 } + }, }; -// static const CopyNumberInfo_t info9[] = -// // "LAr::Endcap::Cryostat::FcalLAr::Cylinder" -// { -// // ------------- region: warm and cold walls behind HEC, FCAL ---- -// // copy number range (low, high) -// { 25, 26, -// // Det Sub Typ Sam -// { 10, 4, 1, 3, -// sizeof(region030)/sizeof(RegionInfo_t), -// region030 } -// }, -// }; -// -// static const CopyNumberInfo_t info10[] = -// // "LAr::Endcap::Cryostat::FcalLAr::Sector" -// { -// // ------------- region: warm and cold walls behind HEC, FCAL ---- -// // copy number range (low, high) -// { 5, 8, -// // Det Sub Typ Sam -// { 10, 4, 1, 3, -// sizeof(region030)/sizeof(RegionInfo_t), -// region030 } -// }, -// }; + // static const CopyNumberInfo_t info9[] = + // // "LAr::Endcap::Cryostat::FcalLAr::Cylinder" + // { + // // ------------- region: warm and cold walls behind HEC, FCAL ---- + // // copy number range (low, high) + // { 25, 26, + // // Det Sub Typ Sam + // { 10, 4, 1, 3, + // sizeof(region030)/sizeof(RegionInfo_t), + // region030 } + // }, + // }; + // + // static const CopyNumberInfo_t info10[] = + // // "LAr::Endcap::Cryostat::FcalLAr::Sector" + // { + // // ------------- region: warm and cold walls behind HEC, FCAL ---- + // // copy number range (low, high) + // { 5, 8, + // // Det Sub Typ Sam + // { 10, 4, 1, 3, + // sizeof(region030)/sizeof(RegionInfo_t), + // region030 } + // }, + // }; static const VolumeInfo_t volume5 = { "LAr::Endcap::Cryostat::Cylinder", - sizeof(info5) / sizeof(CopyNumberInfo_t), - info5 + sizeof(info5) / sizeof(CopyNumberInfo_t), + info5 }; static const VolumeInfo_t volume6 = { "LAr::Endcap::Cryostat::Cone", - sizeof(info6) / sizeof(CopyNumberInfo_t), - info6 + sizeof(info6) / sizeof(CopyNumberInfo_t), + info6 }; static const VolumeInfo_t volume7 = { "LAr::Endcap::Cryostat::EmecHecLAr::Cylinder", - sizeof(info7) / sizeof(CopyNumberInfo_t), - info7 + sizeof(info7) / sizeof(CopyNumberInfo_t), + info7 }; static const VolumeInfo_t volume8 = { "LAr::Endcap::Cryostat::EmecHecLAr::Sector", - sizeof(info8) / sizeof(CopyNumberInfo_t), - info8 + sizeof(info8) / sizeof(CopyNumberInfo_t), + info8 }; -// static const VolumeInfo_t volume9 = -// { "LAr::Endcap::Cryostat::FcalLAr::Cylinder", -// sizeof(info9) / sizeof(CopyNumberInfo_t), -// info9 -// }; + // static const VolumeInfo_t volume9 = + // { "LAr::Endcap::Cryostat::FcalLAr::Cylinder", + // sizeof(info9) / sizeof(CopyNumberInfo_t), + // info9 + // }; -// static const VolumeInfo_t volume10 = -// { "LAr::Endcap::Cryostat::FcalLAr::Sector", -// sizeof(info10) / sizeof(CopyNumberInfo_t), -// info10 -// }; + // static const VolumeInfo_t volume10 = + // { "LAr::Endcap::Cryostat::FcalLAr::Sector", + // sizeof(info10) / sizeof(CopyNumberInfo_t), + // info10 + // }; static const VolumeInfo_t volumes[] = { volume5, volume6, volume7, volume8}; static const G4int numberOfVolumes = sizeof(volumes) / sizeof(VolumeInfo_t); @@ -330,301 +323,311 @@ namespace LArG4 { // Methods /////////////////////////////////////////////////////////// - CalibrationCalculator::CalibrationCalculator() + CalibrationCalculator::CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_backupCalculator("EndcapCryostatCalibrationLArCalculator",name) { + declareProperty("BackupCalculator",m_backupCalculator); + } + + StatusCode CalibrationCalculator::initialize() { // Get a "backup" calculator. - if ( m_backupCalculator == 0 ) - m_backupCalculator = new CalibrationLArCalculator(); + + ATH_CHECK(m_backupCalculator.retrieve()); #if defined (DEBUG_HITS) || defined (DEBUG_MAPS) G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " - << " notInitialized=" - << notInitialized - << ", numberOfVolumes=" << numberOfVolumes - << ", sizeof(volumes)=" << sizeof(volumes) - << ", sizeof(VolumeInfo_t)=" << sizeof(VolumeInfo_t) - << G4endl; + << " notInitialized=" + << notInitialized + << ", numberOfVolumes=" << numberOfVolumes + << ", sizeof(volumes)=" << sizeof(volumes) + << ", sizeof(VolumeInfo_t)=" << sizeof(VolumeInfo_t) + << G4endl; #endif // Intialize the maps. if ( notInitialized ) - { - notInitialized = false; + { + notInitialized = false; - // For each volume managed by this calculator... - for (G4int v = 0; v != numberOfVolumes; v++) - { - const VolumeInfo_t& volume = volumes[v]; + // For each volume managed by this calculator... + for (G4int v = 0; v != numberOfVolumes; v++) + { + const VolumeInfo_t& volume = volumes[v]; #if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " - << " volume '" - << volume.volumeName - << "' has number of entries=" << volume.numberOfCopies - << G4endl; + G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " + << " volume '" + << volume.volumeName + << "' has number of entries=" << volume.numberOfCopies + << G4endl; #endif - identifierMap_t identifierMap; - const CopyNumberInfo_t* copyInfo = volume.copyInfo; - - // For each range copy numbers that can be found in a volume with this name... - for (G4int c = 0; c != volume.numberOfCopies; c++, copyInfo++) - { - // For each copy in the range of copy numbers - for (G4int copy = copyInfo->copyNumberLow; - copy <= copyInfo->copyNumberHigh; - copy++) - { + identifierMap_t identifierMap; + const CopyNumberInfo_t* copyInfo = volume.copyInfo; + + // For each range copy numbers that can be found in a volume with this name... + for (G4int c = 0; c != volume.numberOfCopies; c++, copyInfo++) + { + // For each copy in the range of copy numbers + for (G4int copy = copyInfo->copyNumberLow; + copy <= copyInfo->copyNumberHigh; + copy++) + { #if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " - << " adding copy=" << copy - << " to identifierMap" - << G4endl; + G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " + << " adding copy=" << copy + << " to identifierMap" + << G4endl; #endif - // Add to the map that's based on copy number. - identifierMap[copy] = &(copyInfo->identifierInfo); - } - } + // Add to the map that's based on copy number. + identifierMap[copy] = &(copyInfo->identifierInfo); + } + } - // Add to the map that's based on volume name; it - // contains maps based on copy number. - volumeMap[volume.volumeName] = identifierMap; + // Add to the map that's based on volume name; it + // contains maps based on copy number. + volumeMap[volume.volumeName] = identifierMap; #if defined (DEBUG_HITS) || defined (DEBUG_MAPS) - G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " - << " volume '" - << volume.volumeName - << "' added to map." - << G4endl; + G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " + << " volume '" + << volume.volumeName + << "' added to map." + << G4endl; #endif - } - } // if not initialized + } + } // if not initialized #if defined (DEBUG_HITS) || defined (DEBUG_MAPS) G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::CalibrationCalculator - " - << G4endl - << " initialization complete; map size=" - << volumeMap.size() - << G4endl; + << G4endl + << " initialization complete; map size=" + << volumeMap.size() + << G4endl; #endif - } + return StatusCode::SUCCESS; + }// initialize - CalibrationCalculator::~CalibrationCalculator() + CalibrationCalculator::~CalibrationCalculator() { // Clean up pointers. - delete m_backupCalculator; - m_backupCalculator = 0; + //delete m_backupCalculator; + //m_backupCalculator = 0; } - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) + G4bool CalibrationCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const { // Use the calculators to determine the energies and the // identifier associated with this G4Step. Note that the // default is to process both the energy and the ID. - m_energies.clear(); + _energies.clear(); if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } else { - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + { + m_energyCalculator.Energies( a_step, _energies ); + } else { + for (unsigned int i=0; i != 4; i++) _energies.push_back( 0. ); } - m_identifier.clear(); + _identifier.clear(); if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. + { + // Calculate the identifier. - // First, find the physical volume copy number, and the - // logical volume name. + // First, find the physical volume copy number, and the + // logical volume name. - const G4VPhysicalVolume* physical = a_step->GetPreStepPoint()->GetPhysicalVolume(); - const G4int copyNumber = physical->GetCopyNo(); - G4String volumeName = physical->GetLogicalVolume()->GetName(); + const G4VPhysicalVolume* physical = a_step->GetPreStepPoint()->GetPhysicalVolume(); + const G4int copyNumber = physical->GetCopyNo(); + G4String volumeName = physical->GetLogicalVolume()->GetName(); - if(volumeName.index("LArMgr::") == 0) volumeName.erase(0,8); + if(volumeName.index("LArMgr::") == 0) volumeName.erase(0,8); #ifdef DEBUG_HITS - G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process - " - << G4endl - << " searching for volume '" - << volumeName - << "' copyNumber=" - << copyNumber - << G4endl; + G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process - " + << G4endl + << " searching for volume '" + << volumeName + << "' copyNumber=" + << copyNumber + << G4endl; #endif - // Search the maps for this volume/copy number combination. - volumeMap_ptr_t v = volumeMap.find( volumeName ); - if ( v != volumeMap.end() ) - { + // Search the maps for this volume/copy number combination. + volumeMap_ptr_t v = volumeMap.find( volumeName ); + if ( v != volumeMap.end() ) + { - // Recall that maps are made from pair <key,value>, and - // you access a pair with the "first" and "second" - // members. In this case, "second" is a map. We don't - // need to copy the entire map; it's enough to get its - // reference. + // Recall that maps are made from pair <key,value>, and + // you access a pair with the "first" and "second" + // members. In this case, "second" is a map. We don't + // need to copy the entire map; it's enough to get its + // reference. - identifierMap_t& identifierMap = (*v).second; - identifierMap_ptr_t i = identifierMap.find( copyNumber ); + identifierMap_t& identifierMap = (*v).second; + identifierMap_ptr_t i = identifierMap.find( copyNumber ); - if ( i != identifierMap.end() ) - { - const IdentifierInfo_t* info = (*i).second; + if ( i != identifierMap.end() ) + { + const IdentifierInfo_t* info = (*i).second; - // Find our (x,y,z) location from the G4Step. + // Find our (x,y,z) location from the G4Step. - const G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - const G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - const G4ThreeVector startPoint = pre_step_point->GetPosition(); - const G4ThreeVector endPoint = post_step_point->GetPosition(); - const G4ThreeVector p = (startPoint + endPoint) * 0.5; + const G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + const G4StepPoint* post_step_point = a_step->GetPostStepPoint(); + const G4ThreeVector startPoint = pre_step_point->GetPosition(); + const G4ThreeVector endPoint = post_step_point->GetPosition(); + const G4ThreeVector p = (startPoint + endPoint) * 0.5; - // Determine the geometric eta and phi. Note that we do not - // adjust for any endcap shifts; the values are assigned to - // the volumes based on their actual positions + // Determine the geometric eta and phi. Note that we do not + // adjust for any endcap shifts; the values are assigned to + // the volumes based on their actual positions - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - // For this calculation, we need 0<phi<2*PI. (The - // official ATLAS standard of -PI<phi<PI is - // meaningless here.) - if ( phi < 0 ) phi += 2*M_PI; + G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + // For this calculation, we need 0<phi<2*PI. (The + // official ATLAS standard of -PI<phi<PI is + // meaningless here.) + if ( phi < 0 ) phi += 2*M_PI; - // The region can depend on eta. Search through the - // list of regions within this IdentifierInfo record - // to find which one has etaMin<eta<etaMax. + // The region can depend on eta. Search through the + // list of regions within this IdentifierInfo record + // to find which one has etaMin<eta<etaMax. - const G4int regions = info->numberOfRegions; - const RegionInfo_t* region = info->regionInfoArray; + const G4int regions = info->numberOfRegions; + const RegionInfo_t* region = info->regionInfoArray; #ifdef DEBUG_HITS - G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process - " - << G4endl - << " found volume, number of regions=" - << regions - << " eta=" << eta << " phi=" << phi - << G4endl; + G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process - " + << G4endl + << " found volume, number of regions=" + << regions + << " eta=" << eta << " phi=" << phi + << G4endl; #endif - G4int r; - for ( r = 0; r < regions; r++, region++ ) - { - if ( copyNumber!=8 && region->etaMax == 5.0 && eta > region->etaMax) { - // g.p. 3-Apr-2006 - // region is defined only until 5.0, but we may have hits - // from higher eta. Lets put them into last bin - eta = region->etaMax - 0.00001; - break; - } - // hack for strongly missaligned geometry, 2-Oct-2007, g.p. - if(region == ®ion025[0] && copyNumber == 11 && volumeName == "LAr::Endcap::Cryostat::Cylinder" && eta>=region->etaMax) { - eta = region->etaMax - 0.00001; - } - if ( eta > region->etaMin && eta < region->etaMax ) break; - } - - // If the following statement is not true, we're in - // trouble. It means that the eta of our energy - // deposit is outside the assumed eta limits of the - // volume. - - if ( r < regions ) - { - // Convert eta and phi to their integer equivalents for the - // identifier. - - const G4int etaInteger = G4int( (eta - region->etaMin) / region->deltaEta ); - G4int phiInteger = G4int( phi / region->deltaPhi ); - // to handle rounding error problem - if(phiInteger > 63) phiInteger = 0; + G4int r; + for ( r = 0; r < regions; r++, region++ ) + { + if ( copyNumber!=8 && region->etaMax == 5.0 && eta > region->etaMax) { + // g.p. 3-Apr-2006 + // region is defined only until 5.0, but we may have hits + // from higher eta. Lets put them into last bin + eta = region->etaMax - 0.00001; + break; + } + // hack for strongly missaligned geometry, 2-Oct-2007, g.p. + if(region == ®ion025[0] && copyNumber == 11 && volumeName == "LAr::Endcap::Cryostat::Cylinder" && eta>=region->etaMax) { + eta = region->etaMax - 0.00001; + } + if ( eta > region->etaMin && eta < region->etaMax ) break; + } + + // If the following statement is not true, we're in + // trouble. It means that the eta of our energy + // deposit is outside the assumed eta limits of the + // volume. + + if ( r < regions ) + { + // Convert eta and phi to their integer equivalents for the + // identifier. + + const G4int etaInteger = G4int( (eta - region->etaMin) / region->deltaEta ); + G4int phiInteger = G4int( phi / region->deltaPhi ); + // to handle rounding error problem + if(phiInteger > 63) phiInteger = 0; #ifdef DEBUG_HITS - G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process - " - << G4endl - << " found region=" - << region->regionNumber - << " eta bin=" << etaInteger << " phi bin=" << phiInteger - << G4endl; + G4cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process - " + << G4endl + << " found region=" + << region->regionNumber + << " eta bin=" << etaInteger << " phi bin=" << phiInteger + << G4endl; #endif - // The sign of subdet will depend on whether z is positive - // or negative. - G4int subDetSign = 1; - if ( p.z() < 0 ) subDetSign = -1; - - // A quick check against a bad value of etaMin. - if ( etaInteger >= 0 ) { - // Build the full identifier. - m_identifier << info->detector - << info->subdet * subDetSign - << info->type - << info->sampling - << region->regionNumber - << etaInteger - << phiInteger; - - } // etaInteger valid - } // eta valid - } // copy number valid - } // volume name valid - if ( m_identifier == LArG4Identifier() ) - { - // g.p. 09/05/2006 + // The sign of subdet will depend on whether z is positive + // or negative. + G4int subDetSign = 1; + if ( p.z() < 0 ) subDetSign = -1; + + // A quick check against a bad value of etaMin. + if ( etaInteger >= 0 ) { + // Build the full identifier. + _identifier << info->detector + << info->subdet * subDetSign + << info->type + << info->sampling + << region->regionNumber + << etaInteger + << phiInteger; + + } // etaInteger valid + } // eta valid + } // copy number valid + } // volume name valid + if ( _identifier == LArG4Identifier() ) + { + // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/CryostatCalibrationCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/CryostatCalibrationCalculator",_identifier,a_step); #endif #if defined (DEBUG_HITS) || defined (DEBUG_VOLUMES) - static const G4int messageMax = 1000; - static G4int messageCount = 0; // exists only if debug activated - if ( messageCount++ < messageMax ) { - G4ThreeVector p = (a_step->GetPreStepPoint()->GetPosition() + a_step->GetPostStepPoint()->GetPosition()) * 0.5; - std::cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process" << std::endl - << " G4Step in volume '" << volumeName - << "' copy# " << copyNumber - << " not found on tables, using backup calculator;" - << " xyz:"<<p.x()<<", "<<p.y()<<", "<<p.z() - << " eta:"<< p.pseudoRapidity() - << " (error " << messageCount << " of " << messageMax << " max displayed)." - << std::endl; - } + static const G4int messageMax = 1000; + static G4int messageCount = 0; // exists only if debug activated + if ( messageCount++ < messageMax ) { + G4ThreeVector p = (a_step->GetPreStepPoint()->GetPosition() + a_step->GetPostStepPoint()->GetPosition()) * 0.5; + std::cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process" << std::endl + << " G4Step in volume '" << volumeName + << "' copy# " << copyNumber + << " not found on tables, using backup calculator;" + << " xyz:"<<p.x()<<", "<<p.y()<<", "<<p.z() + << " eta:"<< p.pseudoRapidity() + << " (error " << messageCount << " of " << messageMax << " max displayed)." + << std::endl; + } #endif - } - } // calculate identifier + } + } // calculate identifier // What if we haven't implemented the code for a given volume? // Use a "backup" calculator to try to process the step. - if ( m_identifier == LArG4Identifier() ) - { - m_backupCalculator->Process(a_step, kOnlyID); - m_identifier = m_backupCalculator->identifier(); - } + if ( _identifier == LArG4Identifier() ) + { + //m_backupCalculator->Process(a_step, kOnlyID); + //_identifier = m_backupCalculator->identifier(); + std::vector<G4double> _tmpv; + m_backupCalculator->Process(a_step, _identifier, _tmpv, kOnlyID); + } #ifdef DEBUG_HITS -// G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); + // G4double energy = accumulate(_energies.begin(),_energies.end(),0.); std::cout << "LArG4::EndcapCryostat::CalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) -// << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + << " ID=" << std::string(_identifier) + // << " energy=" << energy + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")" + << std::endl; #endif -// g.p. 09/05/2006 + // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/CryostatCalibrationCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/CryostatCalibrationCalculator",_identifier,a_step); #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) return false; + if ( _identifier == LArG4Identifier() ) return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.h similarity index 73% rename from LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.h index acec58566946..d483467ebe3b 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationCalculator.h @@ -6,7 +6,7 @@ // Prepared 24-Feb-2004 Bill Seligman // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -22,7 +22,7 @@ #ifndef LArG4_EndcapCryostat_CalibrationCalculator_H #define LArG4_EndcapCryostat_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -41,12 +41,13 @@ namespace LArG4 { namespace EndcapCryostat { - class CalibrationCalculator : public VCalibrationCalculator { + class CalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationCalculator(); + + CalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -58,28 +59,18 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; // Define a "backup" calculator, in this case this calculator // misses a volume. - static VCalibrationCalculator* m_backupCalculator; + ServiceHandle<ILArCalibCalculatorSvc> m_backupCalculator; }; diff --git a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.cc index a927252af850..9a2625b81626 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.cc @@ -3,453 +3,373 @@ */ // LArG4::EndcapCryostat::CalibrationLArCalculator -// 19-Jul-2004 M.Leltchouk - prepared based on examples in +// 19-Jul-2004 M.Leltchouk - prepared based on examples in // BarrelCryostat::CalibrationLArCalculator // This class calculates the values needed for calibration hits in the // volumes: -// "LAr::Endcap::Cryostat::MotherVolume" -// "LAr::Endcap::Cryostat::EmecHecLAr" -// "LAr::Endcap::Cryostat::FcalLAr" +// "LAr::Endcap::Cryostat::MotherVolume" +// "LAr::Endcap::Cryostat::EmecHecLAr" +// "LAr::Endcap::Cryostat::FcalLAr" #undef DEBUG_HITS -#define DEBUG_VOLUMES +#undef DEBUG_VOLUMES #undef DEBUG_DMXYZ -#include "LArG4EC/CryostatCalibrationLArCalculator.h" -#ifdef DEBUG_DMXYZ -#include "LArG4Code/CalibrationDefaultCalculator.h" -#endif +#include "CryostatCalibrationLArCalculator.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4Code/CalibrationDefaultCalculator.h" - -// direct access to database -//#include "RDBAccessSvc/IRDBAccessSvc.h" -//#include "RDBAccessSvc/IRDBRecord.h" -//#include "RDBAccessSvc/IRDBRecordset.h" -//#include "GeoModelSvc/IGeoModelSvc.h" -//#include "GaudiKernel/ISvcLocator.h" -//#include "GaudiKernel/Bootstrap.h" -//#include "StoreGate/StoreGateSvc.h" #include "G4Step.hh" #include "G4StepPoint.hh" #include "G4VPhysicalVolume.hh" #include "G4ThreeVector.hh" #include "globals.hh" +#include "AthenaKernel/Units.h" #include <map> #include <cmath> #include <climits> + +namespace Units = Athena::Units; + + namespace LArG4 { namespace EndcapCryostat { - VCalibrationCalculator* CalibrationLArCalculator::m_defaultCalculator = 0; - /////////////////////////////////////////////////////////// // Methods /////////////////////////////////////////////////////////// - CalibrationLArCalculator::CalibrationLArCalculator() + CalibrationLArCalculator::CalibrationLArCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_defaultCalculator("CalibrationDefaultCalculator", name) { - // Get the default calculator (hopefully a temporary piece of code): - if ( m_defaultCalculator == 0) - m_defaultCalculator = new CalibrationDefaultCalculator(); + declareProperty("CalibrationDefaultCalculator", m_defaultCalculator); + } + + StatusCode CalibrationLArCalculator::initialize() { + + ATH_CHECK(m_defaultCalculator.retrieve()); // Access source of detector parameters. m_parameters = LArVG4DetectorParameters::GetInstance(); -// // Access to DB to get parameters -// StatusCode status; -// // Access the GeoModelSvc: -// ISvcLocator *svcLocator = Gaudi::svcLocator(); -// IGeoModelSvc *geoModel; -// status = svcLocator->service ("GeoModelSvc",geoModel); -// if (status != StatusCode::SUCCESS) { -// throw std::runtime_error ("Cannot locate GeoModelSvc!!"); -// } -// -// // Access the geometry database: -// IRDBAccessSvc *pAccessSvc; -// status=svcLocator->service("RDBAccessSvc",pAccessSvc); -// if (status != StatusCode::SUCCESS) { -// throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); -// } -// -// // Obtain the geometry version information: -// std::string AtlasVersion = geoModel->atlasVersion(); -// std::string LArVersion = geoModel->LAr_VersionOverride(); -// std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; -// std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; -// -// pAccessSvc->connect(); -// // getting detector parameters -// const IRDBRecordset *emecGeometry = pAccessSvc->getRecordset("EmecGeometry",detectorKey,detectorNode); -// if (emecGeometry->size()==0) { -// throw std::runtime_error("LArG4EC/cryostatCalibrationLArCalculator Cannot find the EmecGeometry table"); -// } -// const IRDBRecordset *fcalMod = pAccessSvc->getRecordset("FCalMod",detectorKey,detectorNode); -// if (fcalMod->size()==0) { -// fcalMod = pAccessSvc->getRecordset("FCalMod","FCalMod-00"); -// } -// if (fcalMod->size()==0) { -// throw std::runtime_error("LArG4EC/cryostatCalibrationLArCalculator Cannot find the FcalMod table"); -// } -// -// // Get the endcap shift from the detector parameters. -// m_zShift = (*emecGeometry)[0]->getDouble("ZSHIFT")*CLHEP::mm; -// -// // Get FCAL modules positions -// m_startZFCal1 = (*fcalMod)[0]->getDouble("STARTPOSITION")*CLHEP::mm; -// m_startZFCal2 = (*fcalMod)[1]->getDouble("STARTPOSITION")*CLHEP::mm; -// m_startZFCal3 = (*fcalMod)[2]->getDouble("STARTPOSITION")*CLHEP::mm; -// m_endZFCal3 = m_startZFCal3 + (*fcalMod)[2]->getDouble("FULLMODULEDEPTH")*CLHEP::mm; -// pAccessSvc->disconnect(); -// + // ----------------------------------------------------------------------- + // Load geometrical parameters + + // The fixed parameters (only a couple of which are readily + // accessible from the database): + + const double rhoAlignmentSafety = 10.*CLHEP::mm; + + const double HEC_MotherRouter = m_parameters->GetValue("LArHECmoduleRouter"); // 2030.*CLHEP::mm + // HEC Outer Radius + // for misalignment-safe determination what is out of them: + m_rhoOutOfEmecHec = HEC_MotherRouter - rhoAlignmentSafety; + + const double zShift = m_parameters->GetValue("LArEMECZshift"); // 40mm + + const double zAlignmentSafety = zShift + 10.*CLHEP::mm; + + + // At nominal (zShift=0) endcap position absolute z-coordinates: + // of the faces of the EndcapPresampler + const double zEndcapPresamplerFrontFace = + m_parameters->GetValue("LArEMECPreNomPos") - m_parameters->GetValue("LArEMECPreThickness")/2.; + // 3622. * CLHEP::mm + + m_zInFrontOfPresampler = zEndcapPresamplerFrontFace + zShift - 20.*CLHEP::mm; + // in this case it is safer to decrease Z-boundary and put it + // inside thick Cold Wall + // The E-deposit in the Cold Wall itself is handled by + // another calculator. + + // The E-deposit in the Cold Wall itself is handled by + // another calculator. + + m_zEMECRefPoint = m_parameters->GetValue("LArEMECRefPoint"); // Z0 = 3689.5*mm + m_zInFrontOfSpanishFan = zEMECRefPoint() + zAlignmentSafety; + + const double HECzStart = m_parameters->GetValue("LArHECzStart"); // 4277.*mm + + m_zInFrontOfHEC = HECzStart + zAlignmentSafety; + + m_zBehindTile = 6100. + zShift - 50.*CLHEP::mm; + + // g.p. 10/09/2008 parameters to find gap boundaries between HEC wheels + m_endZHEC1Wheel = HECzStart + zShift + + m_parameters->GetValue("LArHECdepthZ",0) + + m_parameters->GetValue("LArHECdepthZ",1) + + m_parameters->GetValue("LArHECdepthZ",2) - 10.0; + + m_startZHEC2Wheel = HECzStart + zShift + + m_parameters->GetValue("LArHECdepthZ",0) + + m_parameters->GetValue("LArHECdepthZ",1) + + m_parameters->GetValue("LArHECdepthZ",2) + + m_parameters->GetValue("LArHECfirstAbsorber",3) + + m_parameters->GetValue("LArHECbetweenWheel") + 10.0; + + return StatusCode::SUCCESS; } - CalibrationLArCalculator::~CalibrationLArCalculator() + CalibrationLArCalculator::~CalibrationLArCalculator() { // Cleanup pointers. - delete m_defaultCalculator; - m_defaultCalculator = 0; + //delete m_defaultCalculator; + //m_defaultCalculator = 0; } - - G4bool CalibrationLArCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) + G4bool CalibrationLArCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const { // Use the calculators to determine the energies and the // identifier associated with this G4Step. Note that the // default is to process both the energy and the ID. - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - // Note: - // LArG4::EndcapCryostat::CryostatCalibrationCalculator uses - // a table-based approach to determine the identifier. The - // following code uses an "if-statement" approach. - - // The fixed parameters (only a couple of which are readily - // accessible from the database): - - static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. - static const double oneOverDphi = 32./M_PI; // 1/Dphi - - static const double rhoAlignmentSafety = 10.*CLHEP::mm; - - static double HEC_MotherRouter = INT_MIN; - if ( HEC_MotherRouter < 0.) - HEC_MotherRouter = m_parameters->GetValue("LArHECmoduleRouter"); //2030.*CLHEP::mm HEC Outer Radius - // static const double EMEC_MotherRouter = 2077.*CLHEP::mm; - // we need only lesser of EMEC_MotherRouter, HEC_MotherRouter - // for misalignment-safe determination what is out of them: - static const double rhoOutOfEmecHec = HEC_MotherRouter - rhoAlignmentSafety; - - static double zShift = INT_MIN; - if ( zShift < 0.) - zShift = m_parameters->GetValue("LArEMECZshift"); // 40mm - static const double zAlignmentSafety = zShift + 10.*CLHEP::mm; - - - // At nominal (zShift=0) endcap position absolute z-coordinates: - // of the faces of the EndcapPresampler - static double zEndcapPresamplerFrontFace = INT_MIN; - if ( zEndcapPresamplerFrontFace < 0.) - zEndcapPresamplerFrontFace = - (m_parameters->GetValue("LArEMECPreNomPos") - - m_parameters->GetValue("LArEMECPreThickness")/2.); // 3622. * CLHEP::mm - static const double zInFrontOfPresampler = - zEndcapPresamplerFrontFace + zShift - 20.*CLHEP::mm; - // in this case it is safer to decrease Z-boundary and put it - // inside thick Cold Wall - // The E-deposit in the Cold Wall itself is handled by - // another calculator. - - // The E-deposit in the Cold Wall itself is handled by - // another calculator. - - static double zEMECRefPoint = INT_MIN; - if ( zEMECRefPoint < 0.) - zEMECRefPoint = m_parameters->GetValue("LArEMECRefPoint"); // Z0 = 3689.5*mm - static const double zInFrontOfSpanishFan = zEMECRefPoint + zAlignmentSafety; - - static double HECzStart = INT_MIN; - if ( HECzStart < 0.) - HECzStart = m_parameters->GetValue("LArHECzStart"); // 4277.*mm - - static const double zInFrontOfHEC = HECzStart + zAlignmentSafety; - //static const double zInFrontOfFCAL = 4668.5*mm + zAlignmentSafety; // startZFCal1 = 4668.5 * mm; - static const double zBehindTile = 6100. + zShift - 50.*CLHEP::mm; + _energies.clear(); + if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) { + m_energyCalculator.Energies( a_step, _energies ); + } else { + for (unsigned int i=0; i != 4; i++) { + _energies.push_back( 0. ); + } + } + + + _identifier.clear(); + if ( a_process == kEnergyAndID || a_process == kOnlyID ) { + // Calculate the identifier. + + // Note: + // LArG4::EndcapCryostat::CryostatCalibrationCalculator uses + // a table-based approach to determine the identifier. The + // following code uses an "if-statement" approach. + static const double sc_oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. + static const double sc_oneOverDphi = 32./M_PI; // 1/Dphi // FCAL related parameters - static const double m_zShift = 40.0; - static const double m_startZFCal1 = 4668.5 + m_zShift; - static const double m_startZFCal2 = 5128.3 + m_zShift; - static const double m_startZFCal3 = 5602.8 + m_zShift; - static const double m_endZFCal3 = m_startZFCal3 + 442.3; - static const double m_z1BeforeFCal = 4225.5 + m_zShift; // 368.95 + 53.6 - static const double m_z2BeforeFCal = 4557.5 + m_zShift; // - - // g.p. 10/09/2008 parameters to find gap boundaries between HEC wheels - static double m_endZHEC1Wheel = INT_MIN; - static double m_startZHEC2Wheel = INT_MIN; - if( m_endZHEC1Wheel < 0) { - m_endZHEC1Wheel = HECzStart + zShift + m_parameters->GetValue("LArHECdepthZ",0) + m_parameters->GetValue("LArHECdepthZ",1) + m_parameters->GetValue("LArHECdepthZ",2) - 10.0; - m_startZHEC2Wheel = HECzStart + zShift + m_parameters->GetValue("LArHECdepthZ",0) + m_parameters->GetValue("LArHECdepthZ",1) + m_parameters->GetValue("LArHECdepthZ",2) + m_parameters->GetValue("LArHECfirstAbsorber",3) + m_parameters->GetValue("LArHECbetweenWheel")+10.0; - // 5123.5 5209 - } -///* ---------------------------------------------------------------------- */ -//s tatic int ifirst=1; // not a thread-safe !!! -//if(ifirst){ -//ifirst=0; -//std::cout -//<< " rhoAlignmentSafety:" << rhoAlignmentSafety << std::endl -//<< " HEC_MotherRouter:" << HEC_MotherRouter << std::endl -//<< " rhoOutOfEmecHec:" << rhoOutOfEmecHec << std::endl -//<< " zShift:" << zShift << std::endl -//<< " zAlignmentSafety:" << zAlignmentSafety << std::endl -//<< " zEndcapPresamplerFrontFace:" << zEndcapPresamplerFrontFace << std::endl -//<< " zInFrontOfPresampler:" << zInFrontOfPresampler << std::endl -//<< " zEMECRefPoint:" << zEMECRefPoint << std::endl -//<< " zInFrontOfSpanishFan:" << zInFrontOfSpanishFan << std::endl -//<< " HECzStart:" << HECzStart << std::endl -//<< " zInFrontOfHEC:" << zInFrontOfHEC << std::endl -//<< " zInFrontOfFCAL:" << zInFrontOfFCAL << std::endl -//<< " zBehindTile:" << zBehindTile << std::endl -//<< " m_zShift:" << m_zShift << std::endl -//<< " m_startZFCal1:" << m_startZFCal1 << std::endl -//<< " m_startZFCal2:" << m_startZFCal2 << std::endl -//<< " m_startZFCal3:" << m_startZFCal3 << std::endl -//<< " m_endZFCal3:" << m_endZFCal3 << std::endl -//<< " m_z1BeforeFCal:" << m_z1BeforeFCal << std::endl -//<< " m_z2BeforeFCal:" << m_z2BeforeFCal << std::endl -//<< std::endl; -//} -///* ---------------------------------------------------------------------- */ - - // Calculate the mid-point of the step, and the simple geometry variables. - - const G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - const G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - - const G4ThreeVector startPoint = pre_step_point->GetPosition(); - const G4ThreeVector endPoint = post_step_point->GetPosition(); - const G4ThreeVector p = (startPoint + endPoint) * 0.5; - - const G4double rho = p.perp(); - const G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation - - const G4double absZ = fabs(p.z()); - - // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate - G4int subdet = ( p.z() > 0.) ? 4 : -4; - G4int type = 1; - G4int phiBin = (int) ( phi * oneOverDphi ); - // to handle rounding error problem - if(phiBin > 63) phiBin = 0; - - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int sampling = INT_MIN; - G4int region = INT_MIN; - G4int etaBin = INT_MIN; - - if( eta < 1.4) { + static const double sc_zShift = 40.0; + static const double sc_startZFCal1 = 4668.5 + sc_zShift; + static const double sc_startZFCal2 = 5128.3 + sc_zShift; + static const double sc_startZFCal3 = 5602.8 + sc_zShift; + static const double sc_endZFCal3 = sc_startZFCal3 + 442.3; + static const double sc_z1BeforeFCal = 4225.5 + sc_zShift; // 368.95 + 53.6 + static const double sc_z2BeforeFCal = 4557.5 + sc_zShift; // + + // Calculate the mid-point of the step, and the simple geometry variables. + + const G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + const G4StepPoint* post_step_point = a_step->GetPostStepPoint(); + + const G4ThreeVector startPoint = pre_step_point->GetPosition(); + const G4ThreeVector endPoint = post_step_point->GetPosition(); + const G4ThreeVector p = (startPoint + endPoint) * 0.5; + + const G4double rho = p.perp(); + const G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation + + const G4double absZ = fabs(p.z()); + + // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate + G4int subdet = ( p.z() > 0.) ? 4 : -4; + G4int type = 1; + G4int phiBin = (int) ( phi * sc_oneOverDphi ); + // to handle rounding error problem + if(phiBin > 63) phiBin = 0; + + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int sampling = INT_MIN; + G4int region = INT_MIN; + G4int etaBin = INT_MIN; + + if( eta < 1.4) { + sampling = 2; + region = 5; + etaBin = (int) ( (eta-1.) * sc_oneOverDeta ); + } else if( eta < 1.5 || (rho > rhoOutOfEmecHec() && eta < 1.7) ) { + if (absZ < zEMECRefPoint()) { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.3) * sc_oneOverDeta ); + } else { sampling = 2; region = 5; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - } else if( eta < 1.5 || (rho > rhoOutOfEmecHec && eta < 1.7) ) { - if (absZ < zEMECRefPoint) { - sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.3) * oneOverDeta ); - } else { - sampling = 2; - region = 5; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - } - } else if ( eta < 1.8 && absZ < zInFrontOfPresampler ) { // eta >= 1.5 + etaBin = (int) ( (eta-1.) * sc_oneOverDeta ); + } + } else if ( eta < 1.8 && absZ < zInFrontOfPresampler() ) { // eta >= 1.5 + sampling = 1; + region = 5; + etaBin = (int) ( (eta-1.5) * sc_oneOverDeta ); + } else if ( eta < 3.2 && absZ < zInFrontOfSpanishFan() ) { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.3) * sc_oneOverDeta ); + } else if ( eta < 3.2 && absZ < zInFrontOfHEC() ) { // eta >= 1.5 + sampling = 2; + region = 3; + etaBin = (int) ( (eta-1.5) * sc_oneOverDeta ); + } else if ( eta >= 2.9 && eta < 5. && absZ < sc_startZFCal1 ) { + if(fabs(p.z()) < sc_z1BeforeFCal) { sampling = 1; + region = 7; + etaBin = (int) ( (eta-3.2) * sc_oneOverDeta ); + } else if (fabs(p.z()) < sc_z2BeforeFCal){ + type = 2; + sampling = 0; region = 5; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } else if ( eta < 3.2 && absZ < zInFrontOfSpanishFan ) { + etaBin = (int) ( (eta-3.0) * sc_oneOverDeta ); + } else { + type = 2; sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.3) * oneOverDeta ); - } else if ( eta < 3.2 && absZ < zInFrontOfHEC ) { // eta >= 1.5 + region = 5; + etaBin = (int) ( (eta-3.0) * sc_oneOverDeta ); + } + if(etaBin < 0) etaBin = 0; + } else if ( eta < 1.7 && absZ > zBehindTile() ) { //GU change eta>1.7 to eta<1.7 to agree with documentation for subdet =+-5 + subdet = ( p.z() > 0.) ? 5 : -5; + sampling = 0; + region = 4; + etaBin = (int) ( eta * sc_oneOverDeta ); + // G.P. to treat material between HEC and FCAL + } else if ( eta > 2.9 && eta < 3.3 && absZ > sc_startZFCal1 && absZ < sc_endZFCal3) { + if ( fabs(p.z()) < sc_startZFCal1 ) { + type = 2; + sampling = 1; + region = 5; + etaBin = (int) ( (eta-3.0) * sc_oneOverDeta ); + } else if ( fabs(p.z()) < sc_startZFCal2 ) { + type = 2; + sampling = 1; + region = 4; + etaBin = 0; + } else if ( fabs(p.z()) < sc_startZFCal3 ) { + type = 2; sampling = 2; - region = 3; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } else if ( eta >= 2.9 && eta < 5. && absZ < m_startZFCal1 ) { - if(fabs(p.z()) < m_z1BeforeFCal) { - sampling = 1; - region = 7; - etaBin = (int) ( (eta-3.2) * oneOverDeta ); - } else if (fabs(p.z()) < m_z2BeforeFCal){ - type = 2; - sampling = 0; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } else { - type = 2; - sampling = 1; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } - if(etaBin < 0) etaBin = 0; - } else if ( eta < 1.7 && absZ > zBehindTile ) { //GU change eta>1.7 to eta<1.7 to agree with documentation for subdet =+-5 - subdet = ( p.z() > 0.) ? 5 : -5; - sampling = 0; region = 4; - etaBin = (int) ( eta * oneOverDeta ); - // G.P. to treat material between HEC and FCAL - } else if ( eta > 2.9 && eta < 3.3 && absZ > m_startZFCal1 && absZ < m_endZFCal3) { - if ( fabs(p.z()) < m_startZFCal1 ) { - type = 2; - sampling = 1; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } else if ( fabs(p.z()) < m_startZFCal2 ) { - type = 2; - sampling = 1; - region = 4; - etaBin = 0; - } else if ( fabs(p.z()) < m_startZFCal3 ) { - type = 2; - sampling = 2; - region = 4; - etaBin = 0; - } else if ( fabs(p.z()) < m_endZFCal3 ) { // - type = 2; - sampling = 3; - region = 4; - etaBin = 0; - } else{ // leakage behind FCAL+HEC - type = 1; - sampling = 3; - region = 0; - etaBin = (int) ( (eta-1.7) * oneOverDeta ); - } - //GU change for eta above 1.7 for sampling 3 - } else if ( eta < 5. && eta >=1.7 ) { - sampling = 3; - region = 0; - etaBin = (int) ( (eta-1.7) * oneOverDeta ); - } else if ( eta >= 5. && eta < 8.0) { - sampling = 3; - region = 1; - etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); - } else if (eta>8.) { + etaBin = 0; + } else if ( fabs(p.z()) < sc_endZFCal3 ) { // + type = 2; sampling = 3; - region = 2; + region = 4; etaBin = 0; - phiBin = 0; - // g.p. 10/09/2008 crack between two HEC wheels (after broke up the HEC into two wheels in GeoModel by M.Fincke) - } else if ( fabs(p.z()) > m_endZHEC1Wheel && fabs(p.z()) < m_startZHEC2Wheel ) { + } else{ // leakage behind FCAL+HEC type = 1; - sampling = 2; - region = 4; - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } else { - std::cout << "CryostatCalibrationLArCalculator id not found " << eta << " " << absZ << std::endl; - std::cout << "type: " << type << " region:" << region << " sampling: " << sampling << " etaBin: " << etaBin << " phiBin: " << phiBin << std::endl; + sampling = 3; + region = 0; + etaBin = (int) ( (eta-1.7) * sc_oneOverDeta ); } + //GU change for eta above 1.7 for sampling 3 + } else if ( eta < 5. && eta >=1.7 ) { + sampling = 3; + region = 0; + etaBin = (int) ( (eta-1.7) * sc_oneOverDeta ); + } else if ( eta >= 5. && eta < 8.0) { + sampling = 3; + region = 1; + etaBin = (int) ( (eta-5.)* 0.5 * sc_oneOverDeta ); + } else if (eta>8.) { + sampling = 3; + region = 2; + etaBin = 0; + phiBin = 0; + // g.p. 10/09/2008 crack between two HEC wheels (after broke up the HEC into two wheels in GeoModel by M.Fincke) + } else if ( fabs(p.z()) > endZHEC1Wheel() && fabs(p.z()) < startZHEC2Wheel() ) { + type = 1; + sampling = 2; + region = 4; + etaBin = (int) ( (eta-1.5) * sc_oneOverDeta ); + } else { + std::cout << "CryostatCalibrationLArCalculator id not found " << eta << " " << absZ << std::endl; + std::cout << "type: " << type << " region:" << region << " sampling: " << sampling << " etaBin: " << etaBin << " phiBin: " << phiBin << std::endl; + } - // This is a "quick fix" for a complex issue: We're still - // developing code for the cryostat. What if, somehow, we have - // a G4Step in a LAr or Mother volume that isn't handled by the above - // code? Answer: Use the default calibration calculator (the - // same one used for volumes without sensitive detectors) to get - // the identifier. - - if ( type == INT_MIN || - region == INT_MIN || - sampling == INT_MIN || - etaBin == INT_MIN || - phiBin < 0 || etaBin < 0) - { -// g.p. 09/05/2006 + // This is a "quick fix" for a complex issue: We're still + // developing code for the cryostat. What if, somehow, we have + // a G4Step in a LAr or Mother volume that isn't handled by the above + // code? Answer: Use the default calibration calculator (the + // same one used for volumes without sensitive detectors) to get + // the identifier. + + if ( type == INT_MIN || + region == INT_MIN || + sampling == INT_MIN || + etaBin == INT_MIN || + phiBin < 0 || etaBin < 0) + { + // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/CryostatCalibrationLArCalculator",m_identifier,a_step,-999.); + LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/CryostatCalibrationLArCalculator",_identifier,a_step,-999.); #endif #if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) - static const G4int messageMax = 10; - static G4int messageCount = 0; // exists only if debug activated - if ( messageCount++ < messageMax ) - { - std::cout << "LArG4::EndcapCryostat::CalibrationLArCalculator::Process" - << " (error " << messageCount << " of " << messageMax << " max displayed)" - << std::endl - << " G4Step in LAr at unexpected place: (x,y,z) [mm] = (" - << p.x()/CLHEP::mm << "," - << p.y()/CLHEP::mm << "," - << p.z()/CLHEP::mm - << "); eta=" << eta - << ", phi=" << phi << std::endl - << ", rho=" << sqrt(pow(p.x()/CLHEP::mm,2)+pow(p.y()/CLHEP::mm,2)) - << " using default calculator" - << std::endl; - } + static const G4int messageMax = 10; + static G4int messageCount = 0; // exists only if debug activated + if ( messageCount++ < messageMax ) + { + std::cout << "LArG4::EndcapCryostat::CalibrationLArCalculator::Process" + << " (error " << messageCount << " of " << messageMax << " max displayed)" + << std::endl + << " G4Step in LAr at unexpected place: (x,y,z) [mm] = (" + << p.x()/Units::mm << "," + << p.y()/Units::mm << "," + << p.z()/Units::mm + << "); eta=" << eta + << ", phi=" << phi << std::endl + << ", rho=" << sqrt(pow(p.x()/Units::mm,2)+pow(p.y()/Units::mm,2)) + << " using default calculator" + << std::endl; + } #endif - m_defaultCalculator->Process(a_step, kOnlyID); - m_identifier = m_defaultCalculator->identifier(); - } - else - { - // Append the cell ID to the (empty) identifier. - m_identifier << 10 // Calorimeter - << subdet // LAr +/-4,5 where "+" or " -" according to - // the sign of Z in World coorinate - << type - << sampling - << region - << etaBin - << phiBin; - if (type==1 && sampling==3 && region==0 && etaBin>32) { - std::cout << "Invalid ID S3 r3 CryostatLArCalculator " << eta << " " << etaBin << std::endl; - } - } - } - + //m_defaultCalculator->Process(a_step, kOnlyID); + //_identifier = m_defaultCalculator->identifier(); + std::vector<G4double> _tmpv; + m_defaultCalculator->Process(a_step, _identifier, _tmpv, kOnlyID); + } + else + { + // Append the cell ID to the (empty) identifier. + _identifier << 10 // Calorimeter + << subdet // LAr +/-4,5 where "+" or " -" according to + // the sign of Z in World coorinate + << type + << sampling + << region + << etaBin + << phiBin; + if (type==1 && sampling==3 && region==0 && etaBin>32) { + std::cout << "Invalid ID S3 r3 CryostatLArCalculator " << eta << " " << etaBin << std::endl; + } + } + } + #ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); + G4double energy = accumulate(_energies.begin(),_energies.end(),0.); std::cout << "LArG4::EndcapCryostat::CalibrationLArCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + << " ID=" << std::string(_identifier) + << " energy=" << energy + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")" + << std::endl; #endif -// g.p. 09/05/2006 + // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/CryostatCalibrationLArCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/CryostatCalibrationLArCalculator",_identifier,a_step); #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; + if ( _identifier == LArG4Identifier() ) { + return false; + } return true; } diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationLArCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.h similarity index 57% rename from LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationLArCalculator.h rename to LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.h index 2af79d906419..b3ac0ae332fb 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationLArCalculator.h +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationLArCalculator.h @@ -6,7 +6,7 @@ // Prepared 19-Aug-2004 Bill Seligman // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -21,7 +21,7 @@ #ifndef LArG4_EndcapCryostat_CalibrationLArCalculator_H #define LArG4_EndcapCryostat_CalibrationLArCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "LArG4Code/LArVG4DetectorParameters.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -41,12 +41,13 @@ namespace LArG4 { namespace EndcapCryostat { - class CalibrationLArCalculator : public VCalibrationCalculator { + class CalibrationLArCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationLArCalculator(); + + CalibrationLArCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationLArCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -58,22 +59,12 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; @@ -81,8 +72,24 @@ namespace LArG4 { LArVG4DetectorParameters* m_parameters; // For the default calculator (hopefully temporary). - static VCalibrationCalculator* m_defaultCalculator; - + ServiceHandle<ILArCalibCalculatorSvc> m_defaultCalculator; + + double m_rhoOutOfEmecHec; // used as const after init + double m_zInFrontOfPresampler; // used as const after init + double m_zEMECRefPoint; // used as const after init + double m_zInFrontOfSpanishFan; // used as const after init + double m_zInFrontOfHEC; // used as const after init + double m_zBehindTile; // used as const after init + double m_endZHEC1Wheel; // used as const after init + double m_startZHEC2Wheel; // used as const after init + inline double rhoOutOfEmecHec() const { return m_rhoOutOfEmecHec; }; + inline double zInFrontOfPresampler() const { return m_zInFrontOfPresampler; }; + inline double zEMECRefPoint() const { return m_zEMECRefPoint; }; + inline double zInFrontOfSpanishFan() const { return m_zInFrontOfSpanishFan; }; + inline double zInFrontOfHEC() const { return m_zInFrontOfHEC; }; + inline double zBehindTile() const { return m_zBehindTile; }; + inline double endZHEC1Wheel() const { return m_endZHEC1Wheel; }; + inline double startZHEC2Wheel() const { return m_startZHEC2Wheel; }; }; } // namespace EndcapCryostat diff --git a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc index 8e4ec6e87bc4..62c12be9450d 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.cc @@ -11,17 +11,12 @@ // simulation. #undef DEBUG_HITS -#define DEBUG_VOLUMES +#undef DEBUG_VOLUMES #undef DEBUG_DMXYZ -#include "LArG4EC/CryostatCalibrationMixedCalculator.h" -#ifdef DEBUG_DMXYZ -#include "LArG4Code/CalibrationDefaultCalculator.h" -#endif -#include "LArG4EC/CryostatCalibrationLArCalculator.h" +#include "CryostatCalibrationMixedCalculator.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" // direct access to database #include "RDBAccessSvc/IRDBAccessSvc.h" @@ -47,13 +42,11 @@ namespace LArG4 { namespace EndcapCryostat { - VCalibrationCalculator* CalibrationMixedCalculator::m_backupCalculator = 0; - /////////////////////////////////////////////////////////// // Local class to store detector parameters for calculator /////////////////////////////////////////////////////////// class CalibrationMixedCalculator::Parameters { - public: + public: Parameters(); ~Parameters(); @@ -93,7 +86,7 @@ namespace LArG4 { // Obtain the geometry version information: std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); + std::string LArVersion = geoModel->LAr_VersionOverride(); std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; @@ -132,21 +125,21 @@ namespace LArG4 { m_z1BeforeFCal = m_zEMECRefPoint + m_LArEMECLArThickness; m_z2BeforeFCal = m_endZHec0; -// std::cout << "--- GGG CryostatCalibrationMixedCalculator.cc ---" << std::endl -// << " m_zShift: " << m_zShift << std::endl -// << " m_zEMECRefPoint: " << m_zEMECRefPoint << std::endl -// << " m_LArEMECLArThickness: " << m_LArEMECLArThickness << std::endl -// << " m_startZFCal1: " << m_startZFCal1 << std::endl -// << " m_startZFCal2: " << m_startZFCal2 << std::endl -// << " m_startZFCal3: " << m_startZFCal3 << std::endl -// << " m_hdepthFCal1: " << m_hdepthFCal1 << std::endl -// << " m_hdepthFCal2: " << m_hdepthFCal2 << std::endl -// << " m_hdepthFCal3: " << m_hdepthFCal3 << std::endl -// << " m_endZFCal3: " << m_endZFCal3 << std::endl -// << " m_endZHec0: " << m_endZHec0 << std::endl -// << " m_z1BeforeFCal: " << m_z1BeforeFCal << std::endl -// << " m_z2BeforeFCal: " << m_z2BeforeFCal << std::endl -// << std::endl; + // std::cout << "--- GGG CryostatCalibrationMixedCalculator.cc ---" << std::endl + // << " m_zShift: " << m_zShift << std::endl + // << " m_zEMECRefPoint: " << m_zEMECRefPoint << std::endl + // << " m_LArEMECLArThickness: " << m_LArEMECLArThickness << std::endl + // << " m_startZFCal1: " << m_startZFCal1 << std::endl + // << " m_startZFCal2: " << m_startZFCal2 << std::endl + // << " m_startZFCal3: " << m_startZFCal3 << std::endl + // << " m_hdepthFCal1: " << m_hdepthFCal1 << std::endl + // << " m_hdepthFCal2: " << m_hdepthFCal2 << std::endl + // << " m_hdepthFCal3: " << m_hdepthFCal3 << std::endl + // << " m_endZFCal3: " << m_endZFCal3 << std::endl + // << " m_endZHec0: " << m_endZHec0 << std::endl + // << " m_z1BeforeFCal: " << m_z1BeforeFCal << std::endl + // << " m_z2BeforeFCal: " << m_z2BeforeFCal << std::endl + // << std::endl; pAccessSvc->disconnect(); } @@ -159,33 +152,45 @@ namespace LArG4 { // Methods /////////////////////////////////////////////////////////// - CalibrationMixedCalculator::CalibrationMixedCalculator() : m_par(new Parameters()) + CalibrationMixedCalculator::CalibrationMixedCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_par(nullptr) + , m_backupCalculator("EndcapCryostatCalibrationLArCalculator",name) { + declareProperty("BackupCalculator",m_backupCalculator); + } + + StatusCode CalibrationMixedCalculator::initialize() { // Get a "backup" calculator. - if ( m_backupCalculator == 0) - m_backupCalculator = new CalibrationLArCalculator(); + //if ( m_backupCalculator == 0) + //m_backupCalculator = new CalibrationLArCalculator(); + ATH_CHECK(m_backupCalculator.retrieve()); + m_par = new Parameters(); + return StatusCode::SUCCESS; } - CalibrationMixedCalculator::~CalibrationMixedCalculator() + CalibrationMixedCalculator::~CalibrationMixedCalculator() { // Cleanup pointers. - delete m_backupCalculator; - m_backupCalculator = 0; + //delete m_backupCalculator; + //m_backupCalculator = 0; delete m_par; } // This calculator is intended to apply to the endcap volumes that // have "mixed" identifiers: - G4bool CalibrationMixedCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) + G4bool CalibrationMixedCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const { const static G4String volLArMgr = "LArMgr::"; const static G4String volLArEndcapCryostat = "LAr::Endcap::Cryostat::"; const static G4String volCylinderMixed = "Cylinder::Mixed"; const static G4String volCylinderMixedPresampler = "Cylinder::Mixed::PresamplerMother"; - const static G4String volExtraBeforePS = "ExtraCyl_beforePS"; + const static G4String volExtraBeforePS = "ExtraCyl_beforePS"; const static G4String volSectorMixed = "Sector::Mixed"; const static G4String volEmecHecLArSectorMixed = "EmecHecLAr::Sector::Mixed"; const static G4String volConeMixed = "Cone::Mixed"; @@ -194,351 +199,353 @@ namespace LArG4 { // identifier associated with this G4Step. Note that the // default is to process both the energy and the ID. - m_energies.clear(); + _energies.clear(); if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) { - m_energyCalculator.Energies( a_step, m_energies ); + m_energyCalculator.Energies( a_step, _energies ); } else { - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) _energies.push_back( 0. ); } - m_identifier.clear(); + _identifier.clear(); if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - // Note: - // LArG4::EndcapCryostat::CryostatCalibrationCalculator uses - // a table-based approach to determine the identifier. The - // following code uses an "if-statement" approach. - - // The fixed parameters (only a couple of which are readily - // accessible from the database): - - static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. - static const double oneOverDphi = 32./M_PI; // 1/Dphi - - // Calculate the mid-point of the step, and the simple geometry variables. - - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - //G4double rho = p.perp(); - G4double eta = fabs( p.pseudoRapidity() ); - G4double phi = p.phi(); - if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation - - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int subdet = INT_MIN; - G4int type = INT_MIN; - G4int sampling = INT_MIN; - G4int region = INT_MIN; - G4int etaBin = INT_MIN; - G4int phiBin = (int) ( phi * oneOverDphi ); - // to handle rounding error problem - if(phiBin > 63) phiBin = 0; - - G4String name = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); - G4int copy = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); - - // we meet here 3 volume types: - // LArMgr::LAr::Endcap::Cryostat::* - // LAr::Endcap::Cryostat::Cylinder::Mixed::PresamplerMother - // LArMgr::LAr::FCAL::LiquidArgonC - if(name.compare(0, 8, volLArMgr) == 0) name.erase(0,8); - - if ( name.size() == 23 && name == volFcalLiquidArgonC ) { - subdet = ( p.z() > 0.) ? 4 : -4; - type = 1; - if ( eta < 5.0) { - type = 2; - region = 5; - etaBin = (int) ( (eta-3.)* oneOverDeta ); - sampling = 0; - if ( fabs(p.z()) < (m_par->m_startZFCal1+m_par->m_hdepthFCal1) ) { - sampling = 1; - } else if( fabs(p.z()) < (m_par->m_startZFCal2+m_par->m_hdepthFCal2) ) { - sampling = 2; - } else if( fabs(p.z()) < (m_par->m_startZFCal3+m_par->m_hdepthFCal3) ) { - sampling = 3; - } else { - type = 1; - sampling = 3; - region = 0; - etaBin = (int) ( (eta-1.7)* oneOverDeta ); - } - } else if (eta < 8.0) { - sampling = 3; - region = 1; - etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); - } else { - sampling = 3; - region = 2; - etaBin = 0; - phiBin = 0; - } - }else if(name.size() > 23){ - name.erase(0,23); - if ( ( ( copy == 3 || copy == 14 ) && name == volCylinderMixed ) || name == volCylinderMixedPresampler || name==volExtraBeforePS) - { - // case 1 // front walls - // volumeName LArMgr::LAr::Endcap::Cryostat::Cylinder::Mixed, copy number 3, 14 - // volumeName LAr::Endcap::Cryostat::Cylinder::Mixed::PresamplerMother - - // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate + { + // Calculate the identifier. + + // Note: + // LArG4::EndcapCryostat::CryostatCalibrationCalculator uses + // a table-based approach to determine the identifier. The + // following code uses an "if-statement" approach. + + // The fixed parameters (only a couple of which are readily + // accessible from the database): + + static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. + static const double oneOverDphi = 32./M_PI; // 1/Dphi + + // Calculate the mid-point of the step, and the simple geometry variables. + + G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + G4StepPoint* post_step_point = a_step->GetPostStepPoint(); + + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + //G4double rho = p.perp(); + G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + if ( phi < 0. ) phi += 2.*M_PI; // Normalize for phiBin calculation + + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int subdet = INT_MIN; + G4int type = INT_MIN; + G4int sampling = INT_MIN; + G4int region = INT_MIN; + G4int etaBin = INT_MIN; + G4int phiBin = (int) ( phi * oneOverDphi ); + // to handle rounding error problem + if(phiBin > 63) phiBin = 0; + + G4String name = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); + G4int copy = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); + + // we meet here 3 volume types: + // LArMgr::LAr::Endcap::Cryostat::* + // LAr::Endcap::Cryostat::Cylinder::Mixed::PresamplerMother + // LArMgr::LAr::FCAL::LiquidArgonC + if(name.compare(0, 8, volLArMgr) == 0) name.erase(0,8); + + if ( name.size() == 23 && name == volFcalLiquidArgonC ) { subdet = ( p.z() > 0.) ? 4 : -4; type = 1; - if ( eta < 1.4 ) { - sampling = 2; - region = 5; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - }else if ( eta < 1.5 ) { - sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.3) * oneOverDeta ); - } else if ( eta < 1.8 ) { - sampling = 1; + if ( eta < 5.0) { + type = 2; region = 5; - // these walls are behind the scintillator - so it is - // region=5 and not region=4 even for 1.5<eta<1.6 - etaBin = (int) ( (eta-1.5) * oneOverDeta ); - } else if ( eta < 3.2 ) { - sampling = 1; - region = 6; - etaBin = (int) ( (eta-1.3) * oneOverDeta ); - } else if ( eta < 5.0 ) { // we expect that eta < 5.0 - type = 1; - sampling = 1; - region = 7; - etaBin = (int) ( (eta-3.2) * oneOverDeta ); - } else if( eta < 8.0 ) { + etaBin = (int) ( (eta-3.)* oneOverDeta ); + sampling = 0; + if ( fabs(p.z()) < (m_par->m_startZFCal1+m_par->m_hdepthFCal1) ) { + sampling = 1; + } else if( fabs(p.z()) < (m_par->m_startZFCal2+m_par->m_hdepthFCal2) ) { + sampling = 2; + } else if( fabs(p.z()) < (m_par->m_startZFCal3+m_par->m_hdepthFCal3) ) { + sampling = 3; + } else { + type = 1; + sampling = 3; + region = 0; + etaBin = (int) ( (eta-1.7)* oneOverDeta ); + } + } else if (eta < 8.0) { sampling = 3; region = 1; - etaBin = (int) ( (eta-5.0) * 0.5 * oneOverDeta ); + etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); } else { sampling = 3; region = 2; etaBin = 0; phiBin = 0; } - } else if ( ( copy == 9 || copy == 12 || copy == 13 ) && name == volCylinderMixed ) { - // case 2 // back walls near Tile - // volumeName "LArMgr::LAr::Endcap::Cryostat::Cylinder::Mixed" - // copy number 9, 12, 13 + }else if(name.size() > 23){ + name.erase(0,23); + if ( ( ( copy == 3 || copy == 14 ) && name == volCylinderMixed ) || name == volCylinderMixedPresampler || name==volExtraBeforePS) + { + // case 1 // front walls + // volumeName LArMgr::LAr::Endcap::Cryostat::Cylinder::Mixed, copy number 3, 14 + // volumeName LAr::Endcap::Cryostat::Cylinder::Mixed::PresamplerMother + + // subdet = +/-4 "+" or " -" according to sign of Z in World coorinate + subdet = ( p.z() > 0.) ? 4 : -4; + type = 1; + if ( eta < 1.4 ) { + sampling = 2; + region = 5; + etaBin = (int) ( (eta-1.) * oneOverDeta ); + }else if ( eta < 1.5 ) { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.3) * oneOverDeta ); + } else if ( eta < 1.8 ) { + sampling = 1; + region = 5; + // these walls are behind the scintillator - so it is + // region=5 and not region=4 even for 1.5<eta<1.6 + etaBin = (int) ( (eta-1.5) * oneOverDeta ); + } else if ( eta < 3.2 ) { + sampling = 1; + region = 6; + etaBin = (int) ( (eta-1.3) * oneOverDeta ); + } else if ( eta < 5.0 ) { // we expect that eta < 5.0 + type = 1; + sampling = 1; + region = 7; + etaBin = (int) ( (eta-3.2) * oneOverDeta ); + } else if( eta < 8.0 ) { + sampling = 3; + region = 1; + etaBin = (int) ( (eta-5.0) * 0.5 * oneOverDeta ); + } else { + sampling = 3; + region = 2; + etaBin = 0; + phiBin = 0; + } + } else if ( ( copy == 9 || copy == 12 || copy == 13 ) && name == volCylinderMixed ) { + // case 2 // back walls near Tile + // volumeName "LArMgr::LAr::Endcap::Cryostat::Cylinder::Mixed" + // copy number 9, 12, 13 - type = 1; - if ( eta < 1.7 ) { - subdet = ( p.z() > 0.) ? 5 : -5; - sampling = 3; - region = 0; - etaBin = (int) ( eta * oneOverDeta ); - } else if ( eta < 5.0 ) { - subdet = ( p.z() > 0.) ? 4 : -4; - sampling = 3; - region = 0; - etaBin = (int) ( (eta-1.7) * oneOverDeta ); - } - } else if ( ( ( copy == 10 || copy == 19 ) && name == volCylinderMixed ) || - ( ( copy == 3 || copy == 4 ) && name == volSectorMixed ) || - ( ( copy == 1 || copy == 2 || copy == 8 || copy == 9 || copy == 10 || copy == 11 || copy == 12 ) && name == volEmecHecLArSectorMixed ) ) { - // case 3 // walls and supports at large rho - // volumeName "LAr::Endcap::Cryostat::Cylinder" - // copy number 10, 19 + type = 1; + if ( eta < 1.7 ) { + subdet = ( p.z() > 0.) ? 5 : -5; + sampling = 3; + region = 0; + etaBin = (int) ( eta * oneOverDeta ); + } else if ( eta < 5.0 ) { + subdet = ( p.z() > 0.) ? 4 : -4; + sampling = 3; + region = 0; + etaBin = (int) ( (eta-1.7) * oneOverDeta ); + } + } else if ( ( ( copy == 10 || copy == 19 ) && name == volCylinderMixed ) || + ( ( copy == 3 || copy == 4 ) && name == volSectorMixed ) || + ( ( copy == 1 || copy == 2 || copy == 8 || copy == 9 || copy == 10 || copy == 11 || copy == 12 ) && name == volEmecHecLArSectorMixed ) ) { + // case 3 // walls and supports at large rho + // volumeName "LAr::Endcap::Cryostat::Cylinder" + // copy number 10, 19 - // volumeName "LAr::Endcap::Cryostat::Sector" - // copy number 3, 4 SectorDBArray: daughters of cryoMotherLogical + // volumeName "LAr::Endcap::Cryostat::Sector" + // copy number 3, 4 SectorDBArray: daughters of cryoMotherLogical - // volumeName "LAr::Endcap::Cryostat::EmecHecLAr::Sector" - // copy number 1-2,8,9-12 + // volumeName "LAr::Endcap::Cryostat::EmecHecLAr::Sector" + // copy number 1-2,8,9-12 - subdet = ( p.z() > 0.) ? 4 : -4; - type = 1; - if ( eta < 1.7 ) { - sampling = 2; - region = 5; - etaBin = (int) ( (eta-1.) * oneOverDeta ); - } else { - sampling = 3; - region = 0; - etaBin = (int) ( (eta-1.7) * oneOverDeta ); - } - }else if ( copy == 27 && name == volCylinderMixed ) { - // case 4 // wall between HEC and FCAL - // volumeName "LAr::Endcap::Cryostat::Cylinder::Mixed" - // copy number 27 - subdet = ( p.z() > 0.) ? 4 : -4; - if ( fabs(p.z()) < m_par->m_startZFCal1 ) { - type = 2; - sampling = 1; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } else if ( fabs(p.z()) < m_par->m_startZFCal2 ) { - type = 2; - sampling = 1; - region = 4; - etaBin = 0; - } else if ( fabs(p.z()) < m_par->m_startZFCal3 ) { // - type = 2; - sampling = 2; - region = 4; - etaBin = 0; - } else if ( fabs(p.z()) < m_par->m_endZFCal3 ) { // - type = 2; - sampling = 3; - region = 4; - etaBin = 0; - } else{ // leakage behind FCAL+HEC + subdet = ( p.z() > 0.) ? 4 : -4; type = 1; - sampling = 3; - region = 0; - etaBin = (int) ( (eta-1.7) * oneOverDeta ); - } - } else if ( copy==1 && name == volConeMixed) { - // case 6 // walls close to beam-pipe - // volumeName "LAr::Endcap::Cryostat::Cone::Mixed" - // copy number 6, 7, 16, 29, 33 - subdet = ( p.z() > 0.) ? 4 : -4; - type = 1; - if ( eta < 5.0 ) { - if(fabs(p.z()) < m_par->m_z1BeforeFCal) { - type = 1; - sampling = 1; - region = 7; - etaBin = (int) ( (eta-3.2) * oneOverDeta ); - if(etaBin < 0) etaBin = 0; - } else if (fabs(p.z()) < m_par->m_z2BeforeFCal){ - type = 2; - sampling = 0; + if ( eta < 1.7 ) { + sampling = 2; region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); + etaBin = (int) ( (eta-1.) * oneOverDeta ); } else { + sampling = 3; + region = 0; + etaBin = (int) ( (eta-1.7) * oneOverDeta ); + } + }else if ( copy == 27 && name == volCylinderMixed ) { + // case 4 // wall between HEC and FCAL + // volumeName "LAr::Endcap::Cryostat::Cylinder::Mixed" + // copy number 27 + subdet = ( p.z() > 0.) ? 4 : -4; + if ( fabs(p.z()) < m_par->m_startZFCal1 ) { type = 2; sampling = 1; region = 5; etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } - if(etaBin < 0) etaBin = 0; // FcalNose can be a litle bit further than 3.2 - } else if ( eta < 8.0 ) { - sampling = 3; - region = 1; - etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); - } else { - sampling = 3; - region = 2; - etaBin = 0; - phiBin = 0; - } - }else if ( ( copy == 6 || copy == 7 || copy == 16 || copy == 33 ) && name == volCylinderMixed ) { - // case 6 // walls close to beam-pipe - // volumeName "LAr::Endcap::Cryostat::Cylinder::Mixed" - // copy number 6, 7, 16, 29, 33 - subdet = ( p.z() > 0.) ? 4 : -4; - type = 1; - if ( eta < 5.0 ) { - if(fabs(p.z()) < m_par->m_z1BeforeFCal) { - type = 1; + } else if ( fabs(p.z()) < m_par->m_startZFCal2 ) { + type = 2; sampling = 1; - region = 7; - etaBin = (int) ( (eta-3.2) * oneOverDeta ); - if(etaBin < 0) etaBin = 0; - } else if (fabs(p.z()) < m_par->m_z2BeforeFCal){ + region = 4; + etaBin = 0; + } else if ( fabs(p.z()) < m_par->m_startZFCal3 ) { // type = 2; - sampling = 0; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); - } else { + sampling = 2; + region = 4; + etaBin = 0; + } else if ( fabs(p.z()) < m_par->m_endZFCal3 ) { // type = 2; - sampling = 1; - region = 5; - etaBin = (int) ( (eta-3.0) * oneOverDeta ); + sampling = 3; + region = 4; + etaBin = 0; + } else{ // leakage behind FCAL+HEC + type = 1; + sampling = 3; + region = 0; + etaBin = (int) ( (eta-1.7) * oneOverDeta ); + } + } else if ( copy==1 && name == volConeMixed) { + // case 6 // walls close to beam-pipe + // volumeName "LAr::Endcap::Cryostat::Cone::Mixed" + // copy number 6, 7, 16, 29, 33 + subdet = ( p.z() > 0.) ? 4 : -4; + type = 1; + if ( eta < 5.0 ) { + if(fabs(p.z()) < m_par->m_z1BeforeFCal) { + type = 1; + sampling = 1; + region = 7; + etaBin = (int) ( (eta-3.2) * oneOverDeta ); + if(etaBin < 0) etaBin = 0; + } else if (fabs(p.z()) < m_par->m_z2BeforeFCal){ + type = 2; + sampling = 0; + region = 5; + etaBin = (int) ( (eta-3.0) * oneOverDeta ); + } else { + type = 2; + sampling = 1; + region = 5; + etaBin = (int) ( (eta-3.0) * oneOverDeta ); + } + if(etaBin < 0) etaBin = 0; // FcalNose can be a litle bit further than 3.2 + } else if ( eta < 8.0 ) { + sampling = 3; + region = 1; + etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); + } else { + sampling = 3; + region = 2; + etaBin = 0; + phiBin = 0; + } + }else if ( ( copy == 6 || copy == 7 || copy == 16 || copy == 33 ) && name == volCylinderMixed ) { + // case 6 // walls close to beam-pipe + // volumeName "LAr::Endcap::Cryostat::Cylinder::Mixed" + // copy number 6, 7, 16, 29, 33 + subdet = ( p.z() > 0.) ? 4 : -4; + type = 1; + if ( eta < 5.0 ) { + if(fabs(p.z()) < m_par->m_z1BeforeFCal) { + type = 1; + sampling = 1; + region = 7; + etaBin = (int) ( (eta-3.2) * oneOverDeta ); + if(etaBin < 0) etaBin = 0; + } else if (fabs(p.z()) < m_par->m_z2BeforeFCal){ + type = 2; + sampling = 0; + region = 5; + etaBin = (int) ( (eta-3.0) * oneOverDeta ); + } else { + type = 2; + sampling = 1; + region = 5; + etaBin = (int) ( (eta-3.0) * oneOverDeta ); + } + } else if ( eta < 8.0 ) { + sampling = 3; + region = 1; + etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); + } else { + sampling = 3; + region = 2; + etaBin = 0; + phiBin = 0; } - } else if ( eta < 8.0 ) { - sampling = 3; - region = 1; - etaBin = (int) ( (eta-5.)* 0.5 * oneOverDeta ); - } else { - sampling = 3; - region = 2; - etaBin = 0; - phiBin = 0; } } - } - - // What if we have a G4Step that isn't handled by the above - // code? Answer: Use a "backup" calculator to try to - // process the step. - if ( type == INT_MIN || - region == INT_MIN || - sampling == INT_MIN || - etaBin == INT_MIN || - phiBin < 0 || etaBin < 0) - { -// g.p. 09/05/2006 + // What if we have a G4Step that isn't handled by the above + // code? Answer: Use a "backup" calculator to try to + // process the step. + + if ( type == INT_MIN || + region == INT_MIN || + sampling == INT_MIN || + etaBin == INT_MIN || + phiBin < 0 || etaBin < 0) + { + // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/CryostatCalibrationMixedCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/CryostatCalibrationMixedCalculator",_identifier,a_step); #endif #if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) - static const G4int messageMax = 1000; - static G4int messageCount = 0; - if ( messageCount++ < messageMax ) { - std::cout << "LArG4::EndcapCryostat::CalibrationMixedCalculator::Process" - << " (error " << messageCount << " of " << messageMax << " max displayed)" - << std::endl - << " G4Step in '" - << name - << "' copy=" - << copy - << ", using backup calculator" - << std::endl; - std::cout << " type:" << type - << " region:" << region - << " sampling:" << sampling - << " etaBin:" << etaBin - << " phiBin:" << phiBin - << " xyz:"<<p.x()<<", "<<p.y()<<", "<<p.z() - << " eta:"<< eta - <<std::endl; - } + static const G4int messageMax = 1000; + static G4int messageCount = 0; // exists only if debug activated + if ( messageCount++ < messageMax ) { + std::cout << "LArG4::EndcapCryostat::CalibrationMixedCalculator::Process" + << " (error " << messageCount << " of " << messageMax << " max displayed)" + << std::endl + << " G4Step in '" + << name + << "' copy=" + << copy + << ", using backup calculator" + << std::endl; + std::cout << " type:" << type + << " region:" << region + << " sampling:" << sampling + << " etaBin:" << etaBin + << " phiBin:" << phiBin + << " xyz:"<<p.x()<<", "<<p.y()<<", "<<p.z() + << " eta:"<< eta + <<std::endl; + } #endif - m_backupCalculator->Process(a_step, kOnlyID); - m_identifier = m_backupCalculator->identifier(); - } else { - // Append the cell ID to the (empty) identifier. - m_identifier << 10 // Calorimeter - << subdet // LAr +/-4 where "+" or " -" according to the sign of Z in World coorinate - << type - << sampling - << region - << etaBin - << phiBin; - } - } // if a_process == kEnergyAndID || a_process == kOnlyID + //m_backupCalculator->Process(a_step, kOnlyID); + //_identifier = m_backupCalculator->identifier(); + std::vector<G4double> _tmpv; + m_backupCalculator->Process(a_step, _identifier, _tmpv, kOnlyID); + } else { + // Append the cell ID to the (empty) identifier. + _identifier << 10 // Calorimeter + << subdet // LAr +/-4 where "+" or " -" according to the sign of Z in World coorinate + << type + << sampling + << region + << etaBin + << phiBin; + } + } // if a_process == kEnergyAndID || a_process == kOnlyID #ifdef DEBUG_HITS -// G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); + // G4double energy = accumulate(_energies.begin(),_energies.end(),0.); std::cout << "LArG4::EndcapCryostat::CalibrationMixedCalculator::Process" - << " ID=" << std::string(m_identifier) -// << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + << " ID=" << std::string(_identifier) + // << " energy=" << energy + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")" + << std::endl; #endif -// g.p. 09/05/2006 + // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/CryostatCalibrationMixedCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/CryostatCalibrationMixedCalculator",_identifier,a_step); #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) return false; + if ( _identifier == LArG4Identifier() ) return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationMixedCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.h similarity index 73% rename from LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationMixedCalculator.h rename to LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.h index ed243e00a244..fc3854b0955d 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/CryostatCalibrationMixedCalculator.h +++ b/LArCalorimeter/LArG4/LArG4EC/src/CryostatCalibrationMixedCalculator.h @@ -6,7 +6,7 @@ // Prepared 13-Aug-2004 Bill Seligman // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -21,7 +21,7 @@ #ifndef LArG4_EndcapCryostat_CalibrationMixedCalculator_H #define LArG4_EndcapCryostat_CalibrationMixedCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" #include "globals.hh" @@ -39,12 +39,13 @@ namespace LArG4 { namespace EndcapCryostat { - class CalibrationMixedCalculator : public VCalibrationCalculator { + class CalibrationMixedCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationMixedCalculator(); + + CalibrationMixedCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~CalibrationMixedCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -56,22 +57,12 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; @@ -79,7 +70,7 @@ namespace LArG4 { Parameters *m_par; // Define a "backup" calculator. - static VCalibrationCalculator* m_backupCalculator; + ServiceHandle<ILArCalibCalculatorSvc> m_backupCalculator; CalibrationMixedCalculator (const CalibrationMixedCalculator&); CalibrationMixedCalculator& operator= (const CalibrationMixedCalculator&); diff --git a/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc index 0af1783c1ea4..2c45b11feff3 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.cc @@ -11,17 +11,12 @@ // simulation. #undef DEBUG_HITS -#define DEBUG_VOLUMES +#undef DEBUG_VOLUMES #undef DEBUG_DMXYZ -#include "LArG4EC/EMECSupportCalibrationCalculator.h" -#ifdef DEBUG_DMXYZ -#include "LArG4Code/CalibrationDefaultCalculator.h" -#endif -#include "LArG4EC/CryostatCalibrationLArCalculator.h" +#include "EMECSupportCalibrationCalculator.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" // direct access to database #include "RDBAccessSvc/IRDBAccessSvc.h" @@ -31,6 +26,7 @@ #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/Units.h" #include "globals.hh" #include "G4Step.hh" @@ -43,9 +39,11 @@ #include <cmath> #include <climits> -namespace LArG4 { - VCalibrationCalculator* EMECSupportCalibrationCalculator::m_backupCalculator = 0; +namespace Units = Athena::Units; + + +namespace LArG4 { /////////////////////////////////////////////////////////// // Local class to store detector parameters for calculator @@ -168,39 +166,48 @@ namespace LArG4 { // Methods /////////////////////////////////////////////////////////// - EMECSupportCalibrationCalculator::EMECSupportCalibrationCalculator() : m_par(new Parameters()), - m_parameters(0) + EMECSupportCalibrationCalculator::EMECSupportCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_par(nullptr) + , m_backupCalculator("EndcapCryostatCalibrationLArCalculator",name) { - // Get a "backup" calculator. - if ( m_backupCalculator == 0) - m_backupCalculator = new EndcapCryostat::CalibrationLArCalculator(); + declareProperty("BackupCalculator",m_backupCalculator); + } + + StatusCode EMECSupportCalibrationCalculator::initialize() { + ATH_CHECK(m_backupCalculator.retrieve()); + m_par = new Parameters(); + return StatusCode::SUCCESS; } EMECSupportCalibrationCalculator::~EMECSupportCalibrationCalculator() { // Cleanup pointers. - delete m_backupCalculator; - m_backupCalculator = 0; + //delete m_backupCalculator; + //m_backupCalculator = 0; delete m_par; } - G4bool EMECSupportCalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) + G4bool EMECSupportCalibrationCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const { // Use the calculators to determine the energies and the // identifier associated with this G4Step. Note that the // default is to process both the energy and the ID. - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) { - m_energyCalculator.Energies( a_step, m_energies ); + _energies.reserve(4); + _energies.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyEnergy ) { + m_energyCalculator.Energies( a_step, _energies ); } else { - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) _energies.push_back( 0. ); } - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) + _identifier.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyID ) { static const double oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. static const double oneOverDphi = 32./M_PI; // 1/Dphi @@ -233,15 +240,18 @@ namespace LArG4 { if(name.index("LArMgr::") == 0) name.erase(0,8); +#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) + // The 'copy' variable is used only inside defines G4int copy = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); +#endif #ifdef DEBUG_HITS std::cout << "LArG4::EMECSupportCalibrationCalculator::Process" << " G4Step in '" << name << "' copy=" << copy << " or G4Step in LAr at : (x,y,z) [mm] = (" - << p.x()/CLHEP::mm << "," - << p.y()/CLHEP::mm << "," - << p.z()/CLHEP::mm + << p.x()/Units::mm << "," + << p.y()/Units::mm << "," + << p.z()/Units::mm << "); eta=" << eta << ", phi=" << phi << std::endl; #endif @@ -449,7 +459,7 @@ namespace LArG4 { { // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/EMECSupportCalibrationCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("UNEXP LArG4EC/EMECSupportCalibrationCalculator",_identifier,a_step); #endif #if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) static const G4int messageMax = 1000; @@ -463,20 +473,22 @@ namespace LArG4 { << "' copy=" << copy << " or G4Step in LAr at unexpected place: (x,y,z) [mm] = (" - << p.x()/CLHEP::mm << "," - << p.y()/CLHEP::mm << "," - << p.z()/CLHEP::mm + << p.x()/Units::mm << "," + << p.y()/Units::mm << "," + << p.z()/Units::mm << "); eta=" << eta << ", phi=" << phi << std::endl << ", using backup calculator" << std::endl; } #endif - m_backupCalculator->Process(a_step, kOnlyID); - m_identifier = m_backupCalculator->identifier(); + //m_backupCalculator->Process(a_step, kOnlyID); + //_identifier = m_backupCalculator->identifier(); + std::vector<G4double> _tmpv; + m_backupCalculator->Process(a_step, _identifier, _tmpv, kOnlyID); } else { // Append the cell ID to the (empty) identifier. - m_identifier << 10 // Calorimeter + _identifier << 10 // Calorimeter << subdet // LAr +/-4 where "+" or " -" according to the sign of Z in World coorinate << type << sampling @@ -484,26 +496,26 @@ namespace LArG4 { << etaBin << phiBin; } - } + } // end of if ( a_process == kEnergyAndID || a_process == kOnlyID ) #ifdef DEBUG_HITS -// G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); +// G4double energy = accumulate(_energies.begin(),_energies.end(),0.); std::cout << "LArG4::EMECSupportCalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) + << " ID=" << std::string(_identifier) // << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")" << std::endl; #endif // g.p. 09/05/2006 #ifdef DEBUG_DMXYZ - LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/EMECSupportCalibrationCalculator",m_identifier,a_step); + LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4EC/EMECSupportCalibrationCalculator",_identifier,a_step); #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) return false; + if ( _identifier == LArG4Identifier() ) return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/EMECSupportCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.h similarity index 69% rename from LArCalorimeter/LArG4/LArG4EC/LArG4EC/EMECSupportCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.h index 7bd82d916875..211e39f9f87b 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/EMECSupportCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4EC/src/EMECSupportCalibrationCalculator.h @@ -16,10 +16,10 @@ #ifndef LArG4_EMECSupport_CalibrationCalculator_H #define LArG4_EMECSupport_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "LArGeoCode/VDetectorParameters.h" -#include "LArG4EC/CryostatCalibrationLArCalculator.h" +#include "CryostatCalibrationLArCalculator.h" #include "CaloG4Sim/SimulationEnergies.h" #include "globals.hh" @@ -35,10 +35,11 @@ namespace LArG4 { // namespace EMECSupport { - class EMECSupportCalibrationCalculator : public VCalibrationCalculator { + class EMECSupportCalibrationCalculator : public LArCalibCalculatorSvcImp { public: - EMECSupportCalibrationCalculator(); + EMECSupportCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~EMECSupportCalibrationCalculator(); // The Process method returns a boolean value. If it's true, the @@ -52,33 +53,23 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; class Parameters; - Parameters *m_par; + const Parameters *m_par; // Access to parameters. - LArGeo::VDetectorParameters* m_parameters; + //LArGeo::VDetectorParameters* m_parameters; // Define a "backup" calculator. - static VCalibrationCalculator* m_backupCalculator; + ServiceHandle<ILArCalibCalculatorSvc> m_backupCalculator; EMECSupportCalibrationCalculator (const EMECSupportCalibrationCalculator&); EMECSupportCalibrationCalculator& operator= (const EMECSupportCalibrationCalculator&); diff --git a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc index cc8fe448c5e2..00644ef09233 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.cc @@ -59,9 +59,7 @@ #include "globals.hh" #include "LArG4Code/LArG4BirksLaw.h" -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4RunControl/LArG4EMECOptions.h" -#include "LArG4RunControl/LArG4GlobalOptions.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" #include "LArHV/LArHVManager.h" #include "LArHV/EMECHVManager.h" @@ -71,87 +69,85 @@ #include "LArHV/EMECHVElectrodeConstLink.h" #include "LArHV/EMECHVDescriptor.h" -#include "LArG4EC/EMECSupportCalibrationCalculator.h" -#include "LArG4EC/EnergyCalculator.h" +//#include "EMECSupportCalibrationCalculator.h" +#include "EnergyCalculator.h" +#include "AthenaKernel/Units.h" #define MSG_VECTOR(v) "(" << v.x() << ", " << v.y() << ", " << v.z() << ")" using namespace LArG4::EC; - -// **************************************************************************** -EnergyCalculator::Wheel_Efield_Map EnergyCalculator::ChCollInner; -EnergyCalculator::Wheel_Efield_Map EnergyCalculator::ChCollOuter; - -const G4double EnergyCalculator::GridSize =0.1; //[mm] -const G4double EnergyCalculator::AverageGap = 1.3*CLHEP::mm; - G4bool EnergyCalculator::FieldMapsRead =false; - G4String EnergyCalculator::FieldMapVersion = ""; -// **************************************************************************** -const G4String EnergyCalculator::HVEMECMapFileName="/afs/cern.ch/atlas/offline/data/lar/emec/efield/HVEMECMap.dat"; - G4bool EnergyCalculator::HVMapRead=false; - G4String EnergyCalculator::HVMapVersion="unknown"; -const G4double EnergyCalculator::HV_Etalim[NofEtaSection+1]= - {1.375,1.5,1.6,1.8,2.,2.1,2.3,2.5,2.8,3.2}; -const G4double EnergyCalculator::LArTemperature_ECC0=88.15; //K -const G4double EnergyCalculator::LArTemperature_ECC1=88.37; -const G4double EnergyCalculator::LArTemperature_ECC5=87.97; -const G4double EnergyCalculator::LArTemperature_av =88.16; - G4int EnergyCalculator::HV_Start_phi[NofAtlasSide][NofEtaSection][NofElectrodeSide]; - G4double EnergyCalculator::HV_Values[NofAtlasSide][NofEtaSection][NofElectrodeSide][NofElectrodesOut]; -const G4double EnergyCalculator::AverageHV=1250.;//[V] -const G4double EnergyCalculator::AverageEfield=0.01*AverageHV/AverageGap;//[kv/cm] -const G4double EnergyCalculator::AverageCurrent=1./AverageGap*IonReco(AverageEfield) - *DriftVelo(LArTemperature_av,AverageEfield); -// **************************************************************************** - G4double EnergyCalculator::CHC_Esr =0.2*CLHEP::mm; //[mm] - G4int EnergyCalculator::CHCIprint=0; - G4double EnergyCalculator::CHCEbad =0.; - G4double EnergyCalculator::CHCEtotal=0.; - G4double EnergyCalculator::CHCStotal=0.; +namespace Units = Athena::Units; + +// **************************************************************************** +EnergyCalculator::Wheel_Efield_Map EnergyCalculator::s_ChCollInner; +EnergyCalculator::Wheel_Efield_Map EnergyCalculator::s_ChCollOuter; + +const G4double EnergyCalculator::s_GridSize =0.1; //[mm] +const G4double EnergyCalculator::s_AverageGap = 1.3*CLHEP::mm; +G4bool EnergyCalculator::s_FieldMapsRead =false; +G4String EnergyCalculator::s_FieldMapVersion = ""; +// **************************************************************************** +const G4String EnergyCalculator::s_HVEMECMapFileName="/afs/cern.ch/atlas/offline/data/lar/emec/efield/HVEMECMap.dat"; +G4bool EnergyCalculator::s_HVMapRead=false; +const G4double EnergyCalculator::s_HV_Etalim[s_NofEtaSection+1]= + {1.375,1.5,1.6,1.8,2.,2.1,2.3,2.5,2.8,3.2}; +const G4double EnergyCalculator::s_LArTemperature_ECC0=88.15; //K +const G4double EnergyCalculator::s_LArTemperature_ECC1=88.37; +const G4double EnergyCalculator::s_LArTemperature_ECC5=87.97; +const G4double EnergyCalculator::s_LArTemperature_av =88.16; +G4int EnergyCalculator::s_HV_Start_phi[s_NofAtlasSide][s_NofEtaSection][s_NofElectrodeSide]; +G4double EnergyCalculator::s_HV_Values[s_NofAtlasSide][s_NofEtaSection][s_NofElectrodeSide][s_NofElectrodesOut]; +const G4double EnergyCalculator::s_AverageHV=1250.;//[V] +const G4double EnergyCalculator::s_AverageEfield=0.01*s_AverageHV/s_AverageGap;//[kv/cm] +const G4double EnergyCalculator::s_AverageCurrent=1./s_AverageGap*IonReco(s_AverageEfield) + *DriftVelo(s_LArTemperature_av,s_AverageEfield); +// **************************************************************************** +// G4double EnergyCalculator::s_CHC_Esr =0.2*CLHEP::mm; //[mm] +#ifdef DEBUG_CHCL +G4int EnergyCalculator::s_CHCIprint=0; +G4double EnergyCalculator::s_CHCEbad =0.; +G4double EnergyCalculator::s_CHCEtotal=0.; +G4double EnergyCalculator::s_CHCStotal=0.; +#endif // **************************************************************************** -const G4double EnergyCalculator::ColdCorrection = 1.0036256; -const G4double EnergyCalculator::LongBarThickness = 20.*CLHEP::mm; -const G4double EnergyCalculator::StripWidth = 3.*CLHEP::mm/ColdCorrection; -const G4double EnergyCalculator::KapGap = 1.*CLHEP::mm/ColdCorrection; -const G4double EnergyCalculator::EdgeWidth = 1.*CLHEP::mm; -const G4double EnergyCalculator::DistOfEndofCuFromBack = 22.77*CLHEP::mm/ColdCorrection; -const G4double EnergyCalculator::DistOfStartofCuFromBack= 31.*CLHEP::mm; // frontface of the barrette -const G4double EnergyCalculator::ZmaxOfSignal = DistOfStartofCuFromBack - - DistOfEndofCuFromBack + EdgeWidth; -G4double EnergyCalculator::RefzDist = 0.; -G4bool EnergyCalculator::SetConstOuterBarrett = false; -G4bool EnergyCalculator::SetConstInnerBarrett = false; - -const G4double EnergyCalculator::S3_Etalim[21]={ - 1.50, 1.55, 1.60, 1.65, 1.70, 1.75, 1.80, 1.85, 1.90, 1.95, - 2.00, 2.05, 2.10, 2.15, 2.20, 2.25, 2.30, 2.35, 2.40, 2.45, 2.5 +const G4double EnergyCalculator::s_ColdCorrection = 1.0036256; +const G4double EnergyCalculator::s_LongBarThickness = 20.*CLHEP::mm; +const G4double EnergyCalculator::s_StripWidth = 3.*CLHEP::mm/s_ColdCorrection; +const G4double EnergyCalculator::s_KapGap = 1.*CLHEP::mm/s_ColdCorrection; +const G4double EnergyCalculator::s_EdgeWidth = 1.*CLHEP::mm; +const G4double EnergyCalculator::s_DistOfEndofCuFromBack = 22.77*CLHEP::mm/s_ColdCorrection; +const G4double EnergyCalculator::s_DistOfStartofCuFromBack= 31.*CLHEP::mm; // frontface of the barrette +const G4double EnergyCalculator::s_ZmaxOfSignal = s_DistOfStartofCuFromBack + - s_DistOfEndofCuFromBack + s_EdgeWidth; +G4double EnergyCalculator::s_RefzDist = 0.; +G4bool EnergyCalculator::s_SetConstOuterBarrett = false; +G4bool EnergyCalculator::s_SetConstInnerBarrett = false; + +const G4double EnergyCalculator::s_S3_Etalim[21]={ + 1.50, 1.55, 1.60, 1.65, 1.70, 1.75, 1.80, 1.85, 1.90, 1.95, + 2.00, 2.05, 2.10, 2.15, 2.20, 2.25, 2.30, 2.35, 2.40, 2.45, 2.5 }; -const G4double EnergyCalculator::Rmeas_outer[50]={ +const G4double EnergyCalculator::s_Rmeas_outer[50]={ 11.59, 25.22, 57.28, 71.30, 85.90, 98.94, 103.09, 116.68, 130.42, 146.27, - 147.19, 11.59, 15., 56.91, 44.37, 15.13, 14.93, 45.87, 35.03, 15.40, + 147.19, 11.59, 15., 56.91, 44.37, 15.13, 14.93, 45.87, 35.03, 15.40, 14.04, 39.67, 26.83, 15.64, 14.90, 30.26, 14.70, 29.09, 43.12, 34.51, 25.08, 11.88, 14.39, 19.54, 17.80, 12.70, 15.31, 13.96, 11.79, -99., 23.57, 34.64, 55.32, 65.39, 76.34, 10.83, 94.84, 98.00, -99., -99. }; -const G4double EnergyCalculator::Zmeas_outer[2]={3.81, 7.81}; - - G4double EnergyCalculator::S3_Rlim[21]; - G4double EnergyCalculator::rlim[50]; - G4double EnergyCalculator::zlim[4]; - G4int EnergyCalculator::ModuleNumber; - G4int EnergyCalculator::PhiDivNumber; - G4double EnergyCalculator::PhiStartOfPhiDiv; +const G4double EnergyCalculator::s_Zmeas_outer[2]={3.81, 7.81}; -LArG4::VCalibrationCalculator* EnergyCalculator::m_supportCalculator=0; +G4double EnergyCalculator::s_S3_Rlim[21]; +G4double EnergyCalculator::s_rlim[50]; +G4double EnergyCalculator::s_zlim[4]; // **************************************************************************** static const G4String - ECorr_t_option = "type", - CHC_Map_option = "chcmap", - CHC_Esr_option = "chcesr", - GApower_option = "gapower"; +ECorr_t_option = "type", + CHC_Map_option = "chcmap", + CHC_Esr_option = "chcesr", + GApower_option = "gapower"; static G4double zsep12[44]; // used as const after initialization static G4double ziw[7]; // used as const after initialization @@ -162,640 +158,644 @@ static G4double zsep23[22]; // used as const after initialization s tatic G4String extract_option(G4String &options, G4String option) // Depracated? DM, 29 Jul 2015 // **************************************************************************** { - size_t l = options.length(); - size_t p1 = options.find(option); - if(p1 < l){ - size_t p2 = options.find("=", p1); - p2 ++; - if(p2 < l){ - size_t p3 = options.find(" ", p2); - if(p3 > l) p3 = l; - return options.substr(p2, p3 - p2); - } - } - return ""; + size_t l = options.length(); + size_t p1 = options.find(option); + if(p1 < l){ + size_t p2 = options.find("=", p1); + p2 ++; + if(p2 < l){ + size_t p3 = options.find(" ", p2); + if(p3 > l) p3 = l; + return options.substr(p2, p3 - p2); + } + } + return ""; } #endif // **************************************************************************** static inline G4double DistanceToEtaLine(const G4ThreeVector &p, G4double eta) { - G4double sinTheta = 2. * exp(-eta) / (1. + exp(2. * -eta)); - G4double cosTheta = (1. - exp(2. * -eta)) / (1. + exp(2. * -eta)); - return p.perp() * cosTheta - p.z() * sinTheta; + G4double sinTheta = 2. * exp(-eta) / (1. + exp(2. * -eta)); + G4double cosTheta = (1. - exp(2. * -eta)) / (1. + exp(2. * -eta)); + return p.perp() * cosTheta - p.z() * sinTheta; } -// **************************************************************************** -//void EnergyCalculator::vector_to_msg(G4ThreeVector &v) const -// **************************************************************************** -//{ -// (*m_msg) << "(" << v.x() << ", " << v.y() << ", " << v.z() << ")"; -//} +template<typename T, typename R, typename ...Args, typename ReturnType = R (T::*)(Args...)> +ReturnType remove_const(R (T::*Func)(Args...) const) { + return reinterpret_cast<ReturnType>(Func); +} // **************************************************************************** -G4bool EnergyCalculator::Process(const G4Step* step, std::vector<LArHitData>& hdata){ -// **************************************************************************** +G4bool EnergyCalculator::Process(const G4Step* step, std::vector<LArHitData>& hdata) const { + // **************************************************************************** // make sure hdata is reset - hdata.resize(1); - return (this->*Process_type)(step, hdata); + hdata.resize(1); + return (this->*m_Process_type)(step, hdata); } // **************************************************************************** +StatusCode EnergyCalculator::finalize() { + if(m_birksLaw) { + delete m_birksLaw; + m_birksLaw = nullptr; + } + delete m_lwc; + m_lwc = nullptr; + return StatusCode::SUCCESS; +} + // **************************************************************************** -G4bool EnergyCalculator::FindIdentifier( - const G4Step* step, - std::vector<LArHitData>& hdata, - G4ThreeVector &startPointLocal, - G4ThreeVector &endPointLocal - ){ +G4bool EnergyCalculator::Process_Default(const G4Step* step, std::vector<LArHitData>& hdata) const // **************************************************************************** +{ + G4ThreeVector startPointinLocal, endPointinLocal; + if(!FindIdentifier_Default(step, hdata, startPointinLocal, endPointinLocal)){ + return false; + } - return (this->*FindIdentifier_type) (step,hdata,startPointLocal,endPointLocal); + G4double E = step->GetTotalEnergyDeposit(); + if (m_birksLaw) { + const G4ThreeVector midpoint = (startPointinLocal + endPointinLocal) * 0.5; + const G4double wholeStepLengthCm = step->GetStepLength() / CLHEP::cm; + const G4double gap = (this->*m_GetGapSize_type)(midpoint); // const method + const G4double efield = 0.01 * (this->*m_GetHV_Value_type)(midpoint, 0.123456) / gap; // estimate Efield[KV/cm] + // 0.123456 is arbitrary number. This value is not used for this type of process + E = (*m_birksLaw)(E, wholeStepLengthCm, efield); + } + + hdata[0].energy = (this->*m_ecorr_method)(E, startPointinLocal, endPointinLocal, 0.654321); + // 0.654321 is arbitrary number. This value is not used for this type of process. + return true; } -// **************************************************************************** -EnergyCalculator::~EnergyCalculator() { - if(birksLaw) { - delete birksLaw; - birksLaw = 0; +G4double EnergyCalculator::getPhiStartOfPhiDiv(const G4Step* step) const { + // --- moved from FindIdentifier_Barrett --- // + // get Module and Phidiv number (result is put into VolumeNumber and PhiDivNumber) + G4int ModuleNumber = -999; + G4int PhiDivNumber = -999; + + G4bool validhit = GetVolumeIndex(step, ModuleNumber, PhiDivNumber); + if (!validhit) { + ATH_MSG_FATAL(" ERROR ::Process_Barrett::Module, Phidiv is not found" + <<" ModuleNumber= "<<ModuleNumber<<" PhiDivNumber= "<<PhiDivNumber); } - delete m_lwc; - m_lwc = 0; + + if(lwc()->type() == LArG4::OuterAbsorberWheel){ // for wheel calculation + //PhiStartOfPhiDiv = + return lwc()->GetFanStepOnPhi()/2. + ModuleNumber * CLHEP::twopi/8. + + PhiDivNumber * lwc()->GetFanStepOnPhi(); + //phi_inb = PhiStartOfPhiDiv + pinLocal.phi(); //in ::BackOuterBarrettes + //if(phi_inb < 0.) phi_inb = phi_inb + CLHEP::twopi; + //if(phi_inb > CLHEP::twopi) phi_inb = phi_inb - CLHEP::twopi; + //phi_inb = CLHEP::twopi - phi_inb; // phi in ::EmecMother system; + } + + if(lwc()->type() == LArG4::OuterAbsorberModule){ // for TB modul calculation + + // M_PI_2 - M_PI/8. is from EMECSupportConstruction + // PhiStartOfPhiDiv = + return M_PI_2 - M_PI/8. + lwc()->GetFanStepOnPhi()/2 + PhiDivNumber * lwc()->GetFanStepOnPhi(); + + //phi_inb = PhiStartOfPhiDiv + pinLocal.phi(); //in BackOuterBarrettes; + //phi_inb = M_PI - phi_inb; // phi in ::EmecMother system; + } + // --- moved from FindIdentifier_Barrett --- // + ATH_MSG_ERROR(" ERROR ::Process_Barrett::getPhiStartOfPhiDiv, LArWheelType is unknown ("<<lwc()->type()<<"), PhiStartOfPhiDiv is set zero!" + <<" ModuleNumber= "<<ModuleNumber<<" PhiDivNumber= "<<PhiDivNumber); + return 0.0; } // **************************************************************************** -G4bool EnergyCalculator::Process_Default(const G4Step* step, std::vector<LArHitData>& hdata) +G4bool EnergyCalculator::Process_Barrett(const G4Step* step, std::vector<LArHitData>& hdata) const{ + // **************************************************************************** + const G4double PhiStartOfPhiDiv = getPhiStartOfPhiDiv(step); + G4ThreeVector startPointinLocal, endPointinLocal; + if(!FindIdentifier_Barrett(step, PhiStartOfPhiDiv, hdata, startPointinLocal, endPointinLocal)){ + //cell id is not found + if(!lwc()->GetisBarretteCalib()) return false; // ==> normal calculator return false + else{ // if Calibration Calculator for Barrett: + // compute DM identifier; + // In calibration calculator mode this process is used as "geometry calculator". + // We have to be prepared to return + // either the emec cell id or , if the hit does not belong to any cell, + // the DeadMatter (DM) id. + // DM identifier for Barrett is defined + // by the EmecSupportCalibrationCalculator.( In general it is + // activated by the atlas_calo.py) + const G4bool status=FindDMIdentifier_Barrett(step, hdata); + if(!status) + ATH_MSG_WARNING(" WARNING!!EnergyCalculator::Process_Barrett:" + << " DM identifier not found????"); + return status; + } // end of calibr. calculator + } // end if cell id not found + // compute signal in 'normal' calculator mode, if cellid is found + G4double E = step->GetTotalEnergyDeposit(); + if (m_birksLaw){ + const G4ThreeVector midpoint = (startPointinLocal + endPointinLocal) * 0.5; + const G4double wholeStepLengthCm = step->GetStepLength() / CLHEP::cm; + const G4double gap = (this->*m_GetGapSize_type)(midpoint); // const method + const G4double efield = 0.01 * (this->*m_GetHV_Value_type)(midpoint, PhiStartOfPhiDiv) / gap; // estimate Efield[KV/cm] + E = (*m_birksLaw)(E, wholeStepLengthCm, efield); + } + + hdata[0].energy = (this->*m_ecorr_method)(E, startPointinLocal, endPointinLocal, PhiStartOfPhiDiv); + return true; +} // **************************************************************************** +EnergyCalculator::EnergyCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_supportCalculator("EMECSupportCalibrationCalculator",name) + , m_corrProp(8) + , m_correction_type(EMEC_ECOR_CHCL1) + // PhiGapNumber(0), + // PhiHalfGapNumber(0), + // HalfWaveNumber(0), + // SignofZinHalfWave(0), + // SignofSlopeofHalfWave(0), + // SinPhiGap(0), + // CosPhiGap(0), + // ZinHalfWave(0), + // HalfEleThickness(0), + // ChCollWheelType(0), + // ChCollFoldType(0), + // PointFoldMapArea(0), + // calculatorPhiGap(0), + // chcollPhiGap(0), + , m_solidtypeProp(0) + , m_solidtype(LArG4::InnerAbsorberWheel) + , m_zside(1) + , m_birksLaw(nullptr) + , m_lwc(nullptr) + // **************************************************************************** { - G4ThreeVector startPointinLocal, endPointinLocal; - if(!FindIdentifier_Default(step, hdata, startPointinLocal, endPointinLocal)){ - return false; - } - - G4double E = step->GetTotalEnergyDeposit(); - if (birksLaw) { - const G4ThreeVector midpoint = (startPointinLocal + endPointinLocal) * 0.5; - const G4double wholeStepLengthCm = step->GetStepLength() / CLHEP::cm; - const G4double gap = (this->*GetGapSize_type)(midpoint); - const G4double efield = 0.01 * (this->*GetHV_Value_type)(midpoint) / gap; // estimate Efield[KV/cm] - E = (*birksLaw)(E, wholeStepLengthCm,efield); - } - - hdata[0].energy = (this->*ecorr_method)(E, startPointinLocal, endPointinLocal); - return true; + ATH_MSG_DEBUG("constructor started"); + + declareProperty("EMECHVEnable",m_DB_HV=false); + // get power of gap in signal calculation + declareProperty("EMECGapPower",m_GApower=1.4); + // pick up surface_suppression_range + declareProperty("EMECEsr",m_CHC_Esr=0.2*CLHEP::mm); + declareProperty("EMECHVMap",m_HVMapVersion="v02"); + declareProperty("EMECChMap", m_suffix="v03"); + + declareProperty("SupportCalculator",m_supportCalculator); + declareProperty("WheelType",m_solidtypeProp); + m_solidtypeProp.declareUpdateHandler(&EnergyCalculator::SolidTypeHandler, this); + declareProperty("EnergyCorrection",m_corrProp); + m_corrProp.declareUpdateHandler(&EnergyCalculator::CorrectionTypeHandler, this); + declareProperty("zSide",m_zside); } -// **************************************************************************** -G4bool EnergyCalculator::Process_Barrett(const G4Step* step, std::vector<LArHitData>& hdata){ -// **************************************************************************** - G4ThreeVector startPointinLocal, endPointinLocal; - if(!FindIdentifier_Barrett(step, hdata, startPointinLocal, endPointinLocal)){ - //cell id is not found - if(!lwc()->GetisBarretteCalib()) return false; // ==> normal calculator return false - else{ // if Calibration Calculator for Barrett: - // compute DM identifier; - // In calibration calculator mode this process is used as "geometry calculator". - // We have to be prepared to return - // either the emec cell id or , if the hit does not belong to any cell, - // the DeadMatter (DM) id. - // DM identifier for Barrett is defined - // by the EmecSupportCalibrationCalculator.( In general it is - // activated by the atlas_calo.py) - const G4bool status=FindDMIdentifier_Barrett(step, hdata); - if(!status) - std::cout<<" WARNING!!EnergyCalculator::Process_Barrett:" - << " DM identifier not found????" - <<std::endl; - return status; - } // end of calibr. calculator - } // end if cell id not found - - // compute signal in 'normal' calculator mode, if cellid is found - G4double E = step->GetTotalEnergyDeposit(); - if (birksLaw){ - const G4ThreeVector midpoint = (startPointinLocal + endPointinLocal) * 0.5; - const G4double wholeStepLengthCm = step->GetStepLength() / CLHEP::cm; - const G4double gap = (this->*GetGapSize_type)(midpoint); - const G4double efield = 0.01 * (this->*GetHV_Value_type)(midpoint) / gap; // estimate Efield[KV/cm] - E = (*birksLaw)(E, wholeStepLengthCm,efield); - } - - hdata[0].energy = (this->*ecorr_method)(E, startPointinLocal, endPointinLocal); - return true; +void EnergyCalculator::CorrectionTypeHandler(Property&) +{ + switch(m_corrProp.value()) + { + case 0: m_correction_type=EMEC_ECOR_ROPT; break; + case 1: m_correction_type=EMEC_ECOR_OFF; break; + case 2: m_correction_type=EMEC_ECOR_GADJ; break; + case 3: m_correction_type=EMEC_ECOR_CHCL; break; + case 4: m_correction_type=EMEC_ECOR_GADJ_OLD; break; + case 5: m_correction_type=EMEC_ECOR_GADJ_E; break; + case 6: m_correction_type=EMEC_ECOR_GADJ_S; break; + case 7: m_correction_type=EMEC_ECOR_GADJ_SE; break; + case 8: m_correction_type=EMEC_ECOR_CHCL1; break; + default: + { + std::ostringstream merr; + merr << + "EnergyCalculator::CorrectionTypeHandler FATAL: invalid EnergyCorrection_t specified " + << m_corrProp.value(); + std::cerr << merr.str() << std::endl; + throw GaudiException(merr.str(), "EnergyCalculator::CorrectionTypeHandler", StatusCode::FAILURE); + } + } } -// **************************************************************************** -EnergyCalculator::EnergyCalculator( - LArWheelCalculator::LArWheelCalculator_t solidtype, - EnergyCorrection_t corr, - G4int zside - ) : - m_correction_type(corr), - PhiGapNumber(0), - PhiHalfGapNumber(0), - HalfWaveNumber(0), - SignofZinHalfWave(0), - SignofSlopeofHalfWave(0), - SinPhiGap(0), - CosPhiGap(0), - ZinHalfWave(0), - HalfEleThickness(0), - ChCollWheelType(0), - ChCollFoldType(0), - PointFoldMapArea(0), - calculatorPhiGap(0), - chcollPhiGap(0), - birksLaw(0), - m_lwc(new LArWheelCalculator(solidtype, zside) ), - m_DB_HV(false) -// **************************************************************************** + +void EnergyCalculator::SolidTypeHandler(Property&) { - ISvcLocator* svcLocator = Gaudi::svcLocator(); - IMessageSvc* msgSvc; - StatusCode status = svcLocator->service("MessageSvc", msgSvc); - if(!status.isFailure()){ - m_msg = new MsgStream(msgSvc, "LArG4::EC::EnergyCalculator"); - } else { - throw std::runtime_error("EnergyCalculator constructor: cannot initialze message service"); - } - (*m_msg) << MSG::DEBUG << "constructor started" << endreq; - - if(lwc()->GetisElectrode()){ - (*m_msg) << MSG::FATAL - << "energy caclculator must be of 'absorber' type," - << " while 'electrode' type is requested." - << endreq; - throw std::runtime_error("wrong type for EnergyCalculator"); - } - - RefzDist = lwc()->GetElecFocaltoWRP() + - lwc()->GetdWRPtoFrontFace() + lwc()->GetWheelThickness() + - lwc()->GetdWRPtoFrontFace() + LongBarThickness - DistOfEndofCuFromBack; - - StoreGateSvc* detStore; - LArG4EMECOptions *emecOptions; - LArG4GlobalOptions *globalOptions; - status = svcLocator->service("DetectorStore", detStore); - - if(status.isSuccess()){ - status = detStore->retrieve(emecOptions, "LArG4EMECOptions"); - if(status.isFailure()){ - throw std::runtime_error("EnergyCalculator: cannot retrieve LArG4EMECOptions"); - } - status = detStore->retrieve(globalOptions, "LArG4GlobalOptions"); - if(status.isFailure()){ - throw std::runtime_error("EnergyCalculator: cannot retrieve LArG4GlobalOptions"); - } - } else { - throw std::runtime_error("EnergyCalculator: cannot initialize StoreGate interface"); - } - - (*m_msg) << MSG::DEBUG << "StoreGate interface is ready" << endreq; - - //m_identifier = LArG4Identifier(); - m_compartment = 0; - //m_time = 0.; - //m_energy = 0.; - m_isInTime = false; - - m_OOTcut = globalOptions->OutOfTimeCut(); - - if(emecOptions->EMECBirksLaw()){ - const double Birks_LAr_density = 1.396; - const double Birks_k = emecOptions->EMECBirksk(); - birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); - } - - m_DB_HV = emecOptions->EMECHVEnable(); - - // Access the GeoModelSvc: - IGeoModelSvc *geoModel; - status = svcLocator->service ("GeoModelSvc",geoModel); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); - } - - // Access the geometry database: - IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); - } - - // Obtain the geometry version information: - - DecodeVersionKey larVersionKey(geoModel, "LAr"); - - pAccessSvc->connect(); - - const IRDBRecordset *emecSamplingSep = - pAccessSvc->getRecordset("EmecSamplingSep", larVersionKey.tag(), larVersionKey.node()); - if (emecSamplingSep->size()==0) { - throw std::runtime_error("Cannot find the EmecSamplingSep Table"); - } - - const IRDBRecordset *emecGeometry = - pAccessSvc->getRecordset("EmecGeometry", larVersionKey.tag(), larVersionKey.node()); - if (emecGeometry->size()==0) { - throw std::runtime_error("Cannot find the EmecGeometry Table"); - } - - pAccessSvc->disconnect(); - - for(int i = 0; i < 7; i ++){ - std::ostringstream A0STR; - A0STR << "_" << i; - const std::string A0 = A0STR.str(); - const std::string colName = "ZIW" + A0; - ziw[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; - // cout<<"i,ziw= "<<i<<" "<<ziw[i]<<endl; - } - for(int i = 0; i < 44; i ++){ - std::ostringstream A0STR; - A0STR << "_" << i; - const std::string A0 = A0STR.str(); - const std::string colName = "ZSEP12" + A0; - zsep12[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; - // cout<<"i,zsep12= "<<i<<" "<<zsep12[i]<<endl; - } - for(int i = 0; i < 22; i ++){ - std::ostringstream A0STR; - A0STR << "_" << i; - const std::string A0 = A0STR.str(); - const std::string colName = "ZSEP23" + A0; - zsep23[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; - // cout<<"i,zsep23= "<<i<<" "<<zsep23[i]<<endl; - } - - ElectrodeFanHalfThickness = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::InnerElectrodWheel); - FanEleThickness = ElectrodeFanHalfThickness * 2.; - FanEleThicknessOld = 0.300*CLHEP::mm; - FanEleFoldRadiusOld = 3.*CLHEP::mm; - FanAbsThickness = lwc()->GetFanHalfThickness() * 2.; - WaveLength = lwc()->GetActiveLength() / lwc()->GetNumberOfWaves(); - - assert(fabs((*emecGeometry)[0]->getDouble("GAP0")*CLHEP::cm - AverageGap) < 0.000001); - -//Barrette treatment - if(lwc()->GetisBarrette()){ - if(lwc()->type() == LArWheelCalculator::OuterAbsorberWheel || lwc()->type() == LArWheelCalculator::OuterAbsorberModule) { - SetConst_OuterBarrett(); - } else{ - if(lwc()->type() == LArWheelCalculator::InnerAbsorberWheel || lwc()->type() == LArWheelCalculator::InnerAbsorberModule ){ - - (*m_msg) << MSG::FATAL - << "EnergyCalculator: " - << "Barrett section is not (yet) prepared for " - << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) - << endreq; - G4ExceptionDescription description; - description << G4String("Process_Barrett: ") + "Barrett section is not (yet) prepared for solidtype=" + - LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()); - G4Exception("EnergyCalculator", "BarretteSectionNotPrepared", FatalException, description); - } - else{ - (*m_msg) << MSG::FATAL - << "EnergyCalculator: " - << "Unknown solidtype:" - << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) - << endreq; - G4ExceptionDescription description; - description << G4String("Process_Barrett: ") + "Unknown solidtype=" + - LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()); - G4Exception("EnergyCalculator", "UnknownSolidType", FatalException, description); - } - } - - Process_type = &EnergyCalculator::Process_Barrett; - FindIdentifier_type = &EnergyCalculator::FindIdentifier_Barrett; - GetHV_Value_type = &EnergyCalculator::GetHV_Value_Barrett; - GetGapSize_type = &EnergyCalculator::GetGapSize_Barrett; - distance_to_the_nearest_electrode_type = - &EnergyCalculator::distance_to_the_nearest_electrode_Barrett; - - if(lwc()->GetisBarretteCalib()) m_supportCalculator= new LArG4::EMECSupportCalibrationCalculator(); - - } else { - Process_type = &EnergyCalculator::Process_Default; - FindIdentifier_type = &EnergyCalculator::FindIdentifier_Default; - GetHV_Value_type = &EnergyCalculator::GetHV_Value_Default; - GetGapSize_type = &EnergyCalculator::GetGapSize_Default; - distance_to_the_nearest_electrode_type = - &EnergyCalculator::distance_to_the_nearest_electrode_Default; - } - -// energy correction type - if(m_correction_type == EMEC_ECOR_ROPT){ - LArG4EMECOptions::ECORRTYPE ecorr = emecOptions->EMECECorrType(); - switch(ecorr){ - case LArG4EMECOptions::GAPADJ: - m_correction_type = EMEC_ECOR_GADJ; break; - case LArG4EMECOptions::CHCOLL: - m_correction_type = EMEC_ECOR_CHCL; break; - case LArG4EMECOptions::GAPOLD: - m_correction_type = EMEC_ECOR_GADJ_OLD; break; - case LArG4EMECOptions::GAP_E: - m_correction_type = EMEC_ECOR_GADJ_E; break; - case LArG4EMECOptions::GAP_S: - m_correction_type = EMEC_ECOR_GADJ_S; break; - case LArG4EMECOptions::GAP_SE: - m_correction_type = EMEC_ECOR_GADJ_SE; break; - case LArG4EMECOptions::NONE: - m_correction_type = EMEC_ECOR_OFF; break; - case LArG4EMECOptions::CHCOLL1: - m_correction_type = EMEC_ECOR_CHCL1; break; - default: - (*m_msg) << MSG::FATAL - << "got from StoreGate ECORRTYPE = " << ecorr - << ", don't know such correction" << endreq; - throw std::runtime_error("EnergyCalculator: \ -Bad ECORRTYPE"); - } - }// end for defining m_correction_type - - switch(m_correction_type){ - case EMEC_ECOR_GADJ: - ecorr_method = &EnergyCalculator::GapAdjustment; - break; - case EMEC_ECOR_CHCL: - ecorr_method = &EnergyCalculator::CalculateChargeCollection; - break; - case EMEC_ECOR_GADJ_OLD: - ecorr_method = &EnergyCalculator::GapAdjustment_old; - break; - case EMEC_ECOR_GADJ_E: - ecorr_method = &EnergyCalculator::GapAdjustment_E; - break; - case EMEC_ECOR_GADJ_S: - ecorr_method = &EnergyCalculator::GapAdjustment_s; - break; - case EMEC_ECOR_GADJ_SE: - ecorr_method = &EnergyCalculator::GapAdjustment__sE; - break; - case EMEC_ECOR_OFF: - ecorr_method = &EnergyCalculator::dummy_correction_method; - break; - case EMEC_ECOR_CHCL1: - if(lwc()->GetisBarrette()){ - ecorr_method = &EnergyCalculator::CalculateChargeCollection; - (*m_msg) << MSG::INFO << "CHCOLL energy correction is user for Barettes" - << " instead of CHCOLL1" << endreq; - } else { - ecorr_method = &EnergyCalculator::CalculateChargeCollection1; - } - break; - default: - (*m_msg) << MSG::FATAL - << "EnergyCalculator: unknown correction type " - << m_correction_type << endreq; - G4Exception("EnergyCalculator", "UnknownCorrectionType", FatalException, - "Process_Barrett: unknown correction type"); - } - -// get power of gap in signal calculation - m_GApower = emecOptions->EMECGapPower(); - -// pick up surface_suppression_range - CHC_Esr = emecOptions->EMECEsr(); - -//read HV values of power supplies - - HVMapVersion = emecOptions->EMECHVMap(); - if(HVMapVersion == "v00" || HVMapVersion == "v01") NofPhiSections=32; - else{ - NofPhiSections=lwc()->GetNumberOfFans(); - for(G4int i=0;i<NofAtlasSide;++i){ - for(G4int j=0;j<NofEtaSection;++j){ - for(G4int k=0;k<NofElectrodeSide;++k){ - HV_Start_phi[i][j][k]=0; - } - } - } - } - NumberOfElectrodesInPhiSection = lwc()->GetNumberOfFans() / NofPhiSections; - - Ylimits[0]=Ylimits[1]=Ylimits[2]=Ylimits[3]=0; - - if(HVMapRead == false){ - (*m_msg) << MSG::DEBUG - << "EnergyCalculator: getting EMECHVMap version = " - << emecOptions->EMECHVMap() << " from StoreGate" - << endreq; - G4String HVMapPath = "LArG4EC"; - G4String HVMapFileName = "HVEMECMap_"+ HVMapVersion + ".dat"; - G4String HVpartialPath = HVMapPath + "/" + HVMapFileName; - G4String HVMapLocation = PathResolver::find_file(HVpartialPath, "ATLASCALDATA"); - GetHVMap(HVMapLocation.c_str()); - } - - if(m_DB_HV) get_HV_map_from_DB(); - -// if charge collection is required - if(m_correction_type == EMEC_ECOR_CHCL || m_correction_type == EMEC_ECOR_CHCL1){ - if(!lwc()->GetisElectrode()){ -// get fieldmap from file - - if(FieldMapsRead == false){ - ChCollInner.FieldMapPrepared=false; - ChCollOuter.FieldMapPrepared=false; -// Determine which version of the file by examining the user option. - G4String suffix = emecOptions->EMECChMap(); - if(suffix.empty()) FieldMapVersion = "v00"; - else FieldMapVersion = suffix; - - (*m_msg) << MSG::DEBUG - << "EnergyCalculator: field map version = " - << FieldMapVersion - << endreq; - - IniGeomforFieldMaps(); - -// Now we have to get the full path to the file. In -// stand-alone, we use AFS. In Athena, we use -// PathResolver. - G4String FieldMapFileName = "ec.fieldz" + suffix; - G4String FieldMapPath = "LArG4EC"; - G4String partialPath = FieldMapPath + "/" + FieldMapFileName; - G4String FieldMapLocation = PathResolver::find_file(partialPath, "ATLASCALDATA"); - - GetFieldMaps(FieldMapLocation.c_str()); - FieldMapsRead=true; - - } // finish to read the fieldmap - -// prepare the fieldmaps for further calculation - - if(FieldMapVersion != "v00"){ - FanEleThicknessOld = FanEleThickness; - FanEleFoldRadiusOld = lwc()->GetFanFoldRadius(); - } - - if(lwc()->GetisInner()) ChCollWheelType=&ChCollInner; - else ChCollWheelType=&ChCollOuter; - - if(ChCollWheelType->FieldMapPrepared == false){ - PrepareFieldMap(); - ChCollWheelType->FieldMapPrepared = true; - } + switch(m_solidtypeProp.value()) + { + case 0: m_solidtype = LArG4::InnerAbsorberWheel; break; + case 1: m_solidtype = LArG4::OuterAbsorberWheel; break; + case 2: m_solidtype = LArG4::InnerElectrodWheel; break; + case 3: m_solidtype = LArG4::OuterElectrodWheel; break; + case 4: m_solidtype = LArG4::InnerAbsorberModule; break; + case 5: m_solidtype = LArG4::OuterAbsorberModule; break; + case 6: m_solidtype = LArG4::InnerElectrodModule; break; + case 7: m_solidtype = LArG4::OuterElectrodModule; break; + case 8: m_solidtype = LArG4::BackInnerBarretteWheel; break; + case 9: m_solidtype = LArG4::BackOuterBarretteWheel; break; + case 10: m_solidtype = LArG4::BackInnerBarretteWheelCalib; break; + case 11: m_solidtype = LArG4::BackOuterBarretteWheelCalib; break; + case 12: m_solidtype = LArG4::BackInnerBarretteModule; break; + case 13: m_solidtype = LArG4::BackOuterBarretteModule; break; + case 14: m_solidtype = LArG4::BackInnerBarretteModuleCalib; break; + case 15: m_solidtype = LArG4::BackOuterBarretteModuleCalib; break; + case 16: m_solidtype = LArG4::InnerGlueWheel; break; + case 17: m_solidtype = LArG4::OuterGlueWheel; break; + case 18: m_solidtype = LArG4::InnerLeadWheel; break; + case 19: m_solidtype = LArG4::OuterLeadWheel; break; + default: + { + std::ostringstream merr; + merr << + "EnergyCalculator::SolidTypeHandler FATAL: invalid LArWheelCalculator_t specified " + << m_solidtypeProp.value(); + std::cerr << merr.str() << std::endl; + throw GaudiException(merr.str(), "EnergyCalculator::SolidTypeHandler", StatusCode::FAILURE); } - else{ // electrode type - (*m_msg) << MSG::FATAL - << "EnergyCalculator: " - << "Charge Collection cannot be prepared for " - << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) - << endreq; - G4ExceptionDescription description; - description << G4String("Process_Barrett: ") + - "Charge Collection cannot be prepared for solidtype=" + - LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()); - G4Exception("EnergyCalculator", "IncorrectSolidType", FatalException, description); + } +} + +StatusCode EnergyCalculator::initialize() +{ + m_lwc = new LArWheelCalculator(m_solidtype, m_zside); + if(lwc()->GetisElectrode()) + { + ATH_MSG_FATAL("energy caclculator must be of 'absorber' type," + << " while 'electrode' type is requested."); + return StatusCode::FAILURE; + } + s_RefzDist = lwc()->GetElecFocaltoWRP() + + lwc()->GetdWRPtoFrontFace() + lwc()->GetWheelThickness() + + lwc()->GetdWRPtoFrontFace() + s_LongBarThickness - s_DistOfEndofCuFromBack; + + ISvcLocator* svcLocator = Gaudi::svcLocator(); + + if(m_BirksLaw) + { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); + } + + // Access the GeoModelSvc: + IGeoModelSvc *geoModel=0; + ATH_CHECK(svcLocator->service ("GeoModelSvc",geoModel)); + + // Access the geometry database: + IRDBAccessSvc *pAccessSvc=0; + ATH_CHECK(svcLocator->service("RDBAccessSvc",pAccessSvc)); + + DecodeVersionKey larVersionKey(geoModel, "LAr"); + + pAccessSvc->connect(); + + const IRDBRecordset *emecSamplingSep = + pAccessSvc->getRecordset("EmecSamplingSep", larVersionKey.tag(), larVersionKey.node()); + if (emecSamplingSep->size()==0) { + throw std::runtime_error("Cannot find the EmecSamplingSep Table"); + } + + const IRDBRecordset *emecGeometry = + pAccessSvc->getRecordset("EmecGeometry", larVersionKey.tag(), larVersionKey.node()); + if (emecGeometry->size()==0) { + throw std::runtime_error("Cannot find the EmecGeometry Table"); + } + + pAccessSvc->disconnect(); + + for(int i = 0; i < 7; i ++){ + std::ostringstream A0STR; + A0STR << "_" << i; + const std::string A0 = A0STR.str(); + const std::string colName = "ZIW" + A0; + ziw[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; + // cout<<"i,ziw= "<<i<<" "<<ziw[i]<<endl; + } + for(int i = 0; i < 44; i ++){ + std::ostringstream A0STR; + A0STR << "_" << i; + const std::string A0 = A0STR.str(); + const std::string colName = "ZSEP12" + A0; + zsep12[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; + // cout<<"i,zsep12= "<<i<<" "<<zsep12[i]<<endl; + } + for(int i = 0; i < 22; i ++){ + std::ostringstream A0STR; + A0STR << "_" << i; + const std::string A0 = A0STR.str(); + const std::string colName = "ZSEP23" + A0; + zsep23[i] = (*emecSamplingSep)[0]->getDouble(colName)*CLHEP::cm; + // cout<<"i,zsep23= "<<i<<" "<<zsep23[i]<<endl; + } + + m_ElectrodeFanHalfThickness = LArWheelCalculator::GetFanHalfThickness(LArG4::InnerElectrodWheel); + m_FanEleThickness = ElectrodeFanHalfThickness() * 2.; + m_FanEleThicknessOld = 0.300*CLHEP::mm; + m_FanEleFoldRadiusOld = 3.*CLHEP::mm; + m_FanAbsThickness = lwc()->GetFanHalfThickness() * 2.; + m_WaveLength = lwc()->GetActiveLength() / lwc()->GetNumberOfWaves(); + + assert(fabs((*emecGeometry)[0]->getDouble("GAP0")*CLHEP::cm - s_AverageGap) < 0.000001); + + //Barrette treatment + if(lwc()->GetisBarrette()){ + if(lwc()->type() == LArG4::OuterAbsorberWheel || lwc()->type() == LArG4::OuterAbsorberModule) { + SetConst_OuterBarrett(); + } else{ + if(lwc()->type() == LArG4::InnerAbsorberWheel || lwc()->type() == LArG4::InnerAbsorberModule ){ + + ATH_MSG_FATAL("EnergyCalculator: " + << "Barrett section is not (yet) prepared for " + << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())); + G4ExceptionDescription description; + description << G4String("Process_Barrett: ") + "Barrett section is not (yet) prepared for solidtype=" + + LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()); + G4Exception("EnergyCalculator", "BarretteSectionNotPrepared", FatalException, description); + } + else{ + ATH_MSG_FATAL("EnergyCalculator: " + << "Unknown solidtype:" + << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())); + G4ExceptionDescription description; + description << G4String("Process_Barrett: ") + "Unknown solidtype=" + + LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()); + G4Exception("EnergyCalculator", "UnknownSolidType", FatalException, description); + } + } + m_Process_type = &EnergyCalculator::Process_Barrett; + m_GetHV_Value_type = &EnergyCalculator::GetHV_Value_Barrett; + m_GetGapSize_type = &EnergyCalculator::GetGapSize_Barrett; + m_distance_to_the_nearest_electrode_type = + &EnergyCalculator::distance_to_the_nearest_electrode_Barrett; + + if(lwc()->GetisBarretteCalib()) { + ATH_CHECK(m_supportCalculator.retrieve()); + } + + } else { + m_Process_type = &EnergyCalculator::Process_Default; + m_GetHV_Value_type = &EnergyCalculator::GetHV_Value_Default; + m_GetGapSize_type = &EnergyCalculator::GetGapSize_Default; + m_distance_to_the_nearest_electrode_type = + &EnergyCalculator::distance_to_the_nearest_electrode_Default; + } + + // energy correction type from jO + + + switch(m_correction_type){ + case EMEC_ECOR_GADJ: + m_ecorr_method = &EnergyCalculator::GapAdjustment; + break; + case EMEC_ECOR_CHCL: + m_ecorr_method = &EnergyCalculator::CalculateChargeCollection; + break; + case EMEC_ECOR_GADJ_OLD: + m_ecorr_method = &EnergyCalculator::GapAdjustment_old; + break; + case EMEC_ECOR_GADJ_E: + m_ecorr_method = &EnergyCalculator::GapAdjustment_E; + break; + case EMEC_ECOR_GADJ_S: + m_ecorr_method = &EnergyCalculator::GapAdjustment_s; + break; + case EMEC_ECOR_GADJ_SE: + m_ecorr_method = &EnergyCalculator::GapAdjustment__sE; + break; + case EMEC_ECOR_OFF: + m_ecorr_method = &EnergyCalculator::dummy_correction_method; + break; + case EMEC_ECOR_CHCL1: + if(lwc()->GetisBarrette()){ + m_ecorr_method = &EnergyCalculator::CalculateChargeCollection; + ATH_MSG_INFO("CHCOLL energy correction is user for Barettes" + << " instead of CHCOLL1"); + } else { + m_ecorr_method = &EnergyCalculator::CalculateChargeCollection1; + } + break; + default: + ATH_MSG_FATAL("EnergyCalculator: unknown correction type " + << m_correction_type); + G4Exception("EnergyCalculator", "UnknownCorrectionType", FatalException, + "Process_Barrett: unknown correction type"); + } + + if(m_HVMapVersion == "v00" || m_HVMapVersion == "v01") { + m_NofPhiSections=32; + } else { + m_NofPhiSections=lwc()->GetNumberOfFans(); + for(G4int i=0;i<s_NofAtlasSide;++i) { + for(G4int j=0;j<s_NofEtaSection;++j) { + for(G4int k=0;k<s_NofElectrodeSide;++k) { + s_HV_Start_phi[i][j][k]=0; + } + } + } + } + m_NumberOfElectrodesInPhiSection = lwc()->GetNumberOfFans() / NofPhiSections(); + + if(s_HVMapRead == false){ + ATH_MSG_DEBUG("EnergyCalculator: getting EMECHVMap version = " + << m_HVMapVersion << " from jO"); + const G4String HVMapPath = "LArG4EC"; + const G4String HVMapFileName = "HVEMECMap_"+ m_HVMapVersion + ".dat"; + const G4String HVpartialPath = HVMapPath + "/" + HVMapFileName; + const G4String HVMapLocation = PathResolver::find_file(HVpartialPath, "ATLASCALDATA"); + GetHVMap(HVMapLocation.c_str()); + } + + if(m_DB_HV) get_HV_map_from_DB(); + + // if charge collection is required + if(m_correction_type == EMEC_ECOR_CHCL || m_correction_type == EMEC_ECOR_CHCL1) { + if(!lwc()->GetisElectrode()) { + // get fieldmap from file + if(s_FieldMapsRead == false) { + s_ChCollInner.FieldMapPrepared=false; + s_ChCollOuter.FieldMapPrepared=false; + // Determine which version of the file by examining the user option. + //if(m_suffix.empty()) FieldMapVersion = "v00"; + //else FieldMapVersion = m_suffix; + s_FieldMapVersion = m_suffix.empty() ? "v00" : m_suffix; + + ATH_MSG_DEBUG("EnergyCalculator: field map version = " << s_FieldMapVersion); + + IniGeomforFieldMaps(); + + // Now we have to get the full path to the file. In + // stand-alone, we use AFS. In Athena, we use + // PathResolver. + const G4String FieldMapFileName = "ec.fieldz" + m_suffix; + const G4String FieldMapPath = "LArG4EC"; + const G4String partialPath = FieldMapPath + "/" + FieldMapFileName; + const G4String FieldMapLocation = PathResolver::find_file(partialPath, "ATLASCALDATA"); + + LoadFieldMaps(FieldMapLocation.c_str()); + s_FieldMapsRead=true; + } // finish to read the fieldmap + + // prepare the fieldmaps for further calculation + + if(s_FieldMapVersion != "v00"){ + m_FanEleThicknessOld = FanEleThickness(); + m_FanEleFoldRadiusOld = lwc()->GetFanFoldRadius(); + } + + // if(lwc()->GetisInner()) ChCollWheelType=&ChCollInner; + // else ChCollWheelType=&ChCollOuter; + m_ChCollWheelType = lwc()->GetisInner() ? &s_ChCollInner : &s_ChCollOuter; + + if(ChCollWheelType()->FieldMapPrepared == false){ + PrepareFieldMap(m_ChCollWheelType); + m_ChCollWheelType->FieldMapPrepared = true; } - } // end if chcoll required - (*m_msg) << MSG::DEBUG - << "EnergyCalculator parameters: " << std::endl - << "correction type " << m_correction_type << std::endl - << "GA power = " << m_GApower << std::endl - << "energy suppression range = " << CHC_Esr / CLHEP::mm << " [mm]" - << "\n" - << "default method for computation of folding angle (param) - compiled in" - << endreq; -// Aug 2007 AMS, lost Aug 2008, restored May 2009 - m_electrode_calculator = 0; - if(m_correction_type == EMEC_ECOR_CHCL1 && !lwc()->GetisBarrette()){ - LArWheelCalculator::LArWheelCalculator_t t = LArWheelCalculator::OuterElectrodWheel; - if(lwc()->GetisModule()){ - - if(lwc()->GetisInner()) t = LArWheelCalculator::InnerElectrodModule; - else t = LArWheelCalculator::OuterElectrodModule; - - } else if(lwc()->GetisInner()) t = LArWheelCalculator::InnerElectrodWheel; - - m_electrode_calculator = new LArWheelCalculator(t, lwc()->GetAtlasZside()); - if(m_electrode_calculator == 0){ - (*m_msg) << MSG::FATAL - << "cannot create helper electrode calculator" - << endreq; - G4Exception("EnergyCalculator", "NoElectrodeCalculator", FatalException, - "Process_Barrett: cannot create helper electrode calculator"); - } - (*m_msg) << MSG::DEBUG - << "helper electrode calculator created (" - << LArWheelCalculator::LArWheelCalculatorTypeString(t) << ")" - << endreq; - } -} // end of EnergyCalculator::EnergyCalculator + } else { + // electrode type + ATH_MSG_FATAL("EnergyCalculator: " + << "Charge Collection cannot be prepared for " + << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())); + G4ExceptionDescription description; + description << G4String("Process_Barrett: ") + + "Charge Collection cannot be prepared for solidtype=" + + LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()); + G4Exception("EnergyCalculator", "IncorrectSolidType", FatalException, description); + } + } // end if charge collection is required + ATH_MSG_DEBUG("EnergyCalculator parameters: " << "correction type " << m_correction_type ); + ATH_MSG_DEBUG("GA power = " << m_GApower + << "energy suppression range = " << m_CHC_Esr / CLHEP::mm << " [mm]" + << "\n" + << "default method for computation of folding angle (param) - compiled in"); + // Aug 2007 AMS, lost Aug 2008, restored May 2009 + m_electrode_calculator = 0; + if(m_correction_type == EMEC_ECOR_CHCL1 && !lwc()->GetisBarrette()){ + LArG4::LArWheelCalculator_t t = LArG4::OuterElectrodWheel; + if(lwc()->GetisModule()){ + + if(lwc()->GetisInner()) t = LArG4::InnerElectrodModule; + else t = LArG4::OuterElectrodModule; + + } else if(lwc()->GetisInner()) t = LArG4::InnerElectrodWheel; + + m_electrode_calculator = new LArWheelCalculator(t, lwc()->GetAtlasZside()); + if(m_electrode_calculator == 0){ + ATH_MSG_FATAL("cannot create helper electrode calculator"); + G4Exception("EnergyCalculator", "NoElectrodeCalculator", FatalException, + "Process_Barrett: cannot create helper electrode calculator"); + } + ATH_MSG_DEBUG("helper electrode calculator created (" + << LArWheelCalculator::LArWheelCalculatorTypeString(t) << ")"); + } + return StatusCode::SUCCESS; +} // end of EnergyCalculator::initialize G4double EnergyCalculator::CalculateChargeCollection1( - G4double a_energy, const G4ThreeVector &p1, const G4ThreeVector &p2) // need to make const + G4double a_energy, + const G4ThreeVector &p1, + const G4ThreeVector &p2, + G4double /*Barret_PhiStart*/) const { - if(!lwc()->GetisBarrette()){ // should be wheel - G4double current1 = GetCurrent1(p1, p2, a_energy); // need to make const - - CHCEtotal += a_energy; - CHCStotal += current1; - - if(m_msg->level()==MSG::DEBUG) - (*m_msg) << MSG::DEBUG - << " chcoll1: edep, current= " << a_energy << " " << current1 - << " CHCEtotal= " << CHCEtotal << " CHCStotal= " << CHCStotal - << " CHCIprint= " << CHCIprint << " CHCEbad= " << CHCEbad - << " ebad/etotal= " << CHCEbad / CHCEtotal - << endreq; - return current1; - } - return a_energy; + if(!lwc()->GetisBarrette()){ // should be wheel + G4double current1 = GetCurrent1(p1, p2, a_energy); +#ifdef DEBUG_CHCL + s_CHCEtotal += a_energy; + s_CHCStotal += current1; + + + ATH_MSG_DEBUG(" chcoll1: edep, current= " << a_energy << " " << current1 + << " CHCEtotal= " << CHCEtotal << " CHCStotal= " << CHCStotal + << " CHCIprint= " << CHCIprint << " CHCEbad= " << CHCEbad + << " ebad/etotal= " << CHCEbad / CHCEtotal); +#endif + return current1; + } + return a_energy; } // **************************************************************************** G4double EnergyCalculator::GapAdjustment_old(G4double a_energy, - const G4ThreeVector& p1, const G4ThreeVector &p2) // need to make const + const G4ThreeVector& p1, const G4ThreeVector &p2, G4double /*Barret_PhiStart*/ ) const // **************************************************************************** { // std::cout<<"*** GapAdjustment_old is called, a_energy="<<a_energy - // <<std::endl; + // <<std::endl; - const G4ThreeVector p = (p1 + p2) * .5; - return(a_energy / pow( ((this->*GetGapSize_type)(p)) / AverageGap, 1.3)); + const G4ThreeVector p = (p1 + p2) * .5; + return(a_energy / pow( ((this->*m_GetGapSize_type)(p)) / s_AverageGap, 1.3)); // const method } // **************************************************************************** G4double EnergyCalculator::GapAdjustment(G4double a_energy, const G4ThreeVector& a_startPoint, - const G4ThreeVector& a_endPoint) // need to make const + const G4ThreeVector& a_endPoint, + G4double /*Barret_PhiStart*/) const // **************************************************************************** { - static const G4double substpsize = 0.1*CLHEP::mm; + static const G4double substpsize = 0.1*CLHEP::mm; // std::cout<<"*** GapAdjustment is called, a_energy="<<a_energy - // <<std::endl; - - const G4ThreeVector step( a_endPoint - a_startPoint ); - const G4int nofstep= int(step.mag()/substpsize)+1; - const G4double s_energy= a_energy/nofstep; - G4double corr_energy= 0; - G4ThreeVector vstep; - - for(G4int i = 0; i < nofstep; ++ i){ // loop for substeps - const G4double ds = (i + 0.5) / nofstep; - vstep = a_startPoint * (1. - ds) + a_endPoint * ds; - const G4double gap = (this->*GetGapSize_type)(vstep); - corr_energy += s_energy / pow((gap / AverageGap), m_GApower); - } - return corr_energy; + // <<std::endl; + + const G4ThreeVector step( a_endPoint - a_startPoint ); + const G4int nofstep= int(step.mag()/substpsize)+1; + const G4double s_energy= a_energy/nofstep; + G4double corr_energy= 0; + G4ThreeVector vstep; + + for(G4int i = 0; i < nofstep; ++ i){ // loop for substeps + const G4double ds = (i + 0.5) / nofstep; + vstep = a_startPoint * (1. - ds) + a_endPoint * ds; + const G4double gap = (this->*m_GetGapSize_type)(vstep); // const method + corr_energy += s_energy / pow((gap / s_AverageGap), GApower()); + } + return corr_energy; } // **************************************************************************** G4double EnergyCalculator::GapAdjustment_E(G4double a_energy, - const G4ThreeVector& a_startPoint, - const G4ThreeVector& a_endPoint) // need to make const + const G4ThreeVector& a_startPoint, + const G4ThreeVector& a_endPoint, + G4double Barret_PhiStart) const // **************************************************************************** { - static const G4double substpsize = 0.1*CLHEP::mm; + static const G4double substpsize = 0.1*CLHEP::mm; //std::cout<<"*** GapAdjustment_E is called, a_energy="<<a_energy - // <<std::endl; - - const G4ThreeVector step( a_endPoint - a_startPoint ); - const G4int nofstep = G4int(step.mag()/substpsize) + 1; - const G4double s_energy = a_energy / nofstep / AverageCurrent; - G4double corr_energy = 0; - G4ThreeVector vstep; - - for(G4int i = 0; i < nofstep; i ++){ - const G4double ds = (i + 0.5) / nofstep; - vstep = a_startPoint * (1. - ds) + a_endPoint * ds; - const G4double gap = (this->*GetGapSize_type)(vstep); - const G4double HV_value = (this->*GetHV_Value_type)(vstep); - const G4double efield = (HV_value * CLHEP::volt) / (gap * CLHEP::mm) / (CLHEP::kilovolt / CLHEP::cm); // estimate Efield[KV/cm] - corr_energy += s_energy / /* gap * gap / */ (gap - CHC_Esr) - * IonReco(efield) * DriftVelo(LArTemperature_av, efield); - } - return corr_energy; + // <<std::endl; + + const G4ThreeVector step( a_endPoint - a_startPoint ); + const G4int nofstep = G4int(step.mag()/substpsize) + 1; + const G4double s_energy = a_energy / nofstep / s_AverageCurrent; + G4double corr_energy = 0; + + for(G4int i = 0; i < nofstep; i ++){ + const G4double ds = (i + 0.5) / nofstep; + const G4ThreeVector vstep = a_startPoint * (1. - ds) + a_endPoint * ds; + const G4double gap = (this->*m_GetGapSize_type)(vstep); // const method + const G4double HV_value = (this->*m_GetHV_Value_type)(vstep, Barret_PhiStart); + const G4double efield = (HV_value * CLHEP::volt) / (gap * CLHEP::mm) / (CLHEP::kilovolt / CLHEP::cm); // estimate Efield[KV/cm] + corr_energy += s_energy / /* gap * gap / */ ( gap - CHC_Esr() ) + * IonReco(efield) * DriftVelo(s_LArTemperature_av, efield); + } + return corr_energy; } // **************************************************************************** G4double EnergyCalculator::CalculateChargeCollection( - G4double a_energy, - const G4ThreeVector &a_startPoint, - const G4ThreeVector &a_endPoint) // need to make const + G4double a_energy, + const G4ThreeVector &a_startPoint, + const G4ThreeVector &a_endPoint, + G4double Barret_PhiStart) const // **************************************************************************** { // std::cout<<"*** CalculateChargeCollection is called, a_energy="<<a_energy - // <<std::endl; - - if(m_msg->level()==MSG::DEBUG) - (*m_msg) << MSG::DEBUG - << "starting CalculateChargeCollection:" - << "a_energy = " << a_energy - << ", startPoint = " << MSG_VECTOR(a_startPoint) - << ", endPoint = " << MSG_VECTOR(a_endPoint) - << ", wheel type: " - << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) - << " isBarrette = " << lwc()->GetisBarrette() - << " isBarretteCalib = " << lwc()->GetisBarretteCalib() - << endreq; - -// calculatorPhiGap = -// lwc()->PhiGapNumberForWheel(LArWheelCalculator::GetPhiGap(a_startPoint)); + // <<std::endl; + + ATH_MSG_DEBUG("starting CalculateChargeCollection:" + << "a_energy = " << a_energy + << ", startPoint = " << MSG_VECTOR(a_startPoint) + << ", endPoint = " << MSG_VECTOR(a_endPoint) + << ", wheel type: " + << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) + << " isBarrette = " << lwc()->GetisBarrette() + << " isBarretteCalib = " << lwc()->GetisBarretteCalib()); + + // m_calculatorPhiGap = + // lwc()->PhiGapNumberForWheel(LArWheelCalculator::GetPhiGap(a_startPoint)); G4double pStart[3],pEnd[3]; for(G4int i = 0; i <= 2; ++ i){ @@ -806,9 +806,9 @@ G4double EnergyCalculator::CalculateChargeCollection( if(!lwc()->GetisBarrette()){ // should be wheel assert(pStart[2] >= -0.0001 && - pEnd[2] >= -0.0001 && - pStart[2] <= lwc()->GetWheelThickness()+0.0001 && - pEnd[2] <= lwc()->GetWheelThickness()+0.0001); + pEnd[2] >= -0.0001 && + pStart[2] <= lwc()->GetWheelThickness()+0.0001 && + pEnd[2] <= lwc()->GetWheelThickness()+0.0001); if(pStart[2]<0.) pStart[2]=0.0001; if( pEnd[2]<0.) pEnd[2]=0.0001; @@ -825,359 +825,332 @@ G4double EnergyCalculator::CalculateChargeCollection( if( pEnd[2]> thick) pEnd[2]= thick-0.0001; } - const G4double current = GetCurrent(pStart, pEnd, a_energy); + const G4double current = GetCurrent(pStart, pEnd, a_energy, Barret_PhiStart); - CHCEtotal=CHCEtotal+a_energy; - CHCStotal=CHCStotal+current; +#ifdef DEBUG_CHCL + s_CHCEtotal=s_CHCEtotal+a_energy; + s_CHCStotal=s_CHCStotal+current; - if(m_msg->level()==MSG::DEBUG) - (*m_msg) << MSG::DEBUG -// std::cout - <<" isBarrett="<<lwc()->GetisBarrette()<<" isInner="<<lwc()->GetisInner() - <<" chcoll: edep, current= "<<a_energy<<" "<<current - <<" CHCEtotal= "<<CHCEtotal<<" CHCStotal= "<<CHCStotal - <<" CHCIprint= "<<CHCIprint<<" CHCEbad= "<<CHCEbad - <<" ebad/etotal= "<<CHCEbad/CHCEtotal - <<endreq; -// <<std::endl; + ATH_MSG_DEBUG(" isBarrett="<<lwc()->GetisBarrette()<<" isInner="<<lwc()->GetisInner() + <<" chcoll: edep, current= "<<a_energy<<" "<<current + <<" CHCEtotal= "<<s_CHCEtotal<<" CHCStotal= "<<s_CHCStotal + <<" CHCIprint= "<<s_CHCIprint<<" CHCEbad= "<<s_CHCEbad + <<" ebad/etotal= "<<s_CHCEbad/s_CHCEtotal); +#endif return current; } // **************************************************************************** void EnergyCalculator::GetHVMap(const G4String fname){ -// **************************************************************************** + // **************************************************************************** + + ATH_MSG_INFO("HVEMECMap is to be read from file: " << fname); + + FILE *lun = fopen(fname, "r"); + if(lun == 0){ + ATH_MSG_ERROR("GetHVMap - file '" << fname << "' not found!" + << std::endl + << " Trying to read HVEMECMap from local file:" + << "HVEMECMap.dat"); + lun = fopen("HVEMECMap.dat", "r"); + } + if(lun == 0){ + ATH_MSG_FATAL("GetHVMap - file "<< "./HVEMECMap.dat not found!" + << "Cannot obtain HV map."); + G4Exception("EnergyCalculator", "NoHVMap", FatalException, + "GetHVMap: could not read map file"); + } + + char ch[80], ch1[80]; + + for(G4int i=0;i<80;i++) { + ch[i]=0; + ch1[i]=' '; + } + + fgets(ch,80,lun); + ATH_MSG_INFO("actual HVMapVersion = " << ch); + ch1[0]=ch[9]; + ch1[1]=ch[10]; + if(m_HVMapVersion == "v02" || m_HVMapVersion == "v99") { + ch1[0]=ch[10]; + ch1[1]=ch[11]; + } + G4int iv=atoi(ch1); + G4bool ok=false; + if(m_HVMapVersion == "v00" && iv == 0) ok=true; + if(m_HVMapVersion == "v01" && iv == 1) ok=true; + if(m_HVMapVersion == "v02" && iv == 2) ok=true; + if(m_HVMapVersion == "v99" && iv == 99) ok=true; // this is a test file + + if(!ok){ + ATH_MSG_FATAL("GetHVMap - file does not contain the map requested"); + G4Exception("EnergyCalculator", "IncorrectVMap", FatalException, + "GetHVMap: incorrect map file"); + } - (*m_msg) << MSG::INFO - << "HVEMECMap is to be read from file: " << fname << endreq; - - FILE *lun = fopen(fname, "r"); - if(lun == 0){ - (*m_msg) << MSG::ERROR - << "GetHVMap - file '" << fname << "' not found!" - << std::endl - << " Trying to read HVEMECMap from local file:" - << "HVEMECMap.dat" - << endreq; - lun = fopen("HVEMECMap.dat", "r"); - } - if(lun == 0){ - (*m_msg) << MSG::FATAL - << "GetHVMap - file "<< "./HVEMECMap.dat not found!" - << "Cannot obtain HV map." << endreq; - G4Exception("EnergyCalculator", "NoHVMap", FatalException, - "GetHVMap: could not read map file"); - } - - char ch[80], ch1[80]; - - for(G4int i=0;i<80;i++){ch1[i]=' ';} - - fgets(ch,80,lun); - (*m_msg) << MSG::INFO << "actual HVMapVersion = " << ch - << endreq; - ch1[0]=ch[9]; - ch1[1]=ch[10]; - if(HVMapVersion == "v02" || HVMapVersion == "v99"){ - ch1[0]=ch[10]; - ch1[1]=ch[11]; + if(m_HVMapVersion == "v00" || m_HVMapVersion == "v01" ) { + for(G4int i = 0; i < s_NofAtlasSide; ++ i) { + if (fscanf(lun, "%79s", ch) < 1) { + ATH_MSG_ERROR("GetHVMap: Error reading map file"); + } + const G4String AtlasSide = ch; + ATH_MSG_DEBUG("AtlasSide = " << AtlasSide); + for(G4int j = 0; j < s_NofEtaSection; ++ j) { + for(G4int k = 0; k < s_NofElectrodeSide; ++ k) { + if (fscanf(lun, "%79s%79s", ch, ch1) < 2) { + ATH_MSG_ERROR("GetHVMap: Error reading map file"); + } + const G4String EtaSection = ch; + const G4String ElectrodeSide=ch1; + ATH_MSG_DEBUG("EtaSection = " << EtaSection + << " ElectrodeSide = " << ElectrodeSide); + if (fscanf(lun, "%i", &s_HV_Start_phi[i][j][k]) < 1) { + ATH_MSG_ERROR("GetHVMap: Error reading map file"); + } + ATH_MSG_DEBUG("i, j, k = " << i << ", " << j << ", " << k + << " " <<" HV_Start_phi = " << s_HV_Start_phi[i][j][k]); + for(G4int l = 0; l < NofPhiSections(); ++ l){ + if (fscanf(lun, "%lg", &s_HV_Values[i][j][k][l]) < 1) { + ATH_MSG_ERROR("GetHVMap: Error reading map file"); + } + if(l == 0){ + ATH_MSG_DEBUG(" HV_Values = " << s_HV_Values[i][j][k][l]); + } + } } - G4int iv=atoi(ch1); - G4bool ok=false; - if(HVMapVersion == "v00" && iv == 0) ok=true; - if(HVMapVersion == "v01" && iv == 1) ok=true; - if(HVMapVersion == "v02" && iv == 2) ok=true; - if(HVMapVersion == "v99" && iv == 99) ok=true; // this is a test file - - if(!ok){ - (*m_msg) << MSG::FATAL - << "GetHVMap - file does not contain the map requested"<< endreq; - G4Exception("EnergyCalculator", "IncorrectVMap", FatalException, - "GetHVMap: incorrect map file"); - } - - if(HVMapVersion == "v00" || HVMapVersion == "v01" ){ - - G4String AtlasSide, EtaSection, ElectrodeSide; - for(G4int i = 0; i < NofAtlasSide; ++ i){ - if (fscanf(lun, "%79s", ch) < 1) { - (*m_msg) << MSG::ERROR << "GetHVMap: Error reading map file" - << endreq; - } - AtlasSide = ch; - (*m_msg) << MSG::DEBUG << "AtlasSide = " << AtlasSide << endreq; - for(G4int j = 0; j < NofEtaSection; ++ j){ - for(G4int k = 0; k < NofElectrodeSide; ++ k){ - if (fscanf(lun, "%79s%79s", ch, ch1) < 2) { - (*m_msg) << MSG::ERROR << "GetHVMap: Error reading map file" - << endreq; - } - EtaSection =ch; - ElectrodeSide=ch1; - (*m_msg) << MSG::DEBUG << "EtaSection = " << EtaSection - << " ElectrodeSide = " << ElectrodeSide - << endreq; - - if (fscanf(lun, "%i", &HV_Start_phi[i][j][k]) < 1) { - (*m_msg) << MSG::ERROR << "GetHVMap: Error reading map file" - << endreq; - } - (*m_msg) << MSG::DEBUG << "i, j, k = " << i << ", " << j << ", " << k - << " " <<" HV_Start_phi = " << HV_Start_phi[i][j][k] - << endreq; - - for(G4int l = 0; l < NofPhiSections; ++ l){ - if (fscanf(lun, "%lg", &HV_Values[i][j][k][l]) < 1) { - (*m_msg) << MSG::ERROR << "GetHVMap: Error reading map file" - << endreq; - } - if(l == 0){ - (*m_msg) << MSG::DEBUG << " HV_Values = " << HV_Values[i][j][k][l] - << endreq; - } - } - } - } - } - (*m_msg) << MSG::DEBUG << endreq; - } - - if(HVMapVersion == "v02" || HVMapVersion == "v99") { - - G4int iprmx,i,j,k,l,electrodenumber; - char s[200]; - - iprmx=3; - //iprmx=3*256; - for(i=0;i<NofAtlasSide;++i){ //loop for Atlas side - for(j=0;j<3;++j){ // read header lines - fgets(s,200,lun); - printf("%s",s); - } - for(j=0; j<NofElectrodesOut; ++j){ //loop for electrodes - if (fscanf(lun,"%i",&electrodenumber) < 1) { - (*m_msg) << MSG::ERROR << "GetHVMap: Error reading map file" - << endreq; - } - if(j<iprmx || j==NofElectrodesOut-1) printf("%3i",electrodenumber); - if(j==iprmx) printf("...\n"); - for(k=0;k<NofEtaSection;++k){ //loop for etasection - for(l=0;l<NofElectrodeSide;++l){ //loop for side - if (fscanf(lun,"%lg", &HV_Values[i][k][l][j]) < 1) { - (*m_msg) << MSG::ERROR << "GetHVMap: Error reading map file" - << endreq; - } - if(j<iprmx || j==NofElectrodesOut-1) printf("%8.2f",HV_Values[i][k][l][j]); - } - } - if(j<iprmx || j==NofElectrodesOut-1) printf("\n"); - } - fgets(s,200,lun); - } - } - fclose(lun); - HVMapRead = true; + } + } // end for(G4int i = 0; i < NofAtlasSide; ++ i) + } // end if (HVMapVersion == "v00" || HVMapVersion == "v01" ) + if(m_HVMapVersion == "v02" || m_HVMapVersion == "v99") { + char s[200]; + const G4int iprmx=3; + //iprmx=3*256; + for(G4int i=0; i<s_NofAtlasSide; ++i) { //loop for Atlas side + for(G4int j=0; j<3; ++j) { // read header lines + fgets(s,200,lun); + printf("%s",s); + } + for(G4int j=0; j<s_NofElectrodesOut; ++j) { //loop for electrodes + G4int electrodenumber=0; + if (fscanf(lun,"%i",&electrodenumber) < 1) { + ATH_MSG_ERROR("GetHVMap: Error reading map file"); + } + if (j<iprmx || j==s_NofElectrodesOut-1) { + printf("%3i",electrodenumber); + } + if (j==iprmx) { + printf("...\n"); + } + for(G4int k=0; k<s_NofEtaSection; ++k) { //loop for etasection + for(G4int l=0; l<s_NofElectrodeSide; ++l) { //loop for side + if (fscanf(lun,"%lg", &s_HV_Values[i][k][l][j]) < 1) { + ATH_MSG_ERROR("GetHVMap: Error reading map file"); + } + if(j<iprmx || j==s_NofElectrodesOut-1) { + printf("%8.2f",s_HV_Values[i][k][l][j]); + } + } + } + if(j<iprmx || j==s_NofElectrodesOut-1) { + printf("\n"); + } + } + fgets(s,200,lun); + } + } + fclose(lun); + s_HVMapRead = true; } -void EnergyCalculator::get_HV_map_from_DB(void) -{ - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StoreGateSvc* pDetStore; +void EnergyCalculator::get_HV_map_from_DB(void) { + ISvcLocator* svcLocator = Gaudi::svcLocator(); + StoreGateSvc* pDetStore; - StatusCode status = svcLocator->service("DetectorStore", pDetStore); - if(status.isFailure()){ - (*m_msg) << MSG::WARNING - << "unable to get Detector Store! Use default HV values" - << endreq; - return; - } + StatusCode status = svcLocator->service("DetectorStore", pDetStore); + if(status.isFailure()){ + ATH_MSG_WARNING("unable to get Detector Store! Use default HV values"); + return; + } // get EMECHV Manager - const LArHVManager *manager = 0; - if(pDetStore->retrieve(manager) == StatusCode::SUCCESS){ - const EMECHVManager* hvManager = - manager->getEMECHVManager(lwc()->GetisInner()? EMECHVModule::INNER: EMECHVModule::OUTER); - (*m_msg) << MSG::INFO << "got HV Manager for " - << (lwc()->GetisInner()? "inner": "outer") << " wheel" << endreq; - const EMECHVDescriptor* dsc = hvManager->getDescriptor(); - unsigned int counter = 0; - // loop over HV modules - for(unsigned int iSide = hvManager->beginSideIndex(); - iSide < hvManager->endSideIndex(); ++ iSide - ){ - unsigned short jSide = 1 - iSide; // local numbering is inverse - for(unsigned int iEta = hvManager->beginEtaIndex(); - iEta < hvManager->endEtaIndex(); ++ iEta - ){ - unsigned int jEta = iEta; - if(lwc()->GetisInner()) jEta += 7; - for(unsigned int iPhi = hvManager->beginPhiIndex(); - iPhi < hvManager->endPhiIndex(); ++ iPhi - ){ - for(unsigned int iSector = hvManager->beginSectorIndex(); - iSector < hvManager->endSectorIndex(); ++ iSector - ){ - EMECHVModuleConstLink hvMod = - hvManager->getHVModule(iSide, iEta, iPhi, iSector); - unsigned int nElec = hvMod->getNumElectrodes(); - for(unsigned int iElec = 0; iElec < nElec; ++ iElec){ - EMECHVElectrodeConstLink electrode = - hvMod->getElectrode(iElec); - unsigned int jElec = iElec; - jElec += iSector*nElec; - jElec += iPhi*nElec*dsc->getSectorBinning().getNumDivisions(); - if(jSide == 1){ - jElec = lwc()->GetNumberOfFans() + lwc()->GetNumberOfFans() / 2 - jElec; - if(jElec >= (unsigned int)lwc()->GetNumberOfFans()) jElec -= lwc()->GetNumberOfFans(); - } - for(unsigned int iGap = 0; iGap < 2; ++ iGap){ - double hv = electrode->voltage(iGap); - if(m_msg->level()==MSG::DEBUG) - (*m_msg) << MSG::DEBUG - << "Side, Eta, Elec, Gap, hv " - << jSide << " " << jEta << " " - << jElec << " " << iGap << " " - << HV_Values[jSide][jEta][iGap][jElec] - << " -> " << hv << endreq; - if(fabs((HV_Values[jSide][jEta][iGap][jElec] - hv)/HV_Values[jSide][jEta][iGap][jElec]) > 0.05){ - (*m_msg) << MSG::INFO - << "eta: " << dsc->getEtaBinning().binCenter(iEta) * (jSide == 0? 1: -1) << " " - << "phi: " << dsc->getPhiBinning().binCenter(iPhi) << " " - << "ele phi: " << electrode->getPhi() - << " side " << iGap - << " change HV from " - << HV_Values[jSide][jEta][iGap][jElec] - << " to " << hv << endreq; - } - if(hv > -999.){ - HV_Values[jSide][jEta][iGap][jElec] = hv; - ++ counter; - } - } - } - } - } - } - } - (*m_msg) << MSG::INFO << counter - << " HV values updated from DB" << endreq; - } else { - (*m_msg) << MSG::WARNING << "Unable to find HV Manager" << endreq; - } + const LArHVManager *manager = 0; + if(pDetStore->retrieve(manager) == StatusCode::SUCCESS){ + const EMECHVManager* hvManager = + manager->getEMECHVManager(lwc()->GetisInner()? EMECHVModule::INNER: EMECHVModule::OUTER); + ATH_MSG_INFO("got HV Manager for " << (lwc()->GetisInner()? "inner": "outer") << " wheel"); + const EMECHVDescriptor* dsc = hvManager->getDescriptor(); + unsigned int counter = 0; + // loop over HV modules + for(unsigned int iSide = hvManager->beginSideIndex(); + iSide < hvManager->endSideIndex(); ++ iSide + ){ + unsigned short jSide = 1 - iSide; // local numbering is inverse + for(unsigned int iEta = hvManager->beginEtaIndex(); + iEta < hvManager->endEtaIndex(); ++ iEta + ){ + unsigned int jEta = iEta; + if(lwc()->GetisInner()) jEta += 7; + for(unsigned int iPhi = hvManager->beginPhiIndex(); + iPhi < hvManager->endPhiIndex(); ++ iPhi + ){ + for(unsigned int iSector = hvManager->beginSectorIndex(); + iSector < hvManager->endSectorIndex(); ++ iSector + ){ + EMECHVModuleConstLink hvMod = + hvManager->getHVModule(iSide, iEta, iPhi, iSector); + unsigned int nElec = hvMod->getNumElectrodes(); + for(unsigned int iElec = 0; iElec < nElec; ++ iElec){ + EMECHVElectrodeConstLink electrode = + hvMod->getElectrode(iElec); + unsigned int jElec = iElec; + jElec += iSector*nElec; + jElec += iPhi*nElec*dsc->getSectorBinning().getNumDivisions(); + if(jSide == 1){ + jElec = lwc()->GetNumberOfFans() + lwc()->GetNumberOfFans() / 2 - jElec; + if(jElec >= (unsigned int)lwc()->GetNumberOfFans()) jElec -= lwc()->GetNumberOfFans(); + } + for(unsigned int iGap = 0; iGap < 2; ++ iGap){ + double hv = electrode->voltage(iGap); + ATH_MSG_DEBUG("Side, Eta, Elec, Gap, hv " + << jSide << " " << jEta << " " + << jElec << " " << iGap << " " + << s_HV_Values[jSide][jEta][iGap][jElec] + << " -> " << hv); + if(fabs((s_HV_Values[jSide][jEta][iGap][jElec] - hv)/s_HV_Values[jSide][jEta][iGap][jElec]) > 0.05){ + ATH_MSG_INFO("eta: " << dsc->getEtaBinning().binCenter(iEta) * (jSide == 0? 1: -1) << " " + << "phi: " << dsc->getPhiBinning().binCenter(iPhi) << " " + << "ele phi: " << electrode->getPhi() + << " side " << iGap + << " change HV from " + << s_HV_Values[jSide][jEta][iGap][jElec] + << " to " << hv); + } + if(hv > -999.){ + s_HV_Values[jSide][jEta][iGap][jElec] = hv; + ++ counter; + } + } + } + } + } + } + } + ATH_MSG_INFO(counter << " HV values updated from DB"); + } else { + ATH_MSG_WARNING("Unable to find HV Manager"); + } } // **************************************************************************** G4double EnergyCalculator::GetHV_Value(const G4ThreeVector& p) const // **************************************************************************** { -// pickup HV value from the data of power supplies; -// everything positioned in the Wheel's coord.system; -// if it is not the same as the Atlas's one, adjustment is needed -// either in this code or in the data file - - const G4int atlasside = (lwc()->GetAtlasZside() > 0) ? 0 : 1; - - const G4ThreeVector pforeta(p.x(), p.y(), p.z() + lwc()->GetElecFocaltoWRP() + lwc()->GetdWRPtoFrontFace()); - const G4double mideta = pforeta.pseudoRapidity(); - G4int etasection = -1; - for(G4int i = 1; i <= NofEtaSection; ++ i){ - if(mideta <= HV_Etalim[i]){ - etasection = i - 1; - break; - } - } - if(!(etasection>=0 && etasection <=NofEtaSection-1)) throw std::runtime_error("Index out of range"); - - //assert(etasection >= 0 && etasection <= NofEtaSection - 1); - - const std::pair<G4int, G4int> gap = lwc()->GetPhiGapAndSide(p); - G4int electrodeside = 0; //left side of electrode(small phi) - if(gap.second > 0) electrodeside = 1; - - const G4int electrodenumber = lwc()->PhiGapNumberForWheel(gap.first); - const G4int firstelectrode = HV_Start_phi[atlasside][etasection][electrodeside]; - G4int electrodeindex = electrodenumber-firstelectrode; - if(electrodeindex < 0) electrodeindex += lwc()->GetNumberOfFans(); - - const G4int phisection = electrodeindex / NumberOfElectrodesInPhiSection; - assert(phisection>=0 && phisection<=NofPhiSections-1); - - G4double HV_value= HV_Values[atlasside][etasection][electrodeside][phisection]; - - if(m_msg->level()==MSG::DEBUG) -// std::cout - (*m_msg) << MSG::DEBUG - <<"***GetHV::="<<HV_value<<" Asde="<<atlasside<<" eta="<<etasection - <<" Esde="<<electrodeside - <<" fi="<<phisection<<" xyz="<<p.x()<<" "<<p.y()<<" "<<p.z() - <<" igap.first="<<lwc()->PhiGapNumberForWheel(gap.first) - <<" gap.second="<<gap.second - <<endreq; - - return HV_value; + // pickup HV value from the data of power supplies; + // everything positioned in the Wheel's coord.system; + // if it is not the same as the Atlas's one, adjustment is needed + // either in this code or in the data file + + const G4int atlasside = (lwc()->GetAtlasZside() > 0) ? 0 : 1; + + const G4ThreeVector pforeta(p.x(), p.y(), p.z() + lwc()->GetElecFocaltoWRP() + lwc()->GetdWRPtoFrontFace()); + const G4double mideta = pforeta.pseudoRapidity(); + G4int etasection = -1; + for(G4int i = 1; i <= s_NofEtaSection; ++ i){ + if(mideta <= s_HV_Etalim[i]){ + etasection = i - 1; + break; + } + } + if(!(etasection>=0 && etasection <=s_NofEtaSection-1)) throw std::runtime_error("Index out of range"); + + //assert(etasection >= 0 && etasection <= s_NofEtaSection - 1); + + const std::pair<G4int, G4int> gap = lwc()->GetPhiGapAndSide(p); + G4int electrodeside = 0; //left side of electrode(small phi) + if(gap.second > 0) electrodeside = 1; + + const G4int electrodenumber = lwc()->PhiGapNumberForWheel(gap.first); + const G4int firstelectrode = s_HV_Start_phi[atlasside][etasection][electrodeside]; + G4int electrodeindex = electrodenumber-firstelectrode; + if(electrodeindex < 0) electrodeindex += lwc()->GetNumberOfFans(); + + const G4int phisection = electrodeindex / NumberOfElectrodesInPhiSection(); + assert(phisection>=0 && phisection<=NofPhiSections()-1); + + G4double HV_value= s_HV_Values[atlasside][etasection][electrodeside][phisection]; + + ATH_MSG_DEBUG("***GetHV::="<<HV_value<<" Asde="<<atlasside<<" eta="<<etasection + <<" Esde="<<electrodeside + <<" fi="<<phisection<<" xyz="<<p.x()<<" "<<p.y()<<" "<<p.z() + <<" igap.first="<<lwc()->PhiGapNumberForWheel(gap.first) + <<" gap.second="<<gap.second); + + return HV_value; } /* -In this type of correction energy deposited close than CHC_Esr to an electrod -is suppressed. + In this type of correction energy deposited close than s_CHC_Esr to an electrod + is suppressed. */ // **************************************************************************** G4double EnergyCalculator::GapAdjustment_s(G4double a_energy, - const G4ThreeVector& a_startPoint, - const G4ThreeVector& a_endPoint) // need to make const + const G4ThreeVector& a_startPoint, + const G4ThreeVector& a_endPoint, + G4double Barret_PhiStart) const // **************************************************************************** { - static const G4double substpsize = 0.1*CLHEP::mm; + static const G4double substpsize = 0.1*CLHEP::mm; // std::cout<<"*** GapAdjustment_s is called, a_energy="<<a_energy - // <<std::endl; - - const G4ThreeVector step( a_endPoint - a_startPoint ); - const G4int nofstep= int(step.mag()/substpsize)+1; - const G4double s_energy= a_energy/nofstep; - G4double corr_energy= 0.; - G4ThreeVector vstep, tmp; - - for(G4int i = 0; i < nofstep; ++ i){ // loop for substeps - const G4double ds = (i + 0.5) / nofstep; - vstep = a_startPoint * (1. - ds) + a_endPoint * ds; - tmp = vstep; - const G4double dte = (this->*distance_to_the_nearest_electrode_type)(tmp); - if(fabs(dte) < CHC_Esr) continue; - const G4double gap = (this->*GetGapSize_type)(vstep); - corr_energy += s_energy / pow((gap / AverageGap), m_GApower) - * gap / (gap - CHC_Esr); - } - return corr_energy; + // <<std::endl; + + const G4ThreeVector step( a_endPoint - a_startPoint ); + const G4int nofstep= int(step.mag()/substpsize)+1; + const G4double s_energy= a_energy/nofstep; + G4double corr_energy= 0.; + + for(G4int i = 0; i < nofstep; ++ i){ // loop for substeps + const G4double ds = (i + 0.5) / nofstep; + const G4ThreeVector vstep = a_startPoint * (1. - ds) + a_endPoint * ds; + G4ThreeVector tmp = vstep; + const G4double dte = (this->*m_distance_to_the_nearest_electrode_type)(tmp, Barret_PhiStart); + if( fabs(dte) < CHC_Esr() ) continue; + const G4double gap = (this->*m_GetGapSize_type)(vstep); // const method + corr_energy += s_energy / pow((gap / s_AverageGap), GApower()) + * gap / ( gap - CHC_Esr() ); + } + return corr_energy; } // **************************************************************************** G4double EnergyCalculator::GapAdjustment__sE(G4double a_energy, - const G4ThreeVector& a_startPoint, - const G4ThreeVector& a_endPoint) // need to make const + const G4ThreeVector& a_startPoint, + const G4ThreeVector& a_endPoint, + G4double Barret_PhiStart) const // **************************************************************************** { - static const G4double substpsize = 0.1*CLHEP::mm; + static const G4double substpsize = 0.1*CLHEP::mm; // std::cout<<"*** GapAdjustment__sE is called, a_energy="<<a_energy - // <<std::endl; - - const G4ThreeVector step( a_endPoint - a_startPoint ); - const G4int nofstep = G4int(step.mag()/substpsize) + 1; - const G4double s_energy = a_energy / nofstep; - G4double corr_energy = 0; - G4ThreeVector vstep, tmp; - - for(G4int i = 0; i < nofstep; i ++){ - const G4double ds = (i + 0.5) / nofstep; - vstep = a_startPoint * (1. - ds) + a_endPoint * ds; - tmp = vstep; - const G4double dte = (this->*distance_to_the_nearest_electrode_type)(tmp); - if(fabs(dte) < CHC_Esr) continue; - const G4double gap = (this->*GetGapSize_type)(vstep); - const G4double efield = 0.01 * (this->*GetHV_Value_type)(vstep) / gap; // estimate Efield[KV/cm] - corr_energy += s_energy / AverageCurrent / gap * - IonReco(efield) * DriftVelo(LArTemperature_av, efield) - * gap / (gap - CHC_Esr); - } - return corr_energy; + // <<std::endl; + + const G4ThreeVector step( a_endPoint - a_startPoint ); + const G4int nofstep = G4int(step.mag()/substpsize) + 1; + const G4double step_energy = a_energy / nofstep; + G4double corr_energy = 0; + + for(G4int i = 0; i < nofstep; i ++){ + const G4double ds = (i + 0.5) / nofstep; + const G4ThreeVector vstep = a_startPoint * (1. - ds) + a_endPoint * ds; + G4ThreeVector tmp = vstep; + const G4double dte = (this->*m_distance_to_the_nearest_electrode_type)(tmp, Barret_PhiStart); + if( fabs(dte) < CHC_Esr() ) continue; + const G4double gap = (this->*m_GetGapSize_type)(vstep); // const method + const G4double efield = 0.01 * (this->*m_GetHV_Value_type)(vstep, Barret_PhiStart) / gap; // estimate Efield[KV/cm] + corr_energy += step_energy / s_AverageCurrent / gap * + IonReco(efield) * DriftVelo(s_LArTemperature_av, efield) + * gap / ( gap - CHC_Esr() ); + } + return corr_energy; } // **************************************************************************** // The static arrays that describe the endcap geometry. Mostly these @@ -1202,100 +1175,97 @@ typedef struct { } geometry_t; static const geometry_t geometry[] = -// zSide sampling region etaScale etaOffset maxEta gapsPerBin maxPhi -{ { 3, 1, 0, 10, 25 , 6, 4, 63 }, - { 3, 2, 0, 10, 25 , 6, 4, 63 }, - { 2, 1, 5, 40, 96 , 3, 12, 63 }, - { 2, 1, 4, 160, 320 , 63, 12, 63 }, - { 2, 1, 3, 240, 432 , 47, 12, 63 }, - { 2, 1, 2, 320, 480 , 95, 12, 63 }, - { 2, 1, 1, 40, 57 , 2, 12, 63 }, - { 2, 2, 1, 40, 57 , 42, 3, 255 }, - { 2, 3, 0, 20, 30 , 19, 3, 255 }, - // These last two compartments did not exist separately - // in the G3 study. Yes, they have only one bin in eta. - { 2, 1, 0, 20, 27.5, 0, 12, 63 }, - { 2, 2, 0, 20, 27.5, 0, 3, 255 } }; + // zSide sampling region etaScale etaOffset maxEta gapsPerBin maxPhi + { { 3, 1, 0, 10, 25 , 6, 4, 63 }, + { 3, 2, 0, 10, 25 , 6, 4, 63 }, + { 2, 1, 5, 40, 96 , 3, 12, 63 }, + { 2, 1, 4, 160, 320 , 63, 12, 63 }, + { 2, 1, 3, 240, 432 , 47, 12, 63 }, + { 2, 1, 2, 320, 480 , 95, 12, 63 }, + { 2, 1, 1, 40, 57 , 2, 12, 63 }, + { 2, 2, 1, 40, 57 , 42, 3, 255 }, + { 2, 3, 0, 20, 30 , 19, 3, 255 }, + // These last two compartments did not exist separately + // in the G3 study. Yes, they have only one bin in eta. + { 2, 1, 0, 20, 27.5, 0, 12, 63 }, + { 2, 2, 0, 20, 27.5, 0, 3, 255 } }; // **************************************************************************** G4bool EnergyCalculator::FindIdentifier_Default( - const G4Step* step, - std::vector<LArHitData>& hdata, - G4ThreeVector &startPointLocal, - G4ThreeVector &endPointLocal -) // need to make const. return m_identifier, not modify + const G4Step* step, + std::vector<LArHitData>& hdata, + G4ThreeVector &startPointLocal, + G4ThreeVector &endPointLocal + ) const // **************************************************************************** { - G4bool validhit = true; - - const G4StepPoint* pre_step_point = step->GetPreStepPoint(); - const G4StepPoint* post_step_point = step->GetPostStepPoint(); - - const G4ThreeVector startPoint = pre_step_point->GetPosition(); - const G4ThreeVector endPoint = post_step_point->GetPosition(); -// p = (startPoint + endPoint) * 0.5; - const G4ThreeVector p = startPoint; // middle point may be out of volume - - const G4AffineTransform transformation = - pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); - - startPointLocal = transformation.TransformPoint(startPoint); - endPointLocal = transformation.TransformPoint(endPoint); -// pinLocal = (startPointLocal + endPointLocal) * 0.5; - const G4ThreeVector pinLocal = startPointLocal; // middle point may be out of volume - - const G4ThreeVector pforcell(pinLocal.x(), pinLocal.y() , - pinLocal.z() + lwc()->GetElecFocaltoWRP() + lwc()->GetdWRPtoFrontFace()); - - const G4double eta = pforcell.pseudoRapidity(); - const G4double z = pforcell.z(); - G4double phi = pforcell.phi(); - if(phi < 0.) phi += CLHEP::twopi; - - m_compartment = 0; - - if(lwc()->GetisInner()) - { - G4int ipad = G4int((eta - 2.5) / 0.1); - if(ipad > 6 || ipad < 0){ - (*m_msg) << MSG::WARNING - << "FindIdentifier: invalid hit, eta = " - << eta << ", ipad=" << ipad << endreq; - validhit=false; - if (ipad<0) ipad=0; - if (ipad>6) ipad=6; - } - if(z < ziw[ipad]) m_compartment = 1; - else m_compartment = 2; - } else { // !isInner - G4int ipad = G4int((eta - 1.4) / 0.025); - if(ipad < 0) ipad = 0; // first electrode starts below eta=1.4 - if(ipad > 43){ - (*m_msg) << MSG::WARNING - << "FindIdentifier: invalid hit, eta = " - << eta << ", ipad = " << ipad << endreq; - validhit=false; - ipad=43; - } - if(z < zsep12[ipad]){ - if (eta > 2.4) m_compartment = 3; - else if(eta > 2.0) m_compartment = 4; - else if(eta > 1.8) m_compartment = 5; - else if(eta > 1.5) m_compartment = 6; - else if(eta > 1.425) m_compartment = 7; - else m_compartment = 10; - } else { - if(z < zsep23[ipad/2]){ - if(eta > 1.425) m_compartment = 8; - else m_compartment = 11; - } else m_compartment = 9; - } - } -// if m_compartment==0, then none of the above "if's" were resolved. - - assert(m_compartment > 0); - - G4int c = m_compartment - 1; + G4bool validhit = true; + + const G4StepPoint* pre_step_point = step->GetPreStepPoint(); + const G4StepPoint* post_step_point = step->GetPostStepPoint(); + + const G4ThreeVector startPoint = pre_step_point->GetPosition(); + const G4ThreeVector endPoint = post_step_point->GetPosition(); + // p = (startPoint + endPoint) * 0.5; + const G4ThreeVector p = startPoint; // middle point may be out of volume + + const G4AffineTransform transformation = + pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); + + startPointLocal = transformation.TransformPoint(startPoint); + endPointLocal = transformation.TransformPoint(endPoint); + // pinLocal = (startPointLocal + endPointLocal) * 0.5; + const G4ThreeVector pinLocal = startPointLocal; // middle point may be out of volume + + const G4ThreeVector pforcell(pinLocal.x(), pinLocal.y() , + pinLocal.z() + lwc()->GetElecFocaltoWRP() + lwc()->GetdWRPtoFrontFace()); + + const G4double eta = pforcell.pseudoRapidity(); + const G4double z = pforcell.z(); + G4double phi = pforcell.phi(); + if(phi < 0.) phi += CLHEP::twopi; + + G4int m_compartment = 0; + + if(lwc()->GetisInner()) + { + G4int ipad = G4int((eta - 2.5) / 0.1); + if(ipad > 6 || ipad < 0){ + ATH_MSG_WARNING("FindIdentifier: invalid hit, eta = " + << eta << ", ipad=" << ipad); + validhit=false; + if (ipad<0) ipad=0; + if (ipad>6) ipad=6; + } + if(z < ziw[ipad]) m_compartment = 1; + else m_compartment = 2; + } else { // !isInner + G4int ipad = G4int((eta - 1.4) / 0.025); + if(ipad < 0) ipad = 0; // first electrode starts below eta=1.4 + if(ipad > 43){ + ATH_MSG_WARNING("FindIdentifier: invalid hit, eta = " + << eta << ", ipad = " << ipad); + validhit=false; + ipad=43; + } + if(z < zsep12[ipad]){ + if (eta > 2.4) m_compartment = 3; + else if(eta > 2.0) m_compartment = 4; + else if(eta > 1.8) m_compartment = 5; + else if(eta > 1.5) m_compartment = 6; + else if(eta > 1.425) m_compartment = 7; + else m_compartment = 10; + } else { + if(z < zsep23[ipad/2]){ + if(eta > 1.425) m_compartment = 8; + else m_compartment = 11; + } else m_compartment = 9; + } + } + // if m_compartment==0, then none of the above "if's" were resolved. + assert(m_compartment > 0); + + G4int c = m_compartment - 1; // There were some differences between the definition of a // "compartment" in the G3 study and the assignment of @@ -1309,360 +1279,355 @@ G4bool EnergyCalculator::FindIdentifier_Default( // if ( m_compartment == 11 ) m_compartment = 8; -// 19-04-2007 AMS use constant m_AtlasZside obtained in constructor + // 19-04-2007 AMS use constant m_AtlasZside obtained in constructor // zSide is negative if z<0. -// m_AtlasZside = geometry[c].zSide; -// if(p.z() < 0.) m_AtlasZside = -m_AtlasZside; -// G4int atlasside = m_AtlasZside; - const G4int atlasside = lwc()->GetAtlasZside() * geometry[c].zSide; + // m_AtlasZside = geometry[c].zSide; + // if(p.z() < 0.) m_AtlasZside = -m_AtlasZside; + // G4int atlasside = m_AtlasZside; + const G4int atlasside = lwc()->GetAtlasZside() * geometry[c].zSide; - G4int sampling = geometry[c].sampling; - G4int region = geometry[c].region; + G4int sampling = geometry[c].sampling; + G4int region = geometry[c].region; - G4int etaBin = G4int(eta * geometry[c].etaScale - geometry[c].etaOffset); + G4int etaBin = G4int(eta * geometry[c].etaScale - geometry[c].etaOffset); - if(etaBin < 0 || etaBin > geometry[c].maxEta) { - validhit=false; - if (etaBin<0) etaBin=0; - if (etaBin>geometry[c].maxEta) etaBin=geometry[c].maxEta; - } + if(etaBin < 0 || etaBin > geometry[c].maxEta) { + validhit=false; + if (etaBin<0) etaBin=0; + if (etaBin>geometry[c].maxEta) etaBin=geometry[c].maxEta; + } -// =============== -// Treatment of the constraints on the electrodes' geometry, -// and HV buses (J.T. 10.2004) -// Does not work for old G3 numbering scheme!! + // =============== + // Treatment of the constraints on the electrodes' geometry, + // and HV buses (J.T. 10.2004) + // Does not work for old G3 numbering scheme!! // overall geom param.: -// G4double WheelThickness = 514.*CLHEP::mm; - static const G4double rOuterCutoff = 2034.*CLHEP::mm; - static const G4double gapBetweenWheels = 3.*CLHEP::mm; - static const G4double eta_hi = 3.2; - static const G4double eta_mid= 2.5; - static const G4double eta_low= 1.375; + // G4double WheelThickness = 514.*CLHEP::mm; + static const G4double rOuterCutoff = 2034.*CLHEP::mm; + static const G4double gapBetweenWheels = 3.*CLHEP::mm; + static const G4double eta_hi = 3.2; + static const G4double eta_mid= 2.5; + static const G4double eta_low= 1.375; // specific param of electrode design; - static const G4double WidthofHVBus = 2.5*CLHEP::mm; - static const G4double WidthofKaptonGap = 1.0*CLHEP::mm; - static const G4double WidthofKaptonGapinS1 = 0.5*CLHEP::mm; - static const G4double WidthofKaptonGapatEdge = 2.*CLHEP::mm; - static const G4double zStartofIW = 4.*CLHEP::mm; // what follows measured by hand - static const G4double zStartofC7 = 8.4*CLHEP::mm; - static const G4double zStartofC3 = 7.8*CLHEP::mm; - static const G4double zEndofC8e2 = 4.5*CLHEP::mm; - static const G4double zEndofC9e19 = 30.*CLHEP::mm; - static const G4double r0aofC9e18 = 743.1*CLHEP::mm; - static const G4double r0cofC9e18 = 751.1*CLHEP::mm; - static const G4double zSepofC9e18 = 14.*CLHEP::mm; - static const G4double txofC9e18 = 0.48; - - static const G4double DistMax = WidthofHVBus+WidthofKaptonGap; - static const G4double DistMaxS1 = WidthofHVBus+WidthofKaptonGapinS1; - static const G4double DistMaxatEdgeinCrack = gapBetweenWheels/2.+WidthofKaptonGapatEdge+ - WidthofHVBus+WidthofKaptonGap/2.; - static const G4double DistMinatEdgeinCrack =(gapBetweenWheels+WidthofKaptonGapatEdge)/2.; - - G4double dist,dist_min,dist_max,eta_min,eta_max; + static const G4double WidthofHVBus = 2.5*CLHEP::mm; + static const G4double WidthofKaptonGap = 1.0*CLHEP::mm; + static const G4double WidthofKaptonGapinS1 = 0.5*CLHEP::mm; + static const G4double WidthofKaptonGapatEdge = 2.*CLHEP::mm; + static const G4double zStartofIW = 4.*CLHEP::mm; // what follows measured by hand + static const G4double zStartofC7 = 8.4*CLHEP::mm; + static const G4double zStartofC3 = 7.8*CLHEP::mm; + static const G4double zEndofC8e2 = 4.5*CLHEP::mm; + static const G4double zEndofC9e19 = 30.*CLHEP::mm; + static const G4double r0aofC9e18 = 743.1*CLHEP::mm; + static const G4double r0cofC9e18 = 751.1*CLHEP::mm; + static const G4double zSepofC9e18 = 14.*CLHEP::mm; + static const G4double txofC9e18 = 0.48; + + static const G4double DistMax = WidthofHVBus+WidthofKaptonGap; + static const G4double DistMaxS1 = WidthofHVBus+WidthofKaptonGapinS1; + static const G4double DistMaxatEdgeinCrack = gapBetweenWheels/2.+WidthofKaptonGapatEdge+ + WidthofHVBus+WidthofKaptonGap/2.; + static const G4double DistMinatEdgeinCrack =(gapBetweenWheels+WidthofKaptonGapatEdge)/2.; + + G4double dist,dist_min,dist_max,eta_min,eta_max; // check against the edges of the electrodes: hits are deleted if the // distance of the hit to the Cu signal layer on the (r,z) plane // is bigger than 1mm. - switch(m_compartment){ + switch(m_compartment){ -//compartment=1:inner wheel S1 + //compartment=1:inner wheel S1 - case 1: - switch(etaBin){ - case 0: - if(pinLocal.z() < zStartofIW ) { - validhit=false; - } - if (-DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { - validhit=false; - } - break; - case 4: - case 5: - if(pinLocal.z() < zStartofIW ) { - validhit=false; - } - break; - case 6: - if(pinLocal.z() < zStartofIW ) { - validhit=false; - } - if (DistanceToEtaLine( pforcell, eta_hi) < WidthofKaptonGapatEdge * 0.5) { - validhit=false; - } - break; - } - break; - -//compartment=2:inner wheel S2 - - case 2: - switch(etaBin){ - case 0: - if(-DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { - validhit=false; - } - break; - case 6: - if (DistanceToEtaLine( pforcell, eta_hi) < WidthofKaptonGapatEdge * 0.5) { - validhit=false; - } - break; - } - break; - -//compartment=3:outer wheel S1 eta 2.4 - - case 3: - switch(etaBin){ - case 0: - case 1: - case 2: - if(pinLocal.z() < zStartofC3 ) { - validhit=false; - } - break; - case 3: - if(pinLocal.z() < zStartofC3 ) { - validhit=false; - } - - if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { - validhit=false; - } - break; - } - break; - -//compartment=7:outer wheel S1 eta 1.425 - - case 7: - if(pinLocal.z()<zStartofC7) { - validhit=false; - } - - break; - -//compartment=8:outer wheel S2 eta 1.425 - - case 8: - switch(etaBin){ - case 0: - case 1: - if(rOuterCutoff-pforcell.perp() < WidthofKaptonGapatEdge * 0.5) { - validhit=false; - } - - break; - case 2: - if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC8e2) { - validhit=false; - } - break; - case 42: - if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { - validhit=false; - } - - break; - } - break; - -//compartment=9:outer wheel S3 eta 1.5 - - case 9: - switch(etaBin){ - case 18: - if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC9e19 && - pinLocal.z() <= lwc()->GetWheelThickness()-zSepofC9e18 && - pinLocal.perp() < r0aofC9e18 ) { -// G4cout<<" Skip of Hit in aC9e18"<<" r="<<pinLocal.perp()<< -// " zinWheel="<<pinLocal.z()<<G4endl; - validhit=false; - - } - if(pinLocal.z() > lwc()->GetWheelThickness()-zSepofC9e18 && - pinLocal.perp() < + case 1: + switch(etaBin){ + case 0: + if(pinLocal.z() < zStartofIW ) { + validhit=false; + } + if (-DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { + validhit=false; + } + break; + case 4: + case 5: + if(pinLocal.z() < zStartofIW ) { + validhit=false; + } + break; + case 6: + if(pinLocal.z() < zStartofIW ) { + validhit=false; + } + if (DistanceToEtaLine( pforcell, eta_hi) < WidthofKaptonGapatEdge * 0.5) { + validhit=false; + } + break; + } + break; + + //compartment=2:inner wheel S2 + + case 2: + switch(etaBin){ + case 0: + if(-DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { + validhit=false; + } + break; + case 6: + if (DistanceToEtaLine( pforcell, eta_hi) < WidthofKaptonGapatEdge * 0.5) { + validhit=false; + } + break; + } + break; + + //compartment=3:outer wheel S1 eta 2.4 + + case 3: + switch(etaBin){ + case 0: + case 1: + case 2: + if(pinLocal.z() < zStartofC3 ) { + validhit=false; + } + break; + case 3: + if(pinLocal.z() < zStartofC3 ) { + validhit=false; + } + + if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { + validhit=false; + } + break; + } + break; + + //compartment=7:outer wheel S1 eta 1.425 + + case 7: + if(pinLocal.z()<zStartofC7) { + validhit=false; + } + + break; + + //compartment=8:outer wheel S2 eta 1.425 + + case 8: + switch(etaBin){ + case 0: + case 1: + if(rOuterCutoff-pforcell.perp() < WidthofKaptonGapatEdge * 0.5) { + validhit=false; + } + + break; + case 2: + if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC8e2) { + validhit=false; + } + break; + case 42: + if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { + validhit=false; + } + + break; + } + break; + + //compartment=9:outer wheel S3 eta 1.5 + + case 9: + switch(etaBin){ + case 18: + if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC9e19 && + pinLocal.z() <= lwc()->GetWheelThickness()-zSepofC9e18 && + pinLocal.perp() < r0aofC9e18 ) { + // G4cout<<" Skip of Hit in aC9e18"<<" r="<<pinLocal.perp()<< + // " zinWheel="<<pinLocal.z()<<G4endl; + validhit=false; + + } + if(pinLocal.z() > lwc()->GetWheelThickness()-zSepofC9e18 && + pinLocal.perp() < r0cofC9e18+txofC9e18*(pinLocal.z()-(lwc()->GetWheelThickness()-zSepofC9e18))){ -// G4cout<<" Skip of Hit in cC9e18"<<" r="<<pinLocal.perp()<< -// " zinWheel="<<pinLocal.z()<<G4endl; - validhit=false; - - } - break; - case 19: - if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC9e19) { -// G4cout<<" Skip of Hit in z crack C9e19"<<" r="<<pinLocal.perp()<< -// " zinWheel="<<pinLocal.z()<<G4endl; - validhit=false; + // G4cout<<" Skip of Hit in cC9e18"<<" r="<<pinLocal.perp()<< + // " zinWheel="<<pinLocal.z()<<G4endl; + validhit=false; - } - if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { -// G4cout<<" Skip of Hit in eta crack of C9e19"<< -// " r="<<pinLocal.perp()<< " zinWheel="<<pinLocal.z()<<G4endl; - validhit=false; - } - break; - } - break; + } + break; + case 19: + if(pinLocal.z() > lwc()->GetWheelThickness()-zEndofC9e19) { + // G4cout<<" Skip of Hit in z crack C9e19"<<" r="<<pinLocal.perp()<< + // " zinWheel="<<pinLocal.z()<<G4endl; + validhit=false; -//compartment=10:outer wheel S1 eta 1.375 + } + if(DistanceToEtaLine( pforcell, eta_mid) < DistMinatEdgeinCrack) { + // G4cout<<" Skip of Hit in eta crack of C9e19"<< + // " r="<<pinLocal.perp()<< " zinWheel="<<pinLocal.z()<<G4endl; + validhit=false; + } + break; + } + break; - case 10: - if(-DistanceToEtaLine( pforcell, eta_low) < WidthofKaptonGapatEdge * 0.5) { - validhit=false; - } - if(rOuterCutoff-pforcell.perp() < WidthofKaptonGapatEdge * 0.5) - validhit=false; - break; + //compartment=10:outer wheel S1 eta 1.375 -//compartment=11:outer wheel S2 eta 1.375 + case 10: + if(-DistanceToEtaLine( pforcell, eta_low) < WidthofKaptonGapatEdge * 0.5) { + validhit=false; + } + if(rOuterCutoff-pforcell.perp() < WidthofKaptonGapatEdge * 0.5) + validhit=false; + break; - case 11: - if(rOuterCutoff-pforcell.perp() < WidthofKaptonGapatEdge/2.) { - validhit=false; - } - break; - } + //compartment=11:outer wheel S2 eta 1.375 -// treatment of HV bus;the signal collected in the region of the bus -// should be attached to different cell what found above + case 11: + if(rOuterCutoff-pforcell.perp() < WidthofKaptonGapatEdge/2.) { + validhit=false; + } + break; + } + + // treatment of HV bus;the signal collected in the region of the bus + // should be attached to different cell what found above // outer wheel, S1: - G4int cnew=-1; - - if(m_compartment == 10 || m_compartment == 7 ){ - - eta_max = (geometry[c].etaOffset+etaBin+1.)/ geometry[c].etaScale; - dist=DistanceToEtaLine(pforcell,eta_max); -// assert(dist >= 0.); - if (dist>=0. && dist <= DistMaxS1) cnew = c+1; - } - -// outer wheel, S3: - - else if(m_compartment == 9 ) { - - eta_min=(geometry[c].etaOffset+etaBin) / geometry[c].etaScale; - eta_max=(geometry[c].etaOffset+etaBin+1.)/ geometry[c].etaScale; - dist_min =DistanceToEtaLine(pforcell,eta_min); - dist_max =DistanceToEtaLine(pforcell,eta_max); - -// assert(dist_min <=0.); -// assert(dist_max >=0.); - - if(dist_min<=0. && -dist_min <= DistMax) cnew = c-1; - else { - if(etaBin != geometry[c].maxEta) { - if(dist_max>=0. && dist_max <= DistMax) cnew = c-1; - } - else{ // close to the crack region between wheels, etaBin=maxEta; - if(dist_max >= DistMinatEdgeinCrack && - dist_max <= DistMaxatEdgeinCrack) cnew=c-1; - } - } - } - - // inner wheel S2: - - else if(m_compartment == 2) { - - eta_min=(geometry[c].etaOffset+etaBin)/geometry[c].etaScale; - dist = DistanceToEtaLine(pforcell,eta_min); - -// assert(dist<=0.); - - if(etaBin == 0) { - if(dist <=0. && -dist >= DistMinatEdgeinCrack && - -dist <= DistMaxatEdgeinCrack) cnew=c-1; - } - else if(dist<=0. && -dist <= DistMax) cnew=c-1; - } - - if(cnew >= 0 && cnew <= 10 ){ - -/* G4cout<<" edep in HV bus: old:comp="<<c+1<<" sampl="<<sampling<< - " eta="<<etaBin<<" reg="<<region - <<G4endl;*/ - - c=cnew; - m_compartment = c + 1; - sampling = geometry[c].sampling; - region = geometry[c].region; - etaBin = G4int(eta * geometry[c].etaScale - geometry[c].etaOffset); -/* G4cout<<" edep in HV bus: new:comp="<<c+1<<" sampl="<<sampling<< - " eta="<<etaBin<<" reg="<<region - <<G4endl;*/ - } -//=== end of edge and HV bus treatment================ - - - G4int phiGap = lwc()->GetPhiGap(pinLocal); - if(lwc()->GetisModule()){ - if(phiGap < lwc()->GetFirstFan() || phiGap >= lwc()->GetLastFan()){ - // this hit is beyond of edge absorbers of the module and should be ignored - if (phiGap < lwc()->GetFirstFan()) phiGap = lwc()->GetFirstFan(); - if (phiGap >= lwc()->GetLastFan()) phiGap = lwc()->GetLastFan() - 1; - validhit = false; - } - } - - G4int phiBin = phiGap / geometry[c].gapsPerBin; - - if(atlasside < 0){ -// The following formula assumes that the z<0 endcap was derived -// from the positive endcap by rotateY(180.*deg) -// 29-March-2004 ML - phiBin = (geometry[c].maxPhi - 1)/2 - phiBin; - if(phiBin < 0) phiBin += geometry[c].maxPhi + 1; - } - - assert(phiBin >= 0); - assert(phiBin <= geometry[c].maxPhi); - if(phiBin<0) {phiBin=0;validhit=false;} - if(phiBin>geometry[c].maxPhi) { - phiBin=geometry[c].maxPhi; - validhit=false; - } - if(etaBin > geometry[c].maxEta){ - (*m_msg) << MSG::WARNING - << "FindIdentifier: invalid hit, etaBin = " - << etaBin << " > geometry[" << c << "].maxEta=" - << geometry[c].maxEta << endreq; - etaBin=geometry[c].maxEta; - validhit=false; - } - if(etaBin < 0){ - (*m_msg) << MSG::WARNING - << "FindIdentifier: invalid hit, etaBin < 0" - << endreq; - etaBin=0; - validhit=false; - } - - hdata[0].id.clear(); - hdata[0].id << 4 // LArCalorimeter - << 1 // LArEM - << atlasside - << sampling - << region - << etaBin - << phiBin; - - G4double timeOfFlight = (pre_step_point->GetGlobalTime() + - post_step_point->GetGlobalTime()) * 0.5; - hdata[0].time = timeOfFlight/CLHEP::ns - p.mag()/CLHEP::c_light/CLHEP::ns; - if (hdata[0].time > m_OOTcut) m_isInTime = false; - else m_isInTime = true; - - return validhit; + G4int cnew=-1; + + if(m_compartment == 10 || m_compartment == 7 ){ + + eta_max = (geometry[c].etaOffset+etaBin+1.)/ geometry[c].etaScale; + dist=DistanceToEtaLine(pforcell,eta_max); + // assert(dist >= 0.); + if (dist>=0. && dist <= DistMaxS1) cnew = c+1; + } + + // outer wheel, S3: + + else if(m_compartment == 9 ) { + + eta_min=(geometry[c].etaOffset+etaBin) / geometry[c].etaScale; + eta_max=(geometry[c].etaOffset+etaBin+1.)/ geometry[c].etaScale; + dist_min =DistanceToEtaLine(pforcell,eta_min); + dist_max =DistanceToEtaLine(pforcell,eta_max); + + // assert(dist_min <=0.); + // assert(dist_max >=0.); + + if(dist_min<=0. && -dist_min <= DistMax) cnew = c-1; + else { + if(etaBin != geometry[c].maxEta) { + if(dist_max>=0. && dist_max <= DistMax) cnew = c-1; + } + else{ // close to the crack region between wheels, etaBin=maxEta; + if(dist_max >= DistMinatEdgeinCrack && + dist_max <= DistMaxatEdgeinCrack) cnew=c-1; + } + } + } + + // inner wheel S2: + + else if(m_compartment == 2) { + + eta_min=(geometry[c].etaOffset+etaBin)/geometry[c].etaScale; + dist = DistanceToEtaLine(pforcell,eta_min); + + // assert(dist<=0.); + + if(etaBin == 0) { + if(dist <=0. && -dist >= DistMinatEdgeinCrack && + -dist <= DistMaxatEdgeinCrack) cnew=c-1; + } + else if(dist<=0. && -dist <= DistMax) cnew=c-1; + } + + if(cnew >= 0 && cnew <= 10 ){ + + /* G4cout<<" edep in HV bus: old:comp="<<c+1<<" sampl="<<sampling<< + " eta="<<etaBin<<" reg="<<region + <<G4endl;*/ + + c=cnew; + m_compartment = c + 1; + sampling = geometry[c].sampling; + region = geometry[c].region; + etaBin = G4int(eta * geometry[c].etaScale - geometry[c].etaOffset); + /* G4cout<<" edep in HV bus: new:comp="<<c+1<<" sampl="<<sampling<< + " eta="<<etaBin<<" reg="<<region + <<G4endl;*/ + } + //=== end of edge and HV bus treatment================ + + + G4int phiGap = lwc()->GetPhiGap(pinLocal); + if(lwc()->GetisModule()){ + if(phiGap < lwc()->GetFirstFan() || phiGap >= lwc()->GetLastFan()){ + // this hit is beyond of edge absorbers of the module and should be ignored + if (phiGap < lwc()->GetFirstFan()) phiGap = lwc()->GetFirstFan(); + if (phiGap >= lwc()->GetLastFan()) phiGap = lwc()->GetLastFan() - 1; + validhit = false; + } + } + + G4int phiBin = phiGap / geometry[c].gapsPerBin; + + if(atlasside < 0){ + // The following formula assumes that the z<0 endcap was derived + // from the positive endcap by rotateY(180.*deg) + // 29-March-2004 ML + phiBin = (geometry[c].maxPhi - 1)/2 - phiBin; + if(phiBin < 0) phiBin += geometry[c].maxPhi + 1; + } + + assert(phiBin >= 0); + assert(phiBin <= geometry[c].maxPhi); + if(phiBin<0) {phiBin=0;validhit=false;} + if(phiBin>geometry[c].maxPhi) { + phiBin=geometry[c].maxPhi; + validhit=false; + } + if(etaBin > geometry[c].maxEta){ + ATH_MSG_WARNING("FindIdentifier: invalid hit, etaBin = " + << etaBin << " > geometry[" << c << "].maxEta=" + << geometry[c].maxEta); + etaBin=geometry[c].maxEta; + validhit=false; + } + if(etaBin < 0){ + ATH_MSG_WARNING("FindIdentifier: invalid hit, etaBin < 0"); + etaBin=0; + validhit=false; + } + + hdata[0].id.clear(); + hdata[0].id << 4 // LArCalorimeter + << 1 // LArEM + << atlasside + << sampling + << region + << etaBin + << phiBin; + + G4double timeOfFlight = (pre_step_point->GetGlobalTime() + + post_step_point->GetGlobalTime()) * 0.5; + hdata[0].time = timeOfFlight/Units::ns - p.mag()/CLHEP::c_light/Units::ns; + + return validhit; } /* gives the distance to the nearest electrode's surface */ @@ -1670,25 +1635,25 @@ G4bool EnergyCalculator::FindIdentifier_Default( G4double EnergyCalculator::distance_to_the_nearest_electrode(const G4ThreeVector &p) const // **************************************************************************** { - G4ThreeVector p1( p ); - int fan_number = G4int((p.phi() - M_PI_2 - lwc()->GetZeroFanPhi()) / lwc()->GetFanStepOnPhi()); - G4double angle = lwc()->GetFanStepOnPhi() * fan_number + lwc()->GetZeroFanPhi(); - p1.rotateZ(-angle); - G4double d0 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); - G4double d1; - d1 = d0; - G4int delta = 1; - if(d0 < 0.) delta = -1; - angle = - lwc()->GetFanStepOnPhi() * delta; - do{ - p1.rotateZ(angle); - fan_number += delta; - d1 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); - } while(d0 * d1 > 0.); - p1.rotateZ(-angle / 2); - if(delta > 0) fan_number --; - G4double d3 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); - return(fabs(d3) - ElectrodeFanHalfThickness); + G4ThreeVector p1( p ); + int fan_number = G4int((p.phi() - M_PI_2 - lwc()->GetZeroFanPhi()) / lwc()->GetFanStepOnPhi()); + G4double angle = lwc()->GetFanStepOnPhi() * fan_number + lwc()->GetZeroFanPhi(); + p1.rotateZ(-angle); + G4double d0 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); + G4double d1; + d1 = d0; + G4int delta = 1; + if(d0 < 0.) delta = -1; + angle = - lwc()->GetFanStepOnPhi() * delta; + do{ + p1.rotateZ(angle); + fan_number += delta; + d1 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); + } while(d0 * d1 > 0.); + p1.rotateZ(-angle / 2); + if(delta > 0) fan_number --; + G4double d3 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); + return(fabs(d3) - ElectrodeFanHalfThickness()); } // No account for edge effects in this function in case of module, @@ -1700,39 +1665,39 @@ G4double EnergyCalculator::distance_to_the_nearest_electrode(const G4ThreeVector double EnergyCalculator::GetGapSize(const G4ThreeVector& p) const // **************************************************************************** { - G4ThreeVector p1 ( p ); - int fan_number = G4int((p.phi() - M_PI_2 - lwc()->GetZeroFanPhi()) / lwc()->GetFanStepOnPhi()); - G4double angle = lwc()->GetFanStepOnPhi() * fan_number + lwc()->GetZeroFanPhi(); - p1.rotateZ(-angle); - const G4double d0 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); - - const G4int delta = (d0 < 0.)? -1 : 1; - G4double d1(d0), d2; - - angle = - lwc()->GetFanStepOnPhi() * delta; - do { - d2 = d1; - p1.rotateZ(angle); - fan_number += delta; - d1 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); - } while(d0 * d1 > 0.); - p1.rotateZ(-angle / 2); - if(delta > 0) fan_number --; - const G4double d3 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); - if(d3 * d2 < 0.){ - return(fabs(d2) - - lwc()->GetFanHalfThickness() + fabs(d3) - ElectrodeFanHalfThickness); - } else { - return(fabs(d1) - - lwc()->GetFanHalfThickness() + fabs(d3) - ElectrodeFanHalfThickness); - } + G4ThreeVector p1 ( p ); + int fan_number = G4int((p.phi() - M_PI_2 - lwc()->GetZeroFanPhi()) / lwc()->GetFanStepOnPhi()); + G4double angle = lwc()->GetFanStepOnPhi() * fan_number + lwc()->GetZeroFanPhi(); + p1.rotateZ(-angle); + const G4double d0 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); + + const G4int delta = (d0 < 0.)? -1 : 1; + G4double d1(d0), d2; + + angle = - lwc()->GetFanStepOnPhi() * delta; + do { + d2 = d1; + p1.rotateZ(angle); + fan_number += delta; + d1 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); + } while(d0 * d1 > 0.); + p1.rotateZ(-angle / 2); + if(delta > 0) fan_number --; + const G4double d3 = lwc()->DistanceToTheNeutralFibre(p1, lwc()->adjust_fan_number(fan_number)); + if(d3 * d2 < 0.){ + return(fabs(d2) + - lwc()->GetFanHalfThickness() + fabs(d3) - ElectrodeFanHalfThickness()); + } else { + return(fabs(d1) + - lwc()->GetFanHalfThickness() + fabs(d3) - ElectrodeFanHalfThickness()); + } } // **************************************************************************** void EnergyCalculator::SetConst_InnerBarrett(void){ -// **************************************************************************** - if(SetConstInnerBarrett) return; - SetConstInnerBarrett=true; + // **************************************************************************** + if(s_SetConstInnerBarrett) return; + s_SetConstInnerBarrett=true; std::cout <<" ===>>> ERROR!! SetConst_InnerBarrett is called!!!" <<std::endl; exit(99); @@ -1740,439 +1705,437 @@ void EnergyCalculator::SetConst_InnerBarrett(void){ // **************************************************************************** void EnergyCalculator::SetConst_OuterBarrett(void){ -// **************************************************************************** + // **************************************************************************** - if(SetConstOuterBarrett) return; - SetConstOuterBarrett=true; + if(s_SetConstOuterBarrett) return; + s_SetConstOuterBarrett=true; for(G4int i=0;i<=20;++i){ - const G4double teta = 2.*atan( exp(-S3_Etalim[i])); - S3_Rlim[i] = RefzDist*tan(teta); + const G4double teta = 2.*atan( exp(-s_S3_Etalim[i])); + s_S3_Rlim[i] = s_RefzDist*tan(teta); } - rlim[0] = S3_Rlim[3] + KapGap + Rmeas_outer[0] /*11.59 */ / ColdCorrection; - rlim[1] = S3_Rlim[3] + KapGap + Rmeas_outer[1] /*25.22 */ / ColdCorrection; - rlim[2] = S3_Rlim[3] + KapGap + Rmeas_outer[2] /*57.28 */ / ColdCorrection; - rlim[3] = S3_Rlim[3] + KapGap + Rmeas_outer[3] /*71.30 */ / ColdCorrection; - rlim[4] = S3_Rlim[3] + KapGap + Rmeas_outer[4] /*85.90 */ / ColdCorrection; - rlim[5] = S3_Rlim[3] + KapGap + Rmeas_outer[5] /*98.94 */ / ColdCorrection; - rlim[6] = S3_Rlim[3] + KapGap + Rmeas_outer[6] /*103.09 */ / ColdCorrection; - rlim[7] = S3_Rlim[3] + KapGap + Rmeas_outer[7] /*116.68 */ / ColdCorrection; - rlim[8] = S3_Rlim[3] + KapGap + Rmeas_outer[8] /*130.42 */ / ColdCorrection; - rlim[9] = S3_Rlim[3] + KapGap/2. + Rmeas_outer[9] /*146.27 */ / ColdCorrection + EdgeWidth; - rlim[10]= rlim[8] + Rmeas_outer[10]/*147.19 */ / ColdCorrection; - - rlim[11]= S3_Rlim[3] + KapGap + Rmeas_outer[11]/*11.59 */ / ColdCorrection; //eta=1.65 - rlim[12]= S3_Rlim[3] - KapGap - Rmeas_outer[12]/*15. */ / ColdCorrection; + const G4double inv_ColdCorrection = 1. / s_ColdCorrection; + s_rlim[0] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[0] /*11.59 */ * inv_ColdCorrection; + s_rlim[1] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[1] /*25.22 */ * inv_ColdCorrection; + s_rlim[2] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[2] /*57.28 */ * inv_ColdCorrection; + s_rlim[3] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[3] /*71.30 */ * inv_ColdCorrection; + s_rlim[4] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[4] /*85.90 */ * inv_ColdCorrection; + s_rlim[5] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[5] /*98.94 */ * inv_ColdCorrection; + s_rlim[6] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[6] /*103.09 */ * inv_ColdCorrection; + s_rlim[7] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[7] /*116.68 */ * inv_ColdCorrection; + s_rlim[8] = s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[8] /*130.42 */ * inv_ColdCorrection; + s_rlim[9] = s_S3_Rlim[3] + s_KapGap/2. + s_Rmeas_outer[9] /*146.27 */ * inv_ColdCorrection + s_EdgeWidth; + s_rlim[10]= s_rlim[8] + s_Rmeas_outer[10]/*147.19 */ * inv_ColdCorrection; - rlim[13]= S3_Rlim[4] + KapGap + Rmeas_outer[13]/*56.91 */ / ColdCorrection; //eta=1.7 - rlim[14]= S3_Rlim[4] - KapGap - Rmeas_outer[14]/*44.37 */ / ColdCorrection; + s_rlim[11]= s_S3_Rlim[3] + s_KapGap + s_Rmeas_outer[11]/*11.59 */ * inv_ColdCorrection; //eta=1.65 + s_rlim[12]= s_S3_Rlim[3] - s_KapGap - s_Rmeas_outer[12]/*15. */ * inv_ColdCorrection; - rlim[15]= S3_Rlim[5] + KapGap + Rmeas_outer[15]/*15.13 */ / ColdCorrection; //eta=1.75 - rlim[16]= S3_Rlim[5] - KapGap - Rmeas_outer[16]/*14.93 */ / ColdCorrection; + s_rlim[13]= s_S3_Rlim[4] + s_KapGap + s_Rmeas_outer[13]/*56.91 */ * inv_ColdCorrection; //eta=1.7 + s_rlim[14]= s_S3_Rlim[4] - s_KapGap - s_Rmeas_outer[14]/*44.37 */ * inv_ColdCorrection; - rlim[17]= S3_Rlim[6] + KapGap + Rmeas_outer[17]/*45.87 */ / ColdCorrection; //eta=1.80 - rlim[18]= S3_Rlim[6] - KapGap - Rmeas_outer[18]/*35.03 */ / ColdCorrection; + s_rlim[15]= s_S3_Rlim[5] + s_KapGap + s_Rmeas_outer[15]/*15.13 */ * inv_ColdCorrection; //eta=1.75 + s_rlim[16]= s_S3_Rlim[5] - s_KapGap - s_Rmeas_outer[16]/*14.93 */ * inv_ColdCorrection; - rlim[19]= S3_Rlim[7] + KapGap + Rmeas_outer[19]/*15.40 */ / ColdCorrection; //eta=1.85 - rlim[20]= S3_Rlim[7] - KapGap - Rmeas_outer[20]/*14.04 */ / ColdCorrection; + s_rlim[17]= s_S3_Rlim[6] + s_KapGap + s_Rmeas_outer[17]/*45.87 */ * inv_ColdCorrection; //eta=1.80 + s_rlim[18]= s_S3_Rlim[6] - s_KapGap - s_Rmeas_outer[18]/*35.03 */ * inv_ColdCorrection; - rlim[21]= S3_Rlim[8] + KapGap + Rmeas_outer[21]/*39.67 */ / ColdCorrection; //eta=1.90 - rlim[22]= S3_Rlim[8] - KapGap - Rmeas_outer[22]/*26.83 */ / ColdCorrection; + s_rlim[19]= s_S3_Rlim[7] + s_KapGap + s_Rmeas_outer[19]/*15.40 */ * inv_ColdCorrection; //eta=1.85 + s_rlim[20]= s_S3_Rlim[7] - s_KapGap - s_Rmeas_outer[20]/*14.04 */ * inv_ColdCorrection; - rlim[23]= S3_Rlim[9] + KapGap + Rmeas_outer[23]/*15.64 */ / ColdCorrection; //eta=1.95 - rlim[24]= S3_Rlim[9] - KapGap - Rmeas_outer[24]/*14.90 */ / ColdCorrection; + s_rlim[21]= s_S3_Rlim[8] + s_KapGap + s_Rmeas_outer[21]/*39.67 */ * inv_ColdCorrection; //eta=1.90 + s_rlim[22]= s_S3_Rlim[8] - s_KapGap - s_Rmeas_outer[22]/*26.83 */ * inv_ColdCorrection; - rlim[25]= S3_Rlim[10] + KapGap + Rmeas_outer[25]/*30.26 */ / ColdCorrection; //eta=2.00 - rlim[26]= S3_Rlim[10] - KapGap - Rmeas_outer[26]/*14.70 */ / ColdCorrection; + s_rlim[23]= s_S3_Rlim[9] + s_KapGap + s_Rmeas_outer[23]/*15.64 */ * inv_ColdCorrection; //eta=1.95 + s_rlim[24]= s_S3_Rlim[9] - s_KapGap - s_Rmeas_outer[24]/*14.90 */ * inv_ColdCorrection; - rlim[27]= S3_Rlim[10] - KapGap - Rmeas_outer[27]/*29.09 */ / ColdCorrection; //eta=2.05 - rlim[28]= S3_Rlim[10] - KapGap - Rmeas_outer[28]/*43.12 */ / ColdCorrection; //SHAPE CHANGE!!ZZ + s_rlim[25]= s_S3_Rlim[10] + s_KapGap + s_Rmeas_outer[25]/*30.26 */ * inv_ColdCorrection; //eta=2.00 + s_rlim[26]= s_S3_Rlim[10] - s_KapGap - s_Rmeas_outer[26]/*14.70 */ * inv_ColdCorrection; - rlim[29]= S3_Rlim[12] + KapGap + Rmeas_outer[29]/*34.51 */ / ColdCorrection; //eta=2.10 - rlim[30]= S3_Rlim[12] - KapGap - Rmeas_outer[30]/*25.08 */ / ColdCorrection; + s_rlim[27]= s_S3_Rlim[10] - s_KapGap - s_Rmeas_outer[27]/*29.09 */ * inv_ColdCorrection; //eta=2.05 + s_rlim[28]= s_S3_Rlim[10] - s_KapGap - s_Rmeas_outer[28]/*43.12 */ * inv_ColdCorrection; //SHAPE CHANGE!!ZZ - rlim[31]= S3_Rlim[13] + KapGap + Rmeas_outer[31]/*11.88 */ / ColdCorrection; //eta=2.15 - rlim[32]= S3_Rlim[13] - KapGap - Rmeas_outer[32]/*14.39 */ / ColdCorrection; + s_rlim[29]= s_S3_Rlim[12] + s_KapGap + s_Rmeas_outer[29]/*34.51 */ * inv_ColdCorrection; //eta=2.10 + s_rlim[30]= s_S3_Rlim[12] - s_KapGap - s_Rmeas_outer[30]/*25.08 */ * inv_ColdCorrection; - rlim[33]= S3_Rlim[14] + KapGap + Rmeas_outer[33]/*19.54 */ / ColdCorrection; //eta=2.20 - rlim[34]= S3_Rlim[14] - KapGap - Rmeas_outer[34]/*17.80 */ / ColdCorrection; // !!ZZ + s_rlim[31]= s_S3_Rlim[13] + s_KapGap + s_Rmeas_outer[31]/*11.88 */ * inv_ColdCorrection; //eta=2.15 + s_rlim[32]= s_S3_Rlim[13] - s_KapGap - s_Rmeas_outer[32]/*14.39 */ * inv_ColdCorrection; - rlim[35]= S3_Rlim[15] + KapGap + Rmeas_outer[35]/*12.70 */ / ColdCorrection; //eta=2.25 - rlim[36]= S3_Rlim[15] - KapGap - Rmeas_outer[36]/*15.31 */ / ColdCorrection; + s_rlim[33]= s_S3_Rlim[14] + s_KapGap + s_Rmeas_outer[33]/*19.54 */ * inv_ColdCorrection; //eta=2.20 + s_rlim[34]= s_S3_Rlim[14] - s_KapGap - s_Rmeas_outer[34]/*17.80 */ * inv_ColdCorrection; // !!ZZ - rlim[37]= S3_Rlim[16] + KapGap + Rmeas_outer[37]/*13.96 */ / ColdCorrection; //eta=2.30 - rlim[38]= S3_Rlim[16] - KapGap - Rmeas_outer[38]/*11.79 */ / ColdCorrection; // !!ZZ!! + s_rlim[35]= s_S3_Rlim[15] + s_KapGap + s_Rmeas_outer[35]/*12.70 */ * inv_ColdCorrection; //eta=2.25 + s_rlim[36]= s_S3_Rlim[15] - s_KapGap - s_Rmeas_outer[36]/*15.31 */ * inv_ColdCorrection; - rlim[40]= S3_Rlim[16] - KapGap - Rmeas_outer[40]/*23.57 */ / ColdCorrection; - rlim[41]= S3_Rlim[16] - KapGap - Rmeas_outer[41]/*34.64 */ / ColdCorrection; - rlim[42]= S3_Rlim[16] - KapGap - Rmeas_outer[42]/*55.32 */ / ColdCorrection; - rlim[43]= S3_Rlim[16] - KapGap - Rmeas_outer[43]/*65.39 */ / ColdCorrection; - rlim[44]= S3_Rlim[16] - KapGap - Rmeas_outer[44]/*76.34 */ / ColdCorrection; - rlim[45]= rlim[44] - Rmeas_outer[45]/*10.83 */ / ColdCorrection; - rlim[46]= S3_Rlim[16] - KapGap/2.- Rmeas_outer[46]/*94.84 */ / ColdCorrection - EdgeWidth; - rlim[47]= S3_Rlim[16] - KapGap/2.- Rmeas_outer[47]/*98.00 */ / ColdCorrection - EdgeWidth; + s_rlim[37]= s_S3_Rlim[16] + s_KapGap + s_Rmeas_outer[37]/*13.96 */ * inv_ColdCorrection; //eta=2.30 + s_rlim[38]= s_S3_Rlim[16] - s_KapGap - s_Rmeas_outer[38]/*11.79 */ * inv_ColdCorrection; // !!ZZ!! + s_rlim[40]= s_S3_Rlim[16] - s_KapGap - s_Rmeas_outer[40]/*23.57 */ * inv_ColdCorrection; + s_rlim[41]= s_S3_Rlim[16] - s_KapGap - s_Rmeas_outer[41]/*34.64 */ * inv_ColdCorrection; + s_rlim[42]= s_S3_Rlim[16] - s_KapGap - s_Rmeas_outer[42]/*55.32 */ * inv_ColdCorrection; + s_rlim[43]= s_S3_Rlim[16] - s_KapGap - s_Rmeas_outer[43]/*65.39 */ * inv_ColdCorrection; + s_rlim[44]= s_S3_Rlim[16] - s_KapGap - s_Rmeas_outer[44]/*76.34 */ * inv_ColdCorrection; + s_rlim[45]= s_rlim[44] - s_Rmeas_outer[45]/*10.83 */ * inv_ColdCorrection; + s_rlim[46]= s_S3_Rlim[16] - s_KapGap/2.- s_Rmeas_outer[46]/*94.84 */ * inv_ColdCorrection - s_EdgeWidth; + s_rlim[47]= s_S3_Rlim[16] - s_KapGap/2.- s_Rmeas_outer[47]/*98.00 */ * inv_ColdCorrection - s_EdgeWidth; - zlim[0] = - EdgeWidth + Zmeas_outer[0]/*3.81*/ / ColdCorrection; //rel. to the end_of_HV_Cu - zlim[1] = - KapGap/2. + Zmeas_outer[1]/*7.81*/ / ColdCorrection; - zlim[2] = StripWidth + 1./2. * KapGap; - zlim[3] =2*StripWidth + 3./2. * KapGap; + s_zlim[0] = - s_EdgeWidth + s_Zmeas_outer[0]/*3.81*/ * inv_ColdCorrection; //rel. to the end_of_HV_Cu + s_zlim[1] = - s_KapGap/2. + s_Zmeas_outer[1]/*7.81*/ * inv_ColdCorrection; + s_zlim[2] = s_StripWidth + 1./2. * s_KapGap; + s_zlim[3] =2*s_StripWidth + 3./2. * s_KapGap; for (G4int i=0; i<=3; ++i){ - zlim[i]= (ZmaxOfSignal-EdgeWidth) - zlim[i]; //rel to start of the Barrette - if(zlim[i] < 0.) zlim[i]=0.; + s_zlim[i]= (s_ZmaxOfSignal-s_EdgeWidth) - s_zlim[i]; //rel to start of the Barrette + if(s_zlim[i] < 0.) s_zlim[i]=0.; } return; } // **************************************************************************** G4bool EnergyCalculator::GetCompartment_Barrett( - G4ThreeVector pforcell, G4double r_inb, G4double z_inb, G4double eta_inb, - G4int &b_compartment, G4int &etabin) const{ -// **************************************************************************** + G4ThreeVector pforcell, G4double r_inb, G4double z_inb, G4double eta_inb, + G4int &b_compartment, G4int &etabin) const { + // **************************************************************************** + + G4double d,d1,d2,rlim1,rlim2,rlim3,zlim1,zlim2,eta1,eta2; + G4int i; + G4int i0 = 3; + + G4bool validhit=true; + b_compartment=-99; + etabin=-99; + + if(r_inb > s_rlim[10] || r_inb < s_rlim[47] ) + {validhit=false; goto label99;} + if(z_inb > s_ZmaxOfSignal ){validhit=false; goto label99;} + + if(r_inb > s_rlim[0]) { // Upper corner + + if(r_inb > s_rlim[9]) { + if(z_inb > s_zlim[0]) {validhit=false; goto label99;} + label1: + if(z_inb > s_zlim[1]) { + b_compartment = 8; + etabin = 4; + goto label99; + } + label2: + b_compartment = 9; + etabin = 0; + goto label99; + } + if(r_inb > s_rlim[8]) goto label1; + if(r_inb > s_rlim[7]) goto label2; + if(r_inb > s_rlim[6]) { + b_compartment = 8; + etabin = 5; + goto label99; + } + if(r_inb > s_rlim[5]) { + label3: + b_compartment = 8; + etabin = 6; + goto label99; + } + if(r_inb > s_rlim[4]) { + if(z_inb > s_zlim[1]) goto label3; + + label4: + b_compartment = 9; + etabin = 1; + goto label99; + } + + if(r_inb > s_rlim[3]) goto label4; + + if(r_inb > s_rlim[2]) { + b_compartment = 8; + etabin = 7; + goto label99; + } + + if(r_inb > s_rlim[1]) { + b_compartment = 8; + etabin = 8; + goto label99; + } + if(r_inb > s_rlim[0]) { + b_compartment = 9; + etabin = 2; + goto label99; + } + } + + if(r_inb < s_rlim[38]){ // lower corner - G4double d,d1,d2,rlim1,rlim2,rlim3,zlim1,zlim2,eta1,eta2; - G4int i; - G4int i0 = 3; + if( r_inb > s_rlim[40] ) { + b_compartment = 9; + etabin = 16; + goto label99; + } - G4bool validhit=true; - b_compartment=-99; - etabin=-99; + if( r_inb > s_rlim[41] ) { + label5: + b_compartment = 8; + etabin = 37; + goto label99; + } - if(r_inb > rlim[10] || r_inb < rlim[47] ) - {validhit=false; goto label99;} - if(z_inb > ZmaxOfSignal ){validhit=false; goto label99;} + if( r_inb > s_rlim[42] ) { - if(r_inb > rlim[0]) { // Upper corner + d=DistanceToEtaLine( pforcell,2.35); + if(fabs(d) < s_StripWidth+s_KapGap) { + if( d < 0.) { - if(r_inb > rlim[9]) { - if(z_inb > zlim[0]) {validhit=false; goto label99;} -label1: - if(z_inb > zlim[1]) { - b_compartment = 8; - etabin = 4; - goto label99; + label6: + b_compartment = 8; + etabin = 38; + goto label99; + } + label7: + if( z_inb < s_zlim[3] ) goto label5; + goto label6; } -label2: - b_compartment = 9; - etabin = 0; - goto label99; - } - if(r_inb > rlim[8]) goto label1; - if(r_inb > rlim[7]) goto label2; - if(r_inb > rlim[6]) { - b_compartment = 8; - etabin = 5; - goto label99; - } - if(r_inb > rlim[5]) { -label3: - b_compartment = 8; - etabin = 6; - goto label99; - } - if(r_inb > rlim[4]) { - if(z_inb > zlim[1]) goto label3; - -label4: - b_compartment = 9; - etabin = 1; - goto label99; - } - - if(r_inb > rlim[3]) goto label4; - - if(r_inb > rlim[2]) { - b_compartment = 8; - etabin = 7; - goto label99; - } - - if(r_inb > rlim[1]) { - b_compartment = 8; - etabin = 8; - goto label99; - } - if(r_inb > rlim[0]) { - b_compartment = 9; - etabin = 2; - goto label99; - } - } - - if(r_inb < rlim[38]){ // lower corner - - if( r_inb > rlim[40] ) { - b_compartment = 9; - etabin = 16; - goto label99; - } - - if( r_inb > rlim[41] ) { -label5: - b_compartment = 8; - etabin = 37; - goto label99; - } - - if( r_inb > rlim[42] ) { - - d=DistanceToEtaLine( pforcell,2.35); - if(fabs(d) < StripWidth+KapGap) { - if( d < 0.) { - -label6: - b_compartment = 8; - etabin = 38; - goto label99; - } -label7: - if( z_inb < zlim[3] ) goto label5; - goto label6; - } - - if( d > 0. ) goto label7; - - b_compartment = 9; - etabin = 17; - goto label99; - } - - if( r_inb > rlim[43] ) { - b_compartment = 8; - etabin = 39; - goto label99; - } - - if( r_inb > rlim[44] ) { -label8: - b_compartment = 8; - etabin = 40; - goto label99; - } - - if( r_inb > rlim[45] ) { - if( z_inb < zlim[3] ) goto label8; - -label9: - b_compartment = 9; - etabin = 18; - goto label99; - } - - if( r_inb > rlim[46] ) goto label9; - - if( z_inb < ZmaxOfSignal/(rlim[46]-rlim[47])*(r_inb-rlim[47])) goto label9; - - validhit=false; - goto label99; - } - -// medium r region: rlim[0] > r > rlim[38]; -// from middle of cellno 2 to middle of cellno. 16 -// - - for( i=3; i<=17; ++i){ // eta= 1.65 - 2.35 - if( eta_inb < S3_Etalim[i] ) { - i0=i; - break; - } - } - - i=i0; - - eta1 = S3_Etalim[i-1]; - eta2 = S3_Etalim[i]; - rlim1 = rlim[2*i+5 - 1]; - rlim2 = rlim[2*i+5]; - zlim1 = zlim[2]; - zlim2 = zlim[3]; - - if( i == 15 || i == 17) { - zlim1 = zlim[3]; - zlim2 = zlim[2]; - } - - switch(i){ - - case 3: - - if( fabs( DistanceToEtaLine(pforcell, eta2) ) < StripWidth+KapGap - || z_inb > zlim1 ){ - - b_compartment = 8; - etabin = 2*i+3;; - break; - } - - b_compartment = 9; - etabin = i-1; - break; - - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 13: - case 16: - - d1=fabs( DistanceToEtaLine( pforcell, eta1) ); - d2=fabs( DistanceToEtaLine( pforcell, eta2) ); - - if( d1 < StripWidth+KapGap ){ -label11: - b_compartment = 8; - etabin = 2*i+2; - break; - } - if( d2 < StripWidth+KapGap ){ -label12: - b_compartment = 8; - etabin = 2*i+3; - break; - } - - if( z_inb < zlim1 || (r_inb > rlim2 && r_inb < rlim1) ) { - - b_compartment = 9; - etabin = i-1; - break; - } - if( r_inb > rlim1 ) goto label11; - if( r_inb < rlim2 ) goto label12; - validhit=false; - break; -//======================================================== - case 11: - - rlim3 = rlim[28]; - - d1=fabs( DistanceToEtaLine( pforcell, eta1) ); - d2=fabs( DistanceToEtaLine( pforcell, eta2) ); - - if( d1 < StripWidth+KapGap ){ -label13: - b_compartment = 8; - etabin = 2*i+2; - break; - } - - if( r_inb > rlim1 && z_inb > zlim1 ) goto label13; - if( r_inb > rlim2 ){ -label14: - b_compartment = 9; - etabin = i-1; - break; - } - - if( d2 < StripWidth+KapGap ){ - if( z_inb > zlim1 ) { -label15: - b_compartment = 8; - etabin = 2*i+4; - break; - } - -label16: - b_compartment = 8; - etabin = 2*i+3; - break; - } - - if( z_inb < zlim2) goto label14; - if( r_inb > rlim3) goto label16; - if( z_inb > zlim1) goto label15; - goto label16; -//====================================================== - case 12: - - d1=fabs( DistanceToEtaLine( pforcell, eta1) ); - d2=fabs( DistanceToEtaLine( pforcell, eta2) ); - - if( d1 < StripWidth+KapGap ){ - b_compartment = 8; - etabin = 2*i+2; - break; - } - if( d2 < StripWidth+KapGap ){ -label17: - b_compartment = 8; - etabin = 2*i+3; - break; - } - - if( r_inb > rlim2 || z_inb < zlim1 ){ - b_compartment = 9; - etabin = i-1; - break; - } - goto label17; - -//======================================================== - - case 14: - case 15: - - d1=fabs( DistanceToEtaLine( pforcell, eta1) ); - d2=fabs( DistanceToEtaLine( pforcell, eta2) ); - - if( d1 < StripWidth+KapGap ){ -label18: - b_compartment = 8; - etabin = 2*i+2; - break; - } - if( d2 < StripWidth+KapGap ){ -label19: - b_compartment = 8; - etabin = 2*i+3; - break; - } - if( r_inb > rlim1 && z_inb > zlim1 ) goto label18; - if( r_inb < rlim2 && z_inb > zlim2 ) goto label19; - - b_compartment = 9; - etabin = i-1; - break; -//====================================================== - - case 17: - - d1=fabs( DistanceToEtaLine( pforcell, eta1) ); - - if( d1 < StripWidth+KapGap || z_inb > zlim1 ){ - b_compartment = 8; - etabin = 2*i+2; - break; - } - b_compartment = 9; - etabin = i-1; - break; - } - -//====================================================== - - -// end of search for compartment and etabin - -label99: - return validhit; + + if( d > 0. ) goto label7; + + b_compartment = 9; + etabin = 17; + goto label99; + } + + if( r_inb > s_rlim[43] ) { + b_compartment = 8; + etabin = 39; + goto label99; + } + + if( r_inb > s_rlim[44] ) { + label8: + b_compartment = 8; + etabin = 40; + goto label99; + } + + if( r_inb > s_rlim[45] ) { + if( z_inb < s_zlim[3] ) goto label8; + + label9: + b_compartment = 9; + etabin = 18; + goto label99; + } + + if( r_inb > s_rlim[46] ) goto label9; + + if( z_inb < s_ZmaxOfSignal/(s_rlim[46]-s_rlim[47])*(r_inb-s_rlim[47])) goto label9; + + validhit=false; + goto label99; + } + + // medium r region: s_rlim[0] > r > s_rlim[38]; + // from middle of cellno 2 to middle of cellno. 16 + // + + for( i=3; i<=17; ++i){ // eta= 1.65 - 2.35 + if( eta_inb < s_S3_Etalim[i] ) { + i0=i; + break; + } + } + + i=i0; + + eta1 = s_S3_Etalim[i-1]; + eta2 = s_S3_Etalim[i]; + rlim1 = s_rlim[2*i+5 - 1]; + rlim2 = s_rlim[2*i+5]; + zlim1 = s_zlim[2]; + zlim2 = s_zlim[3]; + + if( i == 15 || i == 17) { + zlim1 = s_zlim[3]; + zlim2 = s_zlim[2]; + } + + switch(i){ + + case 3: + + if( fabs( DistanceToEtaLine(pforcell, eta2) ) < s_StripWidth+s_KapGap + || z_inb > zlim1 ){ + + b_compartment = 8; + etabin = 2*i+3;; + break; + } + + b_compartment = 9; + etabin = i-1; + break; + + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 13: + case 16: + + d1=fabs( DistanceToEtaLine( pforcell, eta1) ); + d2=fabs( DistanceToEtaLine( pforcell, eta2) ); + + if( d1 < s_StripWidth+s_KapGap ){ + label11: + b_compartment = 8; + etabin = 2*i+2; + break; + } + if( d2 < s_StripWidth+s_KapGap ){ + label12: + b_compartment = 8; + etabin = 2*i+3; + break; + } + + if( z_inb < zlim1 || (r_inb > rlim2 && r_inb < rlim1) ) { + + b_compartment = 9; + etabin = i-1; + break; + } + if( r_inb > rlim1 ) goto label11; + if( r_inb < rlim2 ) goto label12; + validhit=false; + break; + //======================================================== + case 11: + + rlim3 = s_rlim[28]; + + d1=fabs( DistanceToEtaLine( pforcell, eta1) ); + d2=fabs( DistanceToEtaLine( pforcell, eta2) ); + + if( d1 < s_StripWidth+s_KapGap ){ + label13: + b_compartment = 8; + etabin = 2*i+2; + break; + } + + if( r_inb > rlim1 && z_inb > zlim1 ) goto label13; + if( r_inb > rlim2 ){ + label14: + b_compartment = 9; + etabin = i-1; + break; + } + + if( d2 < s_StripWidth+s_KapGap ){ + if( z_inb > zlim1 ) { + label15: + b_compartment = 8; + etabin = 2*i+4; + break; + } + + label16: + b_compartment = 8; + etabin = 2*i+3; + break; + } + + if( z_inb < zlim2) goto label14; + if( r_inb > rlim3) goto label16; + if( z_inb > zlim1) goto label15; + goto label16; + //====================================================== + case 12: + + d1=fabs( DistanceToEtaLine( pforcell, eta1) ); + d2=fabs( DistanceToEtaLine( pforcell, eta2) ); + + if( d1 < s_StripWidth+s_KapGap ){ + b_compartment = 8; + etabin = 2*i+2; + break; + } + if( d2 < s_StripWidth+s_KapGap ){ + label17: + b_compartment = 8; + etabin = 2*i+3; + break; + } + + if( r_inb > rlim2 || z_inb < zlim1 ){ + b_compartment = 9; + etabin = i-1; + break; + } + goto label17; + + //======================================================== + + case 14: + case 15: + + d1=fabs( DistanceToEtaLine( pforcell, eta1) ); + d2=fabs( DistanceToEtaLine( pforcell, eta2) ); + + if( d1 < s_StripWidth+s_KapGap ){ + label18: + b_compartment = 8; + etabin = 2*i+2; + break; + } + if( d2 < s_StripWidth+s_KapGap ){ + label19: + b_compartment = 8; + etabin = 2*i+3; + break; + } + if( r_inb > rlim1 && z_inb > zlim1 ) goto label18; + if( r_inb < rlim2 && z_inb > zlim2 ) goto label19; + + b_compartment = 9; + etabin = i-1; + break; + //====================================================== + + case 17: + + d1=fabs( DistanceToEtaLine( pforcell, eta1) ); + + if( d1 < s_StripWidth+s_KapGap || z_inb > zlim1 ){ + b_compartment = 8; + etabin = 2*i+2; + break; + } + b_compartment = 9; + etabin = i-1; + break; + } + + //====================================================== + + + // end of search for compartment and etabin + + label99: + return validhit; } // **************************************************************************** -G4bool EnergyCalculator::GetVolumeIndex(const G4Step *step) const{ -// **************************************************************************** - ModuleNumber = -999; - PhiDivNumber = -999; +G4bool EnergyCalculator::GetVolumeIndex(const G4Step *step, G4int & ModuleNumber, G4int & PhiDivNumber) const{ + // **************************************************************************** const G4StepPoint* pre_step_point = step->GetPreStepPoint(); const G4int ndepth = pre_step_point->GetTouchable()->GetHistoryDepth(); for(G4int i=0;i<=ndepth;++i){ - G4String ivolname=pre_step_point->GetTouchable()->GetVolume(i)->GetName(); + G4String ivolname=pre_step_point->GetTouchable()->GetVolume(i)->GetName(); if( ivolname.find("BackOuterBarrette::Module") != std::string::npos ){ ModuleNumber = pre_step_point->GetTouchable()->GetVolume(i)->GetCopyNo(); } @@ -2190,375 +2153,296 @@ G4bool EnergyCalculator::GetVolumeIndex(const G4Step *step) const{ } // **************************************************************************** G4bool EnergyCalculator::FindIdentifier_Barrett( - const G4Step* step, - std::vector<LArHitData>& hdata, - G4ThreeVector &startPointLocal, - G4ThreeVector &endPointLocal - ){ -// **************************************************************************** -// works only for outer part of the full wheel or of the module in the Barrett -// at the back side of EMEC - -// check whether we are in the outer wheel - if(lwc()->type() != LArWheelCalculator::OuterAbsorberWheel && lwc()->type() != LArWheelCalculator::OuterAbsorberModule) { - (*m_msg) << MSG::FATAL - << " ERROR ::FindIdentifier_Barrett, not yet prepared for solidtype=" - << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) - << endreq; - } - - G4bool validhit=true; - -// Get point coordinates in the Atlas coord. system - - const G4StepPoint* pre_step_point = step->GetPreStepPoint(); - const G4StepPoint* post_step_point = step->GetPostStepPoint(); - - const G4ThreeVector startPoint = pre_step_point->GetPosition(); - const G4ThreeVector endPoint = post_step_point->GetPosition(); - // G4ThreeVector p = 0.5 *(startPoint+endPoint); - const G4ThreeVector p = startPoint; // bec. middle point maybe out of volume - - // transform point to the coord system of Barrett::Module::Phidiv (alias local) - - const G4AffineTransform transformation = - pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); - startPointLocal = transformation.TransformPoint(startPoint); - endPointLocal = transformation.TransformPoint(endPoint); - // G4ThreeVector pinLocal = 0.5 * (startPointLocal + endPointLocal); - const G4ThreeVector pinLocal = startPointLocal; - -// get Module and Phidiv number (result is put into static VolumeNumber and PhiDivNumber) - - validhit=GetVolumeIndex(step); - if(!validhit){ - //std::cout - (*m_msg) << MSG::FATAL - <<" ERROR ::FindIdentifier_Barrett:Module, Phidiv is not found" - <<" ModuleNumber= "<<ModuleNumber<<" PhiDivNumber= "<<PhiDivNumber - <<endreq; - // <<std::endl; - } - -//z,r,eta,phi_inb : Specific for Barrette at the Back side of EMEC!! - - G4double phi_inb=0.; - - const G4double z_inb= lwc()->GetdWRPtoFrontFace()/2.-pinLocal.z(); //dist. from front end of the Back Barrettes - const G4double r_inb= pinLocal.perp(); //dist from the z axis - const G4ThreeVector pforcell=G4ThreeVector( pinLocal.x(), pinLocal.y(), - lwc()->GetElecFocaltoWRP()+lwc()->GetdWRPtoFrontFace()+lwc()->GetWheelThickness()+z_inb ); - const G4double eta_inb=pforcell.pseudoRapidity(); //eta in the system where electrodes were designed - - if(lwc()->type() == LArWheelCalculator::OuterAbsorberWheel){ // for wheel calculation - PhiStartOfPhiDiv = lwc()->GetFanStepOnPhi()/2. + ModuleNumber * CLHEP::twopi/8. - + PhiDivNumber * lwc()->GetFanStepOnPhi(); - phi_inb = PhiStartOfPhiDiv + pinLocal.phi(); //in ::BackOuterBarrettes - if(phi_inb < 0.) phi_inb = phi_inb + CLHEP::twopi; - if(phi_inb > CLHEP::twopi) phi_inb = phi_inb - CLHEP::twopi; - phi_inb = CLHEP::twopi - phi_inb; // phi in ::EmecMother system; - } - else if(lwc()->type() == LArWheelCalculator::OuterAbsorberModule){ // for TB modul calculation - - G4double PhiStart = M_PI_2 - M_PI/8.; //this is from EMECSupportConstruction - PhiStartOfPhiDiv = PhiStart + lwc()->GetFanStepOnPhi()/2 + PhiDivNumber * lwc()->GetFanStepOnPhi(); - - phi_inb = PhiStartOfPhiDiv + pinLocal.phi(); //in BackOuterBarrettes; - phi_inb = M_PI - phi_inb; // phi in ::EmecMother system; - } + const G4Step* step, + G4double PhiStartOfPhiDiv, + std::vector<LArHitData>& hdata, + G4ThreeVector &startPointLocal, + G4ThreeVector &endPointLocal + ) const { + // **************************************************************************** + // works only for outer part of the full wheel or of the module in the Barrett + // at the back side of EMEC + + // check whether we are in the outer wheel + if(lwc()->type() != LArG4::OuterAbsorberWheel && lwc()->type() != LArG4::OuterAbsorberModule) { + ATH_MSG_FATAL(" ERROR ::FindIdentifier_Barrett, not yet prepared for solidtype=" + << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())); + } + + G4bool validhit=true; - G4int compartment,etabin,phigap,etaBin,phiBin; + // Get point coordinates in the Atlas coord. system -// get m_compartment and etaBin + const G4StepPoint* pre_step_point = step->GetPreStepPoint(); + const G4StepPoint* post_step_point = step->GetPostStepPoint(); - validhit=GetCompartment_Barrett(pforcell, r_inb, z_inb, eta_inb, compartment, etabin); + const G4ThreeVector startPoint = pre_step_point->GetPosition(); + const G4ThreeVector endPoint = post_step_point->GetPosition(); + // G4ThreeVector p = 0.5 *(startPoint+endPoint); + const G4ThreeVector p = startPoint; // bec. middle point maybe out of volume - m_compartment = compartment; - etaBin = etabin; - if (!validhit) { - m_compartment = 9; // to have some 'reasonable' number - etaBin = 0; - } + // transform point to the coord system of Barrett::Module::Phidiv (alias local) - const G4int c = m_compartment-1; + const G4AffineTransform transformation = + pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); + startPointLocal = transformation.TransformPoint(startPoint); + endPointLocal = transformation.TransformPoint(endPoint); + // G4ThreeVector pinLocal = 0.5 * (startPointLocal + endPointLocal); + const G4ThreeVector pinLocal = startPointLocal; - G4int sampling = geometry[c].sampling; - G4int region = geometry[c].region; + //------ code transfered to getPhiStartOfPhiDiv ------// -// get m_AtlasZside, it is negative if z<0. + const G4double z_inb= lwc()->GetdWRPtoFrontFace()/2.-pinLocal.z(); //dist. from front end of the Back Barrettes + const G4double r_inb= pinLocal.perp(); //dist from the z axis + const G4ThreeVector pforcell=G4ThreeVector( pinLocal.x(), pinLocal.y(), + lwc()->GetElecFocaltoWRP()+lwc()->GetdWRPtoFrontFace()+lwc()->GetWheelThickness()+z_inb ); + const G4double eta_inb=pforcell.pseudoRapidity(); //eta in the system where electrodes were designed -// DM 2015-07-30 -// copy of -// 19-04-2007 AMS use constant m_AtlasZside obtained in constructor - // zSide is negative if z<0. -// m_AtlasZside = geometry[c].zSide; -// if(p.z() < 0.) m_AtlasZside = -m_AtlasZside; -// G4int atlasside = m_AtlasZside; - const G4int atlasside = lwc()->GetAtlasZside() * geometry[c].zSide; + G4int compartment,etabin; - if(lwc()->GetisModule() && atlasside < 0 ) { - (*m_msg) << MSG::FATAL - <<"EnergyCalculator: TB modul should be at pos z" - <<endreq; - } + // get m_compartment and etaBin -// In future version we may use constant m_AtlasZside set by constructor, -// don't know if it is necessary for barettes -// G4int atlasside = m_AtlasZside * geometry[c].zSide; + validhit=GetCompartment_Barrett(pforcell, r_inb, z_inb, eta_inb, compartment, etabin); -// get phiBin + G4int m_compartment = compartment; + G4int etaBin = etabin; + if (!validhit) { + m_compartment = 9; // to have some 'reasonable' number + etaBin = 0; + } - phigap = GetPhiGap_Barrett(pinLocal); // in wheel numbering scheme - //int phigapwheel=phigap; //for check + const G4int c = m_compartment-1; - if(lwc()->GetisModule()) { - phigap = phigap - lwc()->GetStartGapNumber() + lwc()->GetLastFan()/2; // in module numbering scheme + G4int sampling = geometry[c].sampling; + G4int region = geometry[c].region; -/* -//CHECK!!in Module - int phigapmodul=phigap; - G4ThreeVector tmp=G4ThreeVector( r_inb*cos(phi_inb),r_inb*sin(phi_inb),0.01 ); - int phigapmodulx=LArWheelCalculator::GetPhiGap(tmp); // module numbering scheme - int phigapwheelx=lwc()->PhiGapNumberForWheel(phigapmodulx); // transformed to wheelnumbering - - if(phigapwheel != phigapwheelx) - std::cout<<"*** FindIdentifier_BArrett:ERROR:phigapwheel=" - <<phigapwheel<<" phigapwheelx="<<phigapwheelx - <<std::endl; - else std::cout<<"*** checked--wheel--Ok"<<std::endl; - if(phigapmodul != phigapmodulx) - std::cout<<"*** FindIdentifier_BArrett:ERROR:phigapmodul=" - <<phigapmodul<<" phigapmodulx="<<phigapmodulx - <<" FirstFan="<<FirstFan<<" LastFan="<<LastFan - <<std::endl; - else std::cout<<"*** checked--modul--Ok"<<std::endl; -// --- end CHECK -*/ + const G4int atlasside = lwc()->GetAtlasZside() * geometry[c].zSide; + + if(lwc()->GetisModule() && atlasside < 0 ) { + ATH_MSG_FATAL("EnergyCalculator: TB modul should be at pos z"); + } + + // get phiBin + G4int phigap = GetPhiGap_Barrett(pinLocal, PhiStartOfPhiDiv); // in wheel numbering scheme + //int phigapwheel=phigap; //for check - if(phigap < lwc()->GetFirstFan() || phigap >= lwc()->GetLastFan()){ - if (phigap<lwc()->GetFirstFan()) phigap=lwc()->GetFirstFan(); - if (phigap>=lwc()->GetLastFan()) phigap=lwc()->GetLastFan()-1; - validhit=false; - } - } + if(lwc()->GetisModule()) { + phigap = phigap - lwc()->GetStartGapNumber() + lwc()->GetLastFan()/2; // in module numbering scheme - phiBin = phigap / geometry[c].gapsPerBin; + if(phigap < lwc()->GetFirstFan() || phigap >= lwc()->GetLastFan()){ + if (phigap<lwc()->GetFirstFan()) phigap=lwc()->GetFirstFan(); + if (phigap>=lwc()->GetLastFan()) phigap=lwc()->GetLastFan()-1; + validhit=false; + } + } + + G4int phiBin = phigap / geometry[c].gapsPerBin; - if(atlasside < 0){ + if(atlasside < 0){ // The following formula assumes that the z<0 endcap was derived // from the positive endcap by rotateY(180.*deg) // 29-March-2004 ML - phiBin = (geometry[c].maxPhi - 1)/2 - phiBin; - if(phiBin < 0) phiBin += geometry[c].maxPhi + 1; - } + phiBin = (geometry[c].maxPhi - 1)/2 - phiBin; + if(phiBin < 0) phiBin += geometry[c].maxPhi + 1; + } -// checks for phiBin and etaBin + // checks for phiBin and etaBin - if(phiBin<0) { - (*m_msg) << MSG::WARNING - << "FindIdentifier_Barrett: invalid hit, phiBin < 0" - << endreq; - phiBin=0; - validhit=false; - } - if(phiBin>geometry[c].maxPhi) { - (*m_msg) << MSG::WARNING - << "FindIdentifier_Barrett: invalid hit, phiBin = " << phiBin - << " > geometry[" << c << "].maxPhi="<< geometry[c].maxPhi - << endreq; - phiBin=geometry[c].maxPhi; - validhit=false; - } - if(etaBin < 0){ - (*m_msg) << MSG::WARNING - << "FindIdentifier_Barrett: invalid hit, etaBin < 0" - << endreq; - etaBin=0; - validhit=false; - } - if(etaBin > geometry[c].maxEta){ - (*m_msg) << MSG::WARNING - << "FindIdentifier_Barrett: invalid hit, etaBin = " - << etaBin << " > geometry[" << c << "].maxEta=" - << geometry[c].maxEta << endreq; - etaBin=geometry[c].maxEta; - validhit=false; - } + if(phiBin<0) { + ATH_MSG_WARNING("FindIdentifier_Barrett: invalid hit, phiBin < 0"); + phiBin=0; + validhit=false; + } + if(phiBin>geometry[c].maxPhi) { + ATH_MSG_WARNING("FindIdentifier_Barrett: invalid hit, phiBin = " << phiBin + << " > geometry[" << c << "].maxPhi="<< geometry[c].maxPhi); + phiBin=geometry[c].maxPhi; + validhit=false; + } + if(etaBin < 0){ + ATH_MSG_WARNING("FindIdentifier_Barrett: invalid hit, etaBin < 0"); + etaBin=0; + validhit=false; + } + if(etaBin > geometry[c].maxEta){ + ATH_MSG_WARNING("FindIdentifier_Barrett: invalid hit, etaBin = " + << etaBin << " > geometry[" << c << "].maxEta=" + << geometry[c].maxEta); + etaBin=geometry[c].maxEta; + validhit=false; + } - hdata[0].id.clear(); - hdata[0].id << 4 // LArCalorimeter - << 1 // LArEM - << atlasside - << sampling - << region - << etaBin - << phiBin; - - G4double timeOfFlight = 0.5 * - ( pre_step_point->GetGlobalTime() + - post_step_point->GetGlobalTime() ); - hdata[0].time = timeOfFlight/CLHEP::ns - p.mag()/CLHEP::c_light/CLHEP::ns; - if (hdata[0].time > m_OOTcut) m_isInTime = false; - else m_isInTime = true; - - return validhit; + hdata[0].id.clear(); + hdata[0].id << 4 // LArCalorimeter + << 1 // LArEM + << atlasside + << sampling + << region + << etaBin + << phiBin; + + G4double timeOfFlight = 0.5 * + ( pre_step_point->GetGlobalTime() + + post_step_point->GetGlobalTime() ); + hdata[0].time = timeOfFlight/Units::ns - p.mag()/CLHEP::c_light/Units::ns; + + return validhit; } // **************************************************************************** -G4bool EnergyCalculator::FindDMIdentifier_Barrett(const G4Step* step, std::vector<LArHitData>& hdata){ -// **************************************************************************** +G4bool EnergyCalculator::FindDMIdentifier_Barrett(const G4Step* step, std::vector<LArHitData>& hdata) const { + // **************************************************************************** - G4bool validid = false; + // G4bool validid = false; + // hdata[0].id = LArG4Identifier(); + // G4bool validid = m_supportCalculator->Process(step, LArG4::VCalibrationCalculator::kOnlyID); + // hdata[0].id = m_supportCalculator->identifier(); + // return validid; hdata[0].id = LArG4Identifier(); + std::vector<G4double> _tmpv; + return m_supportCalculator->Process(step, hdata[0].id, _tmpv, LArG4::kOnlyID ); +} - validid = m_supportCalculator->Process(step,LArG4::VCalibrationCalculator::kOnlyID); - hdata[0].id = m_supportCalculator->identifier(); +G4double EnergyCalculator::_AdjustedPhiOfPoint_Barrett(const G4ThreeVector& p, G4double PhiStartOfPhiDiv) const { + // G4double phi=p.phi(); // in Module::Phidiv + // phi = PhiStartOfPhiDiv + phi; // in Barrette + // if(phi < 0. ) phi=phi+CLHEP::twopi; + // if(phi >= CLHEP::twopi ) phi=phi-CLHEP::twopi; - return validid; + // if(lwc()->GetisModule()) phi = M_PI - phi; // in EMECMother; TB modul + // else phi = CLHEP::twopi - phi; // in EMECMother; full wheel + + return (lwc()->GetisModule()) ? + CLHEP::pi - _normalizeAngle2Pi(PhiStartOfPhiDiv + p.phi()) // in EMECMother; TB modul + : + CLHEP::twopi - _normalizeAngle2Pi(PhiStartOfPhiDiv + p.phi()) // in EMECMother; full wheel + ; } //**************************************************************************** -G4int EnergyCalculator::GetPhiGap_Barrett(const G4ThreeVector& p) const { -// **************************************************************************** - G4double phi=p.phi(); // in Module::Phidiv - phi = PhiStartOfPhiDiv + phi; // in Barrette - if(phi < 0. ) phi=phi+CLHEP::twopi; - if(phi >= CLHEP::twopi ) phi=phi-CLHEP::twopi; - - if(lwc()->GetisModule()) phi = M_PI - phi; // in EMECMother; TB modul - else phi = CLHEP::twopi - phi; // in EMECMother; full wheel - +G4int EnergyCalculator::GetPhiGap_Barrett(const G4ThreeVector& p, G4double PhiStartOfPhiDiv) const { + // **************************************************************************** + const G4double phi = _AdjustedPhiOfPoint_Barrett(p, PhiStartOfPhiDiv); if(phi > CLHEP::twopi-lwc()->GetFanStepOnPhi()*0.5) {return 0;} return (G4int( (phi+lwc()->GetFanStepOnPhi()*0.5)/lwc()->GetFanStepOnPhi()) ); } // **************************************************************************** G4double EnergyCalculator::GetGapSize_Barrett(const G4ThreeVector& p) const { -// **************************************************************************** + // **************************************************************************** const G4double r=p.perp(); - const G4double ta1=1./ sqrt(4.*r/FanAbsThickness*r/FanAbsThickness - 1.); - const G4double ta2=1./ sqrt(4.*r/FanEleThickness*r/FanEleThickness - 1.); + const G4double ta1=1./ sqrt(4.*r/FanAbsThickness()*r/FanAbsThickness() - 1.); + const G4double ta2=1./ sqrt(4.*r/FanEleThickness()*r/FanEleThickness() - 1.); const G4double phieff= lwc()->GetFanStepOnPhi()*0.5-atan(ta1)-atan(ta2); return (r*phieff); } // **************************************************************************** G4double EnergyCalculator::distance_to_the_nearest_electrode_Barrett( - const G4ThreeVector &p) const { -// **************************************************************************** - G4double phi=p.phi(); // in Module::Phidiv - phi = PhiStartOfPhiDiv + phi; // in Barrette - if(phi < 0. ) phi=phi+CLHEP::twopi; - if(phi >= CLHEP::twopi ) phi=phi-CLHEP::twopi; - - if(lwc()->GetisModule()) phi = M_PI - phi; // in EMECMother; TB modul - else phi = CLHEP::twopi - phi; // in EMECMother; full wheel + const G4ThreeVector &p, + G4double PhiStartOfPhiDiv + ) const { + // **************************************************************************** + const G4double phi = _AdjustedPhiOfPoint_Barrett(p, PhiStartOfPhiDiv); G4double r=p.perp(); G4int igap; G4double elephi,dphi; if (phi > CLHEP::twopi-lwc()->GetFanStepOnPhi()*0.5) { - dphi=phi-CLHEP::twopi; + dphi=phi-CLHEP::twopi; } else { - igap=G4int( (phi+lwc()->GetFanStepOnPhi()*0.5)/lwc()->GetFanStepOnPhi() ); + igap=G4int( (phi+lwc()->GetFanStepOnPhi()*0.5)/lwc()->GetFanStepOnPhi() ); elephi=igap*lwc()->GetFanStepOnPhi(); - dphi=phi-elephi; + dphi=phi-elephi; } - G4double dist=r*sin(fabs(dphi))-FanEleThickness*0.5; + G4double dist=r*sin(fabs(dphi))-FanEleThickness()*0.5; return fabs(dist); } // **************************************************************************** -G4double EnergyCalculator::GetHV_Value_Barrett(const G4ThreeVector& p) const { -// **************************************************************************** - -// get atlasside - - const G4int atlasside = (lwc()->GetAtlasZside() > 0) ? 0 : 1; - -// get etasection - - const G4double z_inb = lwc()->GetdWRPtoFrontFace() * 0.5-p.z(); //dist. from front end of the Back Barrettes - const G4double r_inb= p.perp(); //dist from the z axis - const G4ThreeVector pforcell=G4ThreeVector( p.x(), p.y(), - lwc()->GetElecFocaltoWRP()+lwc()->GetdWRPtoFrontFace()+lwc()->GetWheelThickness()+z_inb ); - const G4double eta_inb=pforcell.pseudoRapidity(); //eta in the system where electrodes were designed - - G4int compartment=-99; G4int etabin=-99; G4int etasection=-99; - - G4bool validhit=GetCompartment_Barrett(pforcell, r_inb, z_inb, eta_inb, compartment, etabin); - - if(!validhit) { return 0.;} // p is not in the sens. region - - switch (compartment) { - - case 8: - if( etabin < 0) { validhit=false; break;} - if( etabin <= 3) { etasection = 0; break;} - if( etabin <= 7) { etasection = 1; break;} - if( etabin <= 15) { etasection = 2; break;} - if( etabin <= 23) { etasection = 3; break;} - if( etabin <= 27) { etasection = 4; break;} - if( etabin <= 35) { etasection = 5; break;} - if( etabin <= 43) { etasection = 6; break;} - validhit=false; - break; - - case 9: - if( etabin < 0) { validhit=false; break;} - if( etabin <= 1) { etasection = 1; break;} - if( etabin <= 5) { etasection = 2; break;} - if( etabin <= 9) { etasection = 3; break;} - if( etabin <= 11) { etasection = 4; break;} - if( etabin <= 15) { etasection = 5; break;} - if( etabin <= 19) { etasection = 6; break;} - validhit=false; - break; - - default: - validhit=false; - break; - } - - if(!validhit) { return 0.;} // p is not in the sens. region +G4double EnergyCalculator::GetHV_Value_Barrett(const G4ThreeVector& p, G4double PhiStartOfPhiDiv) const { + // **************************************************************************** + + // get atlasside + const G4int atlasside = (lwc()->GetAtlasZside() > 0) ? 0 : 1; + + // get etasection + const G4double z_inb = lwc()->GetdWRPtoFrontFace() * 0.5-p.z(); //dist. from front end of the Back Barrettes + const G4double r_inb= p.perp(); //dist from the z axis + const G4ThreeVector pforcell=G4ThreeVector( p.x(), p.y(), + lwc()->GetElecFocaltoWRP()+lwc()->GetdWRPtoFrontFace()+lwc()->GetWheelThickness()+z_inb ); + const G4double eta_inb=pforcell.pseudoRapidity(); //eta in the system where electrodes were designed + + G4int compartment=-99; G4int etabin=-99; G4int etasection=-99; + + G4bool validhit=GetCompartment_Barrett(pforcell, r_inb, z_inb, eta_inb, compartment, etabin); + + if(!validhit) { return 0.;} // p is not in the sens. region + + switch (compartment) { + case 8: + if( etabin < 0) { validhit=false; break;} + if( etabin <= 3) { etasection = 0; break;} + if( etabin <= 7) { etasection = 1; break;} + if( etabin <= 15) { etasection = 2; break;} + if( etabin <= 23) { etasection = 3; break;} + if( etabin <= 27) { etasection = 4; break;} + if( etabin <= 35) { etasection = 5; break;} + if( etabin <= 43) { etasection = 6; break;} + validhit=false; + break; + + case 9: + if( etabin < 0) { validhit=false; break;} + if( etabin <= 1) { etasection = 1; break;} + if( etabin <= 5) { etasection = 2; break;} + if( etabin <= 9) { etasection = 3; break;} + if( etabin <= 11) { etasection = 4; break;} + if( etabin <= 15) { etasection = 5; break;} + if( etabin <= 19) { etasection = 6; break;} + validhit=false; + break; + + default: + validhit=false; + break; + } -// get electrode number and side + if(!validhit) { return 0.;} // p is not in the sens. region - G4double phi=p.phi(); // in Module::Phidiv - phi = PhiStartOfPhiDiv + phi; // in Barrette - if(phi < 0. ) phi=phi+CLHEP::twopi; - if(phi >= CLHEP::twopi ) phi=phi-CLHEP::twopi; + // get electrode number and side - if(lwc()->GetisModule()) phi = M_PI - phi; // in EMECMother; TB modul - else phi = CLHEP::twopi - phi; // in EMECMother; full wheel + const G4double phi = _AdjustedPhiOfPoint_Barrett(p, PhiStartOfPhiDiv); G4int igap,iside; - if (phi > CLHEP::twopi-lwc()->GetFanStepOnPhi()*0.5){igap=0;iside=0;} - else{ igap=G4int( (phi+lwc()->GetFanStepOnPhi()*0.5)/lwc()->GetFanStepOnPhi() ); - G4double elephi=igap*lwc()->GetFanStepOnPhi(); - G4double dphi=phi-elephi; - if(dphi <=0. ) iside=0; - else iside=1; + if (phi > CLHEP::twopi-lwc()->GetFanStepOnPhi()*0.5) { + igap=0; + iside=0; + } else { + igap=G4int( (phi+lwc()->GetFanStepOnPhi()*0.5)/lwc()->GetFanStepOnPhi() ); + const G4double elephi=igap*lwc()->GetFanStepOnPhi(); + const G4double dphi=phi-elephi; + if (dphi <=0.) iside=0; + else iside=1; } const G4int electrodenumber = igap; const G4int electrodeside = iside; -// prepare indices for different versions of HV Map + // prepare indices for different versions of HV Map + + const G4int firstelectrode = s_HV_Start_phi[atlasside][etasection][electrodeside]; - G4int firstelectrode = HV_Start_phi[atlasside][etasection][electrodeside]; G4int electrodeindex = electrodenumber-firstelectrode; if(electrodeindex < 0) electrodeindex += lwc()->GetNumberOfFans(); - G4int phisection = electrodeindex / NumberOfElectrodesInPhiSection; - assert(phisection>=0 && phisection<=NofPhiSections-1); + const G4int phisection = electrodeindex / NumberOfElectrodesInPhiSection(); + + assert(phisection>=0 && phisection<=NofPhiSections()-1); -// pick up HV value from the array + // pick up HV value from the array - G4double HV_value= HV_Values[atlasside][etasection][electrodeside][phisection]; + G4double HV_value= s_HV_Values[atlasside][etasection][electrodeside][phisection]; return HV_value; } - - - diff --git a/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.h new file mode 100644 index 000000000000..f3253ce0f666 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/src/EnergyCalculator.h @@ -0,0 +1,391 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// EnergyCalculator.h +// Prepared 10-Apr-2002 Bill Seligman +// from code written by Jozsef Toth. +// 07-May-2003 AMS: now EnergyCalculator is not a singleton +// 02-July-2003 J.T. Charge collection added +// 20-July-2004 J.T. FieldMapVersion variable is added +// 25-May-2005 J.T. -calling sequence of GapAdj changed +// -new variables and function for reading and handling +// values of HV of power supplies +// - IonReco :for suppress signal because of ion recombination +// - DriftVelo: Walkowiak's formula for drift velocity +// Sept-2006 J.T. - collect signal from the Barrette volume +// Nov -2006 J.T. - fieldmap array structures changed, +// - lengths defined dinamically +// - field map for first/last fold and for Barrett volume are included +// May 2009 AMS move to namespace LArG4::EC +// duplicated data members removed + +#ifndef LArG4_EC_EnergyCalculator_H +#define LArG4_EC_EnergyCalculator_H + +#include <string> +#include <stdexcept> + +#include "CLHEP/Units/SystemOfUnits.h" + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include "LArG4Code/LArG4EnumDefs.h" + +#include "GeoSpecialShapes/LArWheelCalculator.h" +#include "GeoSpecialShapes/LArWheelCalculatorEnums.h" + +#include "G4ThreeVector.hh" +#include "globals.hh" + + +class ILArCalibCalculatorSvc; +class LArG4BirksLaw; + + +namespace LArG4 { + + namespace EC { + + + class EnergyCalculator : public LArCalculatorSvcImp + { + public: + + EnergyCalculator(const std::string& name, ISvcLocator *pSvcLocator); + // Update handlers + void CorrectionTypeHandler(Property&); + void SolidTypeHandler(Property&); + + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + + ///////////////////////////////////////////// + // The interface for LArVCalculator. + virtual G4float OOTcut() const override final { return m_OOTcut; } + virtual G4bool Process(const G4Step*, std::vector<LArHitData>&) const override final; + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); //FIXME should we be checking the absolute value of hitTime here? + } + + + private: + + //G4int m_compartment; -> made local for FindIdentifier functions + + G4bool (EnergyCalculator::*m_Process_type) (const G4Step*, std::vector<LArHitData>&) const; + G4double (EnergyCalculator::*m_GetHV_Value_type) (const G4ThreeVector &p, G4double /*Barret_PhiStart*/) const; + G4double (EnergyCalculator::*m_GetGapSize_type) (const G4ThreeVector &p) const; + G4double (EnergyCalculator::*m_distance_to_the_nearest_electrode_type) (const G4ThreeVector &p, G4double /*Barret_PhiStart*/) const; + + G4bool Process_Default(const G4Step*, std::vector<LArHitData>&) const; + G4bool Process_Barrett(const G4Step*, std::vector<LArHitData>&) const; + G4bool FindIdentifier_Default(const G4Step *, std::vector<LArHitData>&, G4ThreeVector &, G4ThreeVector &) const; + G4bool FindIdentifier_Barrett(const G4Step *, G4double, std::vector<LArHitData>&, G4ThreeVector &, G4ThreeVector &) const; + G4bool FindDMIdentifier_Barrett(const G4Step* step, std::vector<LArHitData>&) const; + G4bool GetCompartment_Barrett(G4ThreeVector,G4double,G4double,G4double, + G4int &, G4int &) const; + G4double GetHV_Value_Default(const G4ThreeVector& p, G4double /*Barret_PhiStart*/) const { + return GetHV_Value(p); + } + G4double GetHV_Value_Barrett(const G4ThreeVector& p, G4double PhiStartOfPhiDiv) const; + G4double GetGapSize_Default(const G4ThreeVector &p) const { + return GetGapSize(p); + } + G4double GetGapSize_Barrett(const G4ThreeVector &p) const; + G4int GetPhiGap_Barrett(const G4ThreeVector &p, G4double PhiStartOfPhiDiv) const; + G4double distance_to_the_nearest_electrode_Default(const G4ThreeVector &p, G4double /*Barret_PhiStart*/) const { + return distance_to_the_nearest_electrode(p); + } + G4double distance_to_the_nearest_electrode_Barrett(const G4ThreeVector &p, G4double Barret_PhiStart) const; + + ServiceHandle<ILArCalibCalculatorSvc> m_supportCalculator; + + static void SetConst_OuterBarrett(void); // used only for initialization + static void SetConst_InnerBarrett(void); // used only for initialization + G4bool GetVolumeIndex(const G4Step *, G4int &, G4int &) const; + static G4bool s_SetConstOuterBarrett; // used as const after init + static G4bool s_SetConstInnerBarrett; // used as const after init + static const G4double s_LongBarThickness;// = 20. *mm; + static const G4double s_ColdCorrection;// =1.0036256; + static const G4double s_StripWidth;// =3.*mm/ColdCorrection; + static const G4double s_KapGap;// =1.*mm/ColdCorrection; + static const G4double s_EdgeWidth;// =1.*mm; + static const G4double s_DistOfEndofCuFromBack;// =22.77*mm/ColdCorrection; + static const G4double s_DistOfStartofCuFromBack;//=31.*mm; // frontface of the barrette + static const G4double s_ZmaxOfSignal;// DistOfStartofCuFromBack - DistOfEndofCuFromBack + EdgeWidth; + static G4double s_RefzDist; // = dElecFocaltoWRP+dWRPtoFrontFace+WheelThickness+ // used as const after + // +dWRPtoFrontFace+ LongBarThickness // initialization + // -DistOfEndofCuFromBack + + static const G4double s_S3_Etalim[21]; + static const G4double s_Rmeas_outer[50]; + static const G4double s_Zmeas_outer[2]; + static G4double s_S3_Rlim[21]; // used as const after init + static G4double s_rlim[50]; // used as const after init + static G4double s_zlim[4]; // used as const after init + + UnsignedIntegerProperty m_corrProp; + EnergyCorrection_t m_correction_type; + + G4double (EnergyCalculator::*m_ecorr_method) (G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double dummy_correction_method(G4double e, const G4ThreeVector&, const G4ThreeVector&, + G4double /*Barret_PhiStart*/) const { + return e; + } + G4double GapAdjustment_old(G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double GapAdjustment (G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double GapAdjustment_E (G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double GapAdjustment_s (G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double GapAdjustment__sE (G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double CalculateChargeCollection(G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + G4double CalculateChargeCollection1(G4double, const G4ThreeVector&, const G4ThreeVector&, G4double /*Barret_PhiStart*/) const; + + G4double m_GApower; // used as const after init + inline G4double GApower() const { return m_GApower; }; + + // ************************************************************************** + //Declaration of variables,functions for charge collection + //J.T + // ************************************************************************** + + + //variables specific for wheel geometry + struct WheelGeometry { + G4int PhiGapNumber, PhiHalfGapNumber; + G4int HalfWaveNumber, SignofZinHalfWave, SignofSlopeofHalfWave; + G4double SinPhiGap, CosPhiGap, ZinHalfWave; + G4double HalfEleThickness; + WheelGeometry() : + PhiGapNumber(0), + PhiHalfGapNumber(0), + HalfWaveNumber(0), + SignofZinHalfWave(0), + SignofSlopeofHalfWave(0), + SinPhiGap(0), + CosPhiGap(0), + ZinHalfWave(0), + HalfEleThickness(0) + {} + }; + + + G4double m_ElectrodeFanHalfThickness; // used as const after init + G4double m_FanEleThicknessOld; // used as const after init + G4double m_FanEleFoldRadiusOld; // used as const after init + G4double m_FanAbsThickness; // used as const after init + G4double m_FanEleThickness; // used as const after init + G4double m_WaveLength; // used as const after init + + G4int m_NofPhiSections; // used as const after init + G4int m_NumberOfElectrodesInPhiSection; // used as const after init + + inline G4double ElectrodeFanHalfThickness() const { return m_ElectrodeFanHalfThickness; }; + inline G4double FanEleThicknessOld() const { return m_FanEleThicknessOld; }; + inline G4double FanEleFoldRadiusOld() const { return m_FanEleFoldRadiusOld; }; + inline G4double FanAbsThickness() const { return m_FanAbsThickness; }; + inline G4double FanEleThickness() const { return m_FanEleThickness; }; + inline G4double WaveLength() const { return m_WaveLength; }; + + inline G4int NofPhiSections() const { return m_NofPhiSections; }; + inline G4int NumberOfElectrodesInPhiSection() const { return m_NumberOfElectrodesInPhiSection; }; + + //variables specific for Efield calculation + + static G4bool s_FieldMapsRead; // used as const after init + static G4String s_FieldMapVersion; // used as const after init + + static const G4double s_GridSize; + static const G4double s_AverageGap; + static const G4double s_inv_AverageGap; + + struct Fold_Efield_Map{ + G4bool FieldMapPrepared; + G4double* FieldMap; // [NumberOfRadialLayers][ZYWeight][MaxNofPoints]; + G4double* MinZofLayer; //these are limits of the + G4double* MaxZofLayer; //area where the FieldMap can + G4double* MinYofLayer; //be used for interpolation + G4double* MaxYofLayer; + G4int* NofColofLayer; // a column is parallel to y + G4int* NofRowofLayer; // a row is parallel to z + G4int* NofPointsinLayer; + G4int* pLayer; + }; + + struct Wheel_Efield_Map {G4bool FieldMapPrepared; + G4int NumberOfRadialLayer; + G4double* RadiusOfLayers; + G4double* FoldinAngleOfLayers; + G4double* HalfLArGapSizeOfLayers; + Fold_Efield_Map* Fold; + Fold_Efield_Map Fold0; + Fold_Efield_Map Fold1; + G4double GridShift; + }; + + static Wheel_Efield_Map s_ChCollInner,s_ChCollOuter; // used as const after init + Wheel_Efield_Map* m_ChCollWheelType; // used as const after init + + inline const Wheel_Efield_Map* ChCollWheelType() const { return m_ChCollWheelType; }; + + struct FoldArea { + const Fold_Efield_Map* ChCollFoldType; + G4int PointFoldMapArea; + FoldArea() : + ChCollFoldType(0), + PointFoldMapArea(0) + {} + }; + + //G4double PhiStartOfPhiDiv; + + void CreateArrays(Wheel_Efield_Map &, G4int); + inline G4int Index(const Fold_Efield_Map* foldmap, G4int i, G4int j, G4int k ) const { + return foldmap->pLayer[i]+j*foldmap->NofPointsinLayer[i]+k; + }; + void SetFoldArea(G4double, FoldArea & ) const; + + //HV for current calculation + + static G4bool s_HVMapRead; // used only for initialization + std::string m_HVMapVersion; // used only for initialization + static const G4double s_AverageHV; + static const G4double s_AverageEfield; + static const G4double s_AverageCurrent; + static const G4String s_HVEMECMapFileName; //{"HVEMECMap.dat"}; + + static const G4int s_NofAtlasSide = 2; + static const G4int s_NofEtaSection = 9; + static const G4int s_NofElectrodeSide = 2; + static const G4int s_NofElectrodesOut = 768; + static const G4double s_HV_Etalim[s_NofEtaSection+1]; // = {1.375,1.5,1.6,1.8,2.,2.1,2.3,2.5,2.8,3.2}; + static G4int s_HV_Start_phi[s_NofAtlasSide][s_NofEtaSection][s_NofElectrodeSide]; // used as const after init + static G4double s_HV_Values[s_NofAtlasSide][s_NofEtaSection][s_NofElectrodeSide][s_NofElectrodesOut]; // used as const after init + + static const G4double s_LArTemperature_ECC0;//={88.15}; //K + static const G4double s_LArTemperature_ECC1;//={88.37}; + static const G4double s_LArTemperature_ECC5;//={87.97}; + static const G4double s_LArTemperature_av ;// ={88.16}; + + void GetHVMap(const G4String); // used only for initialization + G4double GetHV_Value(const G4ThreeVector& p) const; + G4double GetHV_Value_ChColl_Wheel( const G4ThreeVector& , G4int , G4int) const; + + //Efield in [kv/cm], driftvelo in [mm/microsec], Temperature in [K] + + inline static G4double IonReco(const G4double Efield) { + if(Efield<=0.000001){return 0.;} + if(Efield>2.) {return (1./(1. +0.36/Efield));} + return (1./(1.04+0.28/Efield)); + } + + inline static G4double DriftVelo(const G4double T, const G4double Efield) { + if( Efield <= 0.000001) {return 0.;} + return ( (-0.01481*(T-90.371)+1.)* + ( 0.141*Efield*log(1.+12.4/Efield)+ + 1.627*pow(Efield,0.317) ) + -0.0075*(T-90.371) + ); + } + + // functions specific for geometry + + void SetHalfWave(G4double, WheelGeometry &) const; + void GetPhiGap(const G4double *, WheelGeometry &) const; + void SetYlimitsofPhigapinWheel(G4double, G4double, const WheelGeometry & wg, G4double * Ylimits) const; + G4double YofSurface(G4double,G4double,G4double,const WheelGeometry &) const; + inline G4double YofNeutralFibre(G4double alpha,G4double rho, const WheelGeometry & wg) const { + return YofSurface(alpha,rho,0., wg); + } + G4double FoldingAngle(G4double) const; + G4double HalfLArGapSize(G4double, G4double) const; + + // functions specific for charge coll. + + void IniGeomforFieldMaps(void); // called only at init phase + void LoadFieldMaps(const G4String); // called only at init phase + void PrepareFieldMap(Wheel_Efield_Map* ChCollWheelType); // called only at init phase + G4double GetCurrent(G4double *,G4double *,G4double, G4double Barret_PhiStart) const; + void TransformWheeltoFieldMap(const G4double *,G4double *, const WheelGeometry & wg, const FoldArea & fa) const; + void SetYlimitsofPhigapinFieldMap(G4int, const WheelGeometry & wg, G4double * Ylimits) const; + void TransFromBarrtoWheel(const G4double*, G4double PhiStartOfPhiDiv, G4double*) const; + G4double GetWeightfromFieldMap(G4int,G4double,G4double, const FoldArea & fa) const; + G4double HalfLArGapSizeOld(G4double) const; + + G4double m_CHC_Esr; // used as const after init + inline G4double CHC_Esr() const { return m_CHC_Esr; }; + +#ifdef DEBUG_CHCL // non thread-safe debug of charge collection + static const G4int s_CHCMaxPrint=00; // exists only if debug activated + static G4int s_CHCIprint; // exists only if debug activated + static G4double s_CHCEbad; // exists only if debug activated + static G4double s_CHCEtotal; // exists only if debug activated + static G4double s_CHCStotal; // exists only if debug activated +#endif + + private: + // inline void vector_to_msg(G4ThreeVector &v) const; + + /* to be developed... + std::pair<double, double>DxToFans(Hep3Vector &p); + double XDistanceToTheNeutralFibre(const Hep3Vector& P) const; + */ + G4double GetGapSize(const G4ThreeVector &p) const; + + // public: + G4double distance_to_the_nearest_electrode(const G4ThreeVector &p) const; + + UnsignedIntegerProperty m_solidtypeProp; + LArG4::LArWheelCalculator_t m_solidtype; + int m_zside; + LArG4BirksLaw *m_birksLaw; + LArWheelCalculator *m_lwc; + const LArWheelCalculator * lwc() const { return m_lwc; } + + void get_HV_map_from_DB(void); + G4bool m_DB_HV; + + std::string m_suffix; + + // Aug 2007 AMS, lost Aug 2008, restored May 2009 + LArWheelCalculator *m_electrode_calculator; + const LArWheelCalculator * elc() const { return m_electrode_calculator; } + + G4double GetCurrent1(const G4ThreeVector &, const G4ThreeVector &, G4double) const; + + G4double get_HV_value(const G4ThreeVector&, const std::pair<G4int, G4int> &) const; + + EnergyCalculator (const EnergyCalculator&); + EnergyCalculator& operator= (const EnergyCalculator&); + + G4int _getIRlayer(G4double rforalpha) const; + G4int _getIRlayerA(G4double rforalpha) const; + + G4double _interpolateCurrentSubStep(G4double rforalpha, G4int gapup, const G4double vmap[], + G4double tol, const FoldArea & fa, G4int & gaperr ) const; + + + G4double _interpolateCurrentSubStep1(G4double rforalpha, const G4double vmap[], + const G4ThreeVector & Pe, int side_dte, int Pe_fan, + const G4ThreeVector & Pa, int side_dta, int Pa_fan, + const FoldArea & fa, G4int & gaperr ) const; + + G4double _AdjustedPhiOfPoint_Barrett(const G4ThreeVector& p, G4double PhiStartOfPhiDiv) const; + + static inline G4double _normalizeAngle2Pi(G4double a) { + return ( a<0.) ? + a + CLHEP::twopi + : + (a >= CLHEP::twopi ? a - CLHEP::twopi: a); + } + + G4double getPhiStartOfPhiDiv(const G4Step* step) const; + }; + + } // namespace EC +} // namespace LArG4 + +#endif // LArG4_EC_EnergyCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc b/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc index 8a5f1b0d5310..6891b3f8fd75 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/GetCurrent1.cc @@ -4,374 +4,345 @@ #include <cassert> -#include "GaudiKernel/MsgStream.h" - #include "G4ThreeVector.hh" #include "globals.hh" #include "LArG4Code/LArG4BirksLaw.h" -#include "LArG4EC/EnergyCalculator.h" +#include "EnergyCalculator.h" #include "CLHEP/Units/SystemOfUnits.h" static inline int signof(double a){ return (a == 0.) ? 0: (a < 0 ? -1: 1); } -using namespace LArG4::EC; - -G4double EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, const G4ThreeVector &P2, G4double edep) // need to make const -{ -/* - FILE *F = fopen("test1.dat", "w"); - if(F == 0) abort(); - G4ThreeVector a(0., 1200., 0.); - for(double z = 0; z <= WheelThickness; z += 0.1){ - fprintf(F, "%f", z); -// for(double x = -20.; x <= 20.; x += 1.){ -// a[0] = x; - a[2] = z; -// std::cout << "(" << z << ", " << x << ") " << DistanceToTheNeutralFibre(a) << std::endl; - for(int s = -1; s <= 1; s ++){ -// std::cout << "\t" << s << " " << elc()->AmplitudeOfSurface(a, s) << std::endl; - fprintf(F, " %f", elc()->AmplitudeOfSurface(a, s)); - } -// } - fprintf(F, "\n"); - } - fclose(F); - - abort(); -*/ - -//std::cout << "GetCurrent1 -------------------------------------------------------------------------" << std::endl; -//std::cout << "input: (" << P1.x() << ", " << P1.y() << ", " << P1.z() << "), (" -// << P2.x() << ", " << P2.y() << ", " << P2.z() << "), " << edep << std::endl; - - G4int gaperr = 0; - - const std::pair<G4int, G4int> gap2 = lwc()->GetPhiGapAndSide(P2); - const std::pair<G4int, G4int> gap1 = lwc()->GetPhiGapAndSide(P1); -// gap1.first = PhiGapNumberForWheel(gap1.first); -// gap2.first = PhiGapNumberForWheel(gap2.first); - - if(gap1 != gap2) gaperr = -1; - - //JT.>>> - SetFoldArea(P1.z()); // set fold type - SetHalfWave(P1.z()); // set halfwave parameters for substep - G4double p1[3]; - p1[0] = P1.x(); - p1[1] = P1.y(); - p1[2] = P1.z(); - - //std::cout<<"===>>>GetCurrent1: before GetPhiGap** CosPhiGap,SinPhiGap=" - // <<CosPhiGap<<" "<<SinPhiGap<<std::endl; - - GetPhiGap(p1); //set rotation angle from the wheel to the efield Map system; once for each G4 step - - //std::cout<<"===>>>GetCurrent1: after GetPhiGap** CosPhiGap,SinPhiGap=" - // <<CosPhiGap<<" "<<SinPhiGap<<std::endl; - //<<<JT - - const G4double step = (P2 - P1).mag(); - const G4int nofstep = G4int(step / GridSize) + 1; // step is divided to substeps - G4double current = 0.; //current to be returned - const G4double step_current = edep / nofstep / AverageCurrent; // base current for each step - -//std::cout << "gap1: " << gap1.first << ", " << gap1.second -// << "; gap2: " << gap2.first << ", " << gap2.second << std::endl; -//std::cout << "input: (" << P1.x() << ", " << P1.y() << ", " << P1.z() << "), (" -// << P2.x() << ", " << P2.y() << ", " << P2.z() << "), " << edep << std::endl; - - - for(G4int i = 0; i < nofstep; ++ i){ - G4double ds = (i + 0.5) / nofstep; - G4ThreeVector Pe = P1 * (1. - ds) + P2 * ds; - G4ThreeVector Pa = Pe; -//std::cout << "step " << i << std::endl; -//std::cout << "\tpoint (" << Pe.x() << ", " << Pe.y() << ", " << Pe.z() << ")" << std::endl; - - SetFoldArea(Pe.z()); // set fold type - SetHalfWave(Pe.z()); // set halfwave parameters for substep - G4double vstep[3], vmap[3]; - vstep[0] = Pe.x(); - vstep[1] = Pe.y(); - vstep[2] = Pe.z(); - TransformWheeltoFieldMap(vstep, vmap); //get corresponding point in Map - - //JT.>>> - const G4double rvstep2=vstep[0]*vstep[0]+vstep[1]*vstep[1] ; - const G4double rforalpha=sqrt( rvstep2-vmap[1]*vmap[1] ); - const G4double gap=HalfLArGapSize(rforalpha,rforalpha);// LAr gap at the straight section on the fieldmap - const G4double yshift_on_map = rforalpha*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness+FanEleThickness)/2.; - const G4double yshift_on_wheel=sqrt(rvstep2)*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness+FanEleThickness)/2.; - const G4double cylgapcorr=yshift_on_wheel/yshift_on_map; // scale difference between plane and cylindrical surface - /* - std::cout<< " GetCurrent1**Nabs="<<lwc()->GetNumberOfFans()<<" absthick="<<FanAbsThickness<<" elethick="<<FanEleThickness - <<" cylgapcorr-1="<<cylgapcorr-1 - <<" ZinHalfWave="<<ZinHalfWave<<" HalfWaveNumber="<<HalfWaveNumber - <<std::endl; - */ - //<<<JT - -//std::cout << "\tvmap: (" << vmap[0] << ", " << vmap[1] << ", " << vmap[2] << ")" << std::endl; - - const G4double HV_value = get_HV_value(Pe, gap1); - - int Pe_fan = 0; - const G4double dte = elc()->DistanceToTheNearestFan(Pe, Pe_fan); - G4int side = signof(dte); - int Pa_fan = 0; - const G4double dta = lwc()->DistanceToTheNearestFan(Pa, Pa_fan); -//std::cout << "\tdte: " << dte << ", dta: " << dta << std::endl; -//std::cout << "\tPe: (" << Pe.x() << ", " << Pe.y() << ", " << Pe.z() << ")" << std::endl; -//std::cout << "\tPa: (" << Pa.x() << ", " << Pa.y() << ", " << Pa.z() << ")" << std::endl; - - const G4double suppression_range = ElectrodeFanHalfThickness + CHC_Esr; - if(fabs(dte) < suppression_range){ -// std::cout << " S"; - continue; //skip point if too close to the electrode - } - - const G4double agap = fabs(dte) - ElectrodeFanHalfThickness - + fabs(dta) - lwc()->GetFanHalfThickness(); //correction to electrode suppression not to - G4double suppression = agap / (agap - CHC_Esr); // change av. signal in the gap - if(suppression < 0.) suppression = 1.; -//std::cout << "\tagap: " << agap << ", suppression: " << suppression << std::endl; - - //search for radial layers the substep is in between; -/* G4int irlayer = 0; - const G4int &n_layers = ChCollWheelType->NumberOfRadialLayer; - G4double R = Pe.r(); - for(G4int j = 1; j < n_layers; ++ j){ - if(R < ChCollWheelType->RadiusOfLayers[j]){ - irlayer = j - 1; - break; - } - }*/ - // AMS - G4int irlayer = 0; - const G4int &n_layers = ChCollWheelType->NumberOfRadialLayer; - - - //JT>>>>>G4double fold_angle = M_PI - 2. * parameterized_slant_angle(Pe.r()); - - const G4double fold_angle = M_PI - 2. * lwc()->parameterized_slant_angle(rforalpha); //<<<JT - const G4double fold_angle_deg=fold_angle/M_PI*180.; //<<<JT - - for(G4int j = 1; j < n_layers; ++ j){ - if(fold_angle_deg > ChCollWheelType->FoldinAngleOfLayers[j]){ - irlayer = j - 1; - break; - } - } -//std::cout << "\tirlayer: " << irlayer << ", R " << R << std::endl; - assert(irlayer >= 0 && irlayer < n_layers - 1); - - G4double cur = 1.; - - if(!ChCollFoldType->FieldMapPrepared // fieldmap is not available for this fold - || ( vmap[2] < ChCollFoldType->MinZofLayer[irlayer] // or out of z range of both maps - && vmap[2] < ChCollFoldType->MinZofLayer[irlayer + 1]) - ){ - // interpolation not needed -//std::cout << "\tinterpolation not needed" << std::endl; - } else { // interpolation needed - // compute radial interpolation parameter -/* G4double dr = (R - ChCollWheelType->RadiusOfLayers[irlayer]) - / (ChCollWheelType->RadiusOfLayers[irlayer + 1] - ChCollWheelType->RadiusOfLayers[irlayer]); -*/ - // AMS - // JT>> - G4double dr = -(ChCollWheelType->FoldinAngleOfLayers[irlayer] - fold_angle_deg) - / (ChCollWheelType->FoldinAngleOfLayers[irlayer + 1] - ChCollWheelType->FoldinAngleOfLayers[irlayer]); - - //std::cout<<"**** GetCurrent1 dr="<<dr<<" n_layers="<< n_layers<<" irlayer= "<<irlayer<<std::endl; - //<<JT - - if(dr < 0.) dr = 0.; - if(dr > 1.) dr = 1.; - -//std::cout << "\tdr " << dr << " <- "; -//std::cout << R << " " << ChCollWheelType->RadiusOfLayers[irlayer] -// << " " << ChCollWheelType->RadiusOfLayers[irlayer+1] -// << " " << ChCollWheelType->RadiusOfLayers[irlayer] << std::endl; - - const G4double a_e = elc()->AmplitudeOfSurface(Pe, side, Pe_fan); - const G4double a_a = lwc()->AmplitudeOfSurface(Pa, signof(dta), Pa_fan); -//std::cout << "\ta_e: " << a_e << ", a_a: " << a_a << std::endl; - - const G4double x_e = fabs(Pe.x() - a_e); - const G4double x_a = fabs(Pa.x() - a_a); - - //check geom. err condition if point is outside of LAr gap - if(gaperr > -100 && (x_e < 0. || x_a < 0.)) gaperr -= 100; - - - const G4double z1 = Pe.z() - lwc()->GetStraightStartSection(); - G4int nhwave = G4int(z1 / lwc()->GetHalfWaveLength()); - if(nhwave < 0) nhwave = 0; - if(nhwave >= lwc()->GetNumberOfHalfWaves()) nhwave = lwc()->GetNumberOfHalfWaves() - 1; - if((nhwave % 2) == 1) side = -side; - - // get relative y coordinate - G4double yratio = ((side > 0)? x_e: x_a) / (x_e + x_a); -//std::cout << "\tyratio: " << yratio << std::endl; - - if(yratio <= 0.) yratio = 0.00001; // pull the point into the gap if it wouldn't be there; - else if(yratio >= 1.) yratio = 0.99999; // this may happen bec.G4 does not grantee that the full - // step-line is within the same volume - - //std::cout<<"**GetCurrent1: side="<<side<<" x_a,x_e="<<x_a<<" "<<x_e<<" yratio="<< - // yratio<<std::endl; - -// get corresponding y coordinates on the radial layers -// where the weight is to be taken from; - G4double shift = lwc()->GetStraightStartSection(); - if(PointFoldMapArea != 0) shift += WaveLength; - SetHalfWave(shift + vmap[2]); -//std::cout << "\tPointFoldMapArea: " << PointFoldMapArea << ", SetHalfWave(" << shift + vmap[2] << ")" << std::endl; - - SetYlimitsofPhigapinFieldMap(irlayer); //on the lower layer -//std::cout << "\tFieldmap limits: " << Ylimits[0] << " " << Ylimits[1] << " " << Ylimits[2] << " " << Ylimits[3] << std::endl; - G4double pos_low = 0.; - if(side < 0) pos_low = Ylimits[0] * (1. - yratio) + Ylimits[1] * yratio; - else if(side > 0) pos_low = Ylimits[2] * (1. - yratio) + Ylimits[3] * yratio; - - SetYlimitsofPhigapinFieldMap(irlayer + 1); //on the upper layer - G4double pos_up = 0.; - if(side < 0) pos_up = Ylimits[0] * (1. - yratio) + Ylimits[1] * yratio; - else if(side > 0) pos_up = Ylimits[2] * (1. - yratio) + Ylimits[3] * yratio; - -// get weights from the maps of lower and upper layer - const G4double w_low = GetWeightfromFieldMap(irlayer, vmap[2], pos_low); - const G4double w_up = GetWeightfromFieldMap(irlayer + 1, vmap[2], pos_up); - -// get the interpolated normalized Efield alias cur - cur = w_low * (1. - dr) + w_up * dr; - }// end of interpolation - -//(25-05-2005) new current calculation: edep*1/U*IonReco*E*v_drift -// normalized so that signal=edep in the straight section of the same gap -// as above; -// where: HV=1250V,E=9.615 [kv/cm] ,T=88.16 K, -// vdrift=4.62 [mm/mikrosec], Ionreco=96.4% -// ==> AverageCurrent=3.425/[mikrosec]; - -// G4double gap = HalfLArGapSize(Pe.r(), Pe.r()); // gapsize in the straight section -// AMS: why "straight section"? I would better use agap... -// JT: because the fieldmap table is normalized to the efield in the straight section - - // JT>>const G4double &gap = agap; - - const G4double efield = cur * (HV_value * CLHEP::volt) / (gap * CLHEP::mm) / (CLHEP::kilovolt / CLHEP::cm) /cylgapcorr; - // efield = efield/cylgapcorr; //<<JT // DM division by cylgapcorr combined to prev. line - const G4double substep_current = step_current * cur / gap * IonReco(efield) * - DriftVelo(LArTemperature_av, efield) * suppression / cylgapcorr; - //substep_current = substep_current / cylgapcorr; // <<JT // DM division by cylgapcorr combined to prev. line - -// if(birksLaw){ -// current += (*birksLaw)(substep_current, step/nofstep/cm, efield); -// } else { - current += substep_current; -// } - } // end of loop for substeps -//std::cout << std::endl; - if(current < 0.){ - gaperr -= 1000; - current = 0.; - } - - if(gaperr != 0){ - CHCEbad = CHCEbad + edep; - if(CHCIprint < CHCMaxPrint){ - ++ CHCIprint; - (*m_msg) << MSG::WARNING - << "GetCurrent has strange step, gaperr=" - << gaperr << " correction still computed" - << " bad edep ratio=" << CHCEbad/CHCEtotal - << endreq; - } - } - - //std::cout<<"GetCurrent1::edep="<<edep<<" current="<<current <<" gaperr="<<gaperr<<std::endl; - return current; +//using namespace LArG4::EC; + +G4int LArG4::EC::EnergyCalculator::_getIRlayerA(G4double fold_angle_deg) const { + //search for radial layers the substep is in between; + /* G4int irlayer = 0; + const G4int &n_layers = ChCollWheelType->NumberOfRadialLayer; + G4double R = Pe.r(); + for(G4int j = 1; j < n_layers; ++ j){ + if(R < ChCollWheelType->RadiusOfLayers[j]){ + irlayer = j - 1; + break; + } + }*/ + // AMS + G4int irlayer = 0; + const G4int n_layers = ChCollWheelType()->NumberOfRadialLayer; + + for(G4int j = 1; j < n_layers; ++ j) { + if(fold_angle_deg > ChCollWheelType()->FoldinAngleOfLayers[j]) { + irlayer = j - 1; + break; + } + } + //std::cout << "\tirlayer: " << irlayer << ", R " << R << std::endl; + assert(irlayer >= 0 && irlayer < n_layers - 1); + return irlayer; } - -G4double EnergyCalculator::get_HV_value( - const G4ThreeVector& p, const std::pair<G4int, G4int> &gap) const -{ - const G4int atlas_side = (lwc()->GetAtlasZside() > 0) ? 0 : 1; - - G4ThreeVector p1 ( p ); - p1[2] += lwc()->GetElecFocaltoWRP() + lwc()->GetdWRPtoFrontFace(); - const G4double eta = p1.pseudoRapidity(); - G4int eta_section = -1; - for(G4int i = 1; i <= NofEtaSection; ++ i){ - if(eta <= HV_Etalim[i]){ - eta_section = i - 1; - break; - } - } - if(!(eta_section>=0 && eta_section <=NofEtaSection-1)) throw std::runtime_error("Index out of range"); - - //assert(eta_section >= 0 && eta_section < NofEtaSection); - - /*(right side of e large phi)*/ /*left side of electrode(small phi)*/ - const G4int e_side = (gap.second > 0) ? 1 : 0; - - const G4int first_electrode = HV_Start_phi[atlas_side][eta_section][e_side]; - - if(first_electrode < 0 || first_electrode >= lwc()->GetNumberOfFans()){ - (*m_msg) << MSG::FATAL - << " get_HV_value: first_electrode number is out of range" - << endreq; - G4Exception("EnergyCalculator", "ElectrodeOutOfRange", FatalException, - "get_HV_value: first_electrode number is out of range"); - } - - G4int e_index = lwc()->PhiGapNumberForWheel(gap.first) - first_electrode; - if(e_index < 0) e_index += lwc()->GetNumberOfFans(); - const G4int &phi_section = e_index; -/* G4int nofelectrodesinphisection = lwc()->GetNumberOfFans() / NofPhiSections;//24(8) for outer(inner) wheel - G4int phi_section = e_index / nofelectrodesinphisection; - - if(phi_section < 0 || phi_section >= NofPhiSections){ - (*m_msg) << MSG::FATAL - << " get_HV_value: phi_section number is out of range" - << endreq; - G4Exception("EnergyCalculator::get_HV_value"); - }*/ -/* -printf("HV: %.2f at eta %.4f, phi %.4f", - HV_Values[atlas_side][eta_section][e_side][phi_section], eta, p.phi()); -std::cout << " " << gap.first << " | " - << atlas_side << " " << eta_section << " " << e_side << " " << phi_section - << std::endl; -*/ - return HV_Values[atlas_side][eta_section][e_side][phi_section]; +G4double LArG4::EC::EnergyCalculator::_interpolateCurrentSubStep1(G4double rforalpha, const G4double vmap[], + const G4ThreeVector & Pe, int side_dte, int Pe_fan, + const G4ThreeVector & Pa, int side_dta, int Pa_fan, + const FoldArea & fa, G4int & gaperr ) const { + + const G4double fold_angle = M_PI - 2. * lwc()->parameterized_slant_angle(rforalpha); //<<<JT + const G4double fold_angle_deg=fold_angle/M_PI*180.; //<<<JT + const G4int irlayer = _getIRlayerA(fold_angle_deg); + + if(!fa.ChCollFoldType->FieldMapPrepared // fieldmap is not available for this fold + || ( vmap[2] < fa.ChCollFoldType->MinZofLayer[irlayer] // or out of z range of both maps + && vmap[2] < fa.ChCollFoldType->MinZofLayer[irlayer + 1]) + ){ + // interpolation not needed + return 1.0; + } + + // interpolation needed + // compute radial interpolation parameter + G4double dr = -(ChCollWheelType()->FoldinAngleOfLayers[irlayer] - fold_angle_deg) + / (ChCollWheelType()->FoldinAngleOfLayers[irlayer + 1] - ChCollWheelType()->FoldinAngleOfLayers[irlayer]); + + if(dr < 0.) dr = 0.; + if(dr > 1.) dr = 1.; + + const G4double a_e = elc()->AmplitudeOfSurface(Pe, side_dte, Pe_fan); + const G4double a_a = lwc()->AmplitudeOfSurface(Pa, side_dta, Pa_fan); + //std::cout << "\ta_e: " << a_e << ", a_a: " << a_a << std::endl; + + const G4double x_e = fabs(Pe.x() - a_e); + const G4double x_a = fabs(Pa.x() - a_a); + + //check geom. err condition if point is outside of LAr gap + if(gaperr > -100 && (x_e < 0. || x_a < 0.)) gaperr -= 100; + + + const G4double z1 = Pe.z() - lwc()->GetStraightStartSection(); + G4int nhwave = G4int(z1 / lwc()->GetHalfWaveLength()); + if(nhwave < 0) nhwave = 0; + if(nhwave >= lwc()->GetNumberOfHalfWaves()) nhwave = lwc()->GetNumberOfHalfWaves() - 1; + //if((nhwave % 2) == 1) side = -side; + const int side = ((nhwave % 2) == 1) ? -side_dte : side_dte ; + + // get relative y coordinate + G4double yratio = ((side > 0)? x_e: x_a) / (x_e + x_a); + //std::cout << "\tyratio: " << yratio << std::endl; + + if(yratio <= 0.) yratio = 0.00001; // pull the point into the gap if it wouldn't be there; + else if(yratio >= 1.) yratio = 0.99999; // this may happen bec.G4 does not grantee that the full + // step-line is within the same volume + + // get corresponding y coordinates on the radial layers + // where the weight is to be taken from; + G4double shift = lwc()->GetStraightStartSection(); + if(fa.PointFoldMapArea != 0) shift += WaveLength(); + + WheelGeometry _wg; + SetHalfWave(shift + vmap[2], _wg); + //std::cout << "\tPointFoldMapArea: " << PointFoldMapArea << ", SetHalfWave(" << shift + vmap[2] << ")" << std::endl; + + G4double Ylimits[4]; + SetYlimitsofPhigapinFieldMap(irlayer, _wg, Ylimits); //on the lower layer + //std::cout << "\tFieldmap limits: " << Ylimits[0] << " " << Ylimits[1] << " " << Ylimits[2] << " " << Ylimits[3] << std::endl; + G4double pos_low = 0.; + if(side < 0) pos_low = Ylimits[0] * (1. - yratio) + Ylimits[1] * yratio; + else if(side > 0) pos_low = Ylimits[2] * (1. - yratio) + Ylimits[3] * yratio; + + SetYlimitsofPhigapinFieldMap(irlayer + 1, _wg, Ylimits); //on the upper layer + G4double pos_up = 0.; + if(side < 0) pos_up = Ylimits[0] * (1. - yratio) + Ylimits[1] * yratio; + else if(side > 0) pos_up = Ylimits[2] * (1. - yratio) + Ylimits[3] * yratio; + + // get weights from the maps of lower and upper layer + const G4double w_low = GetWeightfromFieldMap(irlayer, vmap[2], pos_low, fa); + const G4double w_up = GetWeightfromFieldMap(irlayer + 1, vmap[2], pos_up, fa); + + // get the interpolated normalized Efield alias cur + return w_low * (1. - dr) + w_up * dr; + // end of interpolation } -/* -G4double EnergyCalculator::transform_z_to_fieldmap(const G4ThreeVector &p) +G4double LArG4::EC::EnergyCalculator::GetCurrent1(const G4ThreeVector &P1, const G4ThreeVector &P2, G4double edep) const { - // fieldmap is defined for - // -- 'normal' folds : - // in the coord syst. of a halfwave of pos.slope - // in the range of 0<z<QuarterWaveLength; - // -- 0th and last fold in the range -13mm < z < QuarterWaveLength/2. - // SetHalfWave() and GetPhiGap() should be called previously; - - G4double result = 0.; - - if(PointFoldMapArea == 0){ - if(HalfWaveNumber == 0) result = ZinHalfWave; // 0th fold - else result = -ZinHalfWave; // last fold - } else { // normal folds - result = fabs(ZinHalfWave); - } - return result; -} - -*/ + /* + FILE *F = fopen("test1.dat", "w"); + if(F == 0) abort(); + G4ThreeVector a(0., 1200., 0.); + for(double z = 0; z <= WheelThickness; z += 0.1){ + fprintf(F, "%f", z); + // for(double x = -20.; x <= 20.; x += 1.){ + // a[0] = x; + a[2] = z; + // std::cout << "(" << z << ", " << x << ") " << DistanceToTheNeutralFibre(a) << std::endl; + for(int s = -1; s <= 1; s ++){ + // std::cout << "\t" << s << " " << elc()->AmplitudeOfSurface(a, s) << std::endl; + fprintf(F, " %f", elc()->AmplitudeOfSurface(a, s)); + } + // } + fprintf(F, "\n"); + } + fclose(F); + + abort(); + */ + + //std::cout << "GetCurrent1 -------------------------------------------------------------------------" << std::endl; + //std::cout << "input: (" << P1.x() << ", " << P1.y() << ", " << P1.z() << "), (" + // << P2.x() << ", " << P2.y() << ", " << P2.z() << "), " << edep << std::endl; + + G4int gaperr = 0; + + const std::pair<G4int, G4int> gap2 = lwc()->GetPhiGapAndSide(P2); + const std::pair<G4int, G4int> gap1 = lwc()->GetPhiGapAndSide(P1); + // gap1.first = PhiGapNumberForWheel(gap1.first); + // gap2.first = PhiGapNumberForWheel(gap2.first); + + if(gap1 != gap2) gaperr = -1; + + WheelGeometry _wg; + FoldArea _fa; + //JT.>>> + SetFoldArea(P1.z(), _fa); // set fold type + SetHalfWave(P1.z(), _wg); // set halfwave parameters for substep + G4double p1[3]; + p1[0] = P1.x(); + p1[1] = P1.y(); + p1[2] = P1.z(); + + GetPhiGap(p1, _wg); //set rotation angle from the wheel to the efield Map system; once for each G4 step + + const G4double step = (P2 - P1).mag(); + const G4int nofstep = G4int(step / s_GridSize) + 1; // step is divided to substeps + G4double current = 0.; //current to be returned + const G4double step_current = edep / nofstep / s_AverageCurrent; // base current for each step + + //std::cout << "gap1: " << gap1.first << ", " << gap1.second + // << "; gap2: " << gap2.first << ", " << gap2.second << std::endl; + //std::cout << "input: (" << P1.x() << ", " << P1.y() << ", " << P1.z() << "), (" + // << P2.x() << ", " << P2.y() << ", " << P2.z() << "), " << edep << std::endl; + + + const G4double inv_nofstep = 1. / static_cast<double>(nofstep); + for(G4int i = 0; i < nofstep; ++ i){ + G4double ds = (i + 0.5) * inv_nofstep; + G4ThreeVector Pe = P1 * (1. - ds) + P2 * ds; + G4ThreeVector Pa = Pe; + //std::cout << "step " << i << std::endl; + //std::cout << "\tpoint (" << Pe.x() << ", " << Pe.y() << ", " << Pe.z() << ")" << std::endl; + + SetFoldArea(Pe.z(), _fa); // set fold type + SetHalfWave(Pe.z(), _wg); // set halfwave parameters for substep + G4double vstep[3], vmap[3]; + vstep[0] = Pe.x(); + vstep[1] = Pe.y(); + vstep[2] = Pe.z(); + TransformWheeltoFieldMap(vstep, vmap, _wg, _fa); //get corresponding point in Map + + //JT.>>> + const G4double rvstep2=vstep[0]*vstep[0]+vstep[1]*vstep[1] ; + const G4double rforalpha=sqrt( rvstep2-vmap[1]*vmap[1] ); + const G4double gap=HalfLArGapSize(rforalpha,rforalpha);// LAr gap at the straight section on the fieldmap + const G4double yshift_on_map = rforalpha*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness() + FanEleThickness() )/2.; + const G4double yshift_on_wheel=sqrt(rvstep2)*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness() + FanEleThickness() )/2.; + const G4double cylgapcorr=yshift_on_wheel/yshift_on_map; // scale difference between plane and cylindrical surface + /* + std::cout<< " GetCurrent1**Nabs="<<lwc()->GetNumberOfFans()<<" absthick="<<FanAbsThickness<<" elethick="<<FanEleThickness + <<" cylgapcorr-1="<<cylgapcorr-1 + <<" ZinHalfWave="<<ZinHalfWave<<" HalfWaveNumber="<<HalfWaveNumber + <<std::endl; + */ + //<<<JT + + //std::cout << "\tvmap: (" << vmap[0] << ", " << vmap[1] << ", " << vmap[2] << ")" << std::endl; + + const G4double HV_value = get_HV_value(Pe, gap1); + + int Pe_fan = 0; + const G4double dte = elc()->DistanceToTheNearestFan(Pe, Pe_fan); + //G4int side = signof(dte); + int Pa_fan = 0; + const G4double dta = lwc()->DistanceToTheNearestFan(Pa, Pa_fan); + //std::cout << "\tdte: " << dte << ", dta: " << dta << std::endl; + //std::cout << "\tPe: (" << Pe.x() << ", " << Pe.y() << ", " << Pe.z() << ")" << std::endl; + //std::cout << "\tPa: (" << Pa.x() << ", " << Pa.y() << ", " << Pa.z() << ")" << std::endl; + + const G4double suppression_range = ElectrodeFanHalfThickness() + CHC_Esr(); + if(fabs(dte) < suppression_range){ + // std::cout << " S"; + continue; //skip point if too close to the electrode + } + + const G4double agap = fabs(dte) - ElectrodeFanHalfThickness() + + fabs(dta) - lwc()->GetFanHalfThickness(); //correction to electrode suppression not to + G4double suppression = agap / ( agap - CHC_Esr() ); // change av. signal in the gap + if(suppression < 0.) suppression = 1.; + //std::cout << "\tagap: " << agap << ", suppression: " << suppression << std::endl; + + const G4double cur = _interpolateCurrentSubStep1( rforalpha, vmap, Pe, signof(dte), Pe_fan, Pa, signof(dta), Pa_fan, _fa, gaperr ); + //(25-05-2005) new current calculation: edep*1/U*IonReco*E*v_drift + // normalized so that signal=edep in the straight section of the same gap + // as above; + // where: HV=1250V,E=9.615 [kv/cm] ,T=88.16 K, + // vdrift=4.62 [mm/mikrosec], Ionreco=96.4% + // ==> s_AverageCurrent=3.425/[mikrosec]; + + // G4double gap = HalfLArGapSize(Pe.r(), Pe.r()); // gapsize in the straight section + // AMS: why "straight section"? I would better use agap... + // JT: because the fieldmap table is normalized to the efield in the straight section + + // JT>>const G4double &gap = agap; + + const G4double efield = cur * (HV_value * CLHEP::volt) / (gap * CLHEP::mm) / (CLHEP::kilovolt / CLHEP::cm) /cylgapcorr; + const G4double substep_current = step_current * cur / gap * IonReco(efield) * + DriftVelo(s_LArTemperature_av, efield) * suppression / cylgapcorr; + + // if(birksLaw){ + // current += (*birksLaw)(substep_current, step/nofstep/cm, efield); + // } else { + current += substep_current; + // } + } // end of loop for substeps + //std::cout << std::endl; + if(current < 0.){ + gaperr -= 1000; + current = 0.; + } + +#ifdef DEBUG_CHCL + if(gaperr != 0){ + s_CHCEbad = s_CHCEbad + edep; + if(s_CHCIprint < s_CHCMaxPrint){ + ++ s_CHCIprint; + ATH_MSG_WARNING("GetCurrent has strange step, gaperr=" + << gaperr << " correction still computed" + << " bad edep ratio=" << s_CHCEbad/s_CHCEtotal + << endmsg; + } + } +#endif + + //std::cout<<"GetCurrent1::edep="<<edep<<" current="<<current <<" gaperr="<<gaperr<<std::endl; + return current; + } + + + G4double LArG4::EC::EnergyCalculator::get_HV_value( + const G4ThreeVector& p, const std::pair<G4int, G4int> &gap) const + { + const G4int atlas_side = (lwc()->GetAtlasZside() > 0) ? 0 : 1; + + G4ThreeVector p1 ( p ); + p1[2] += lwc()->GetElecFocaltoWRP() + lwc()->GetdWRPtoFrontFace(); + const G4double eta = p1.pseudoRapidity(); + G4int eta_section = -1; + for(G4int i = 1; i <= s_NofEtaSection; ++ i){ + if(eta <= s_HV_Etalim[i]){ + eta_section = i - 1; + break; + } + } + if(!(eta_section>=0 && eta_section <=s_NofEtaSection-1)) throw std::runtime_error("Index out of range"); + + //assert(eta_section >= 0 && eta_section < s_NofEtaSection); + + /*(right side of e large phi)*/ /*left side of electrode(small phi)*/ + const G4int e_side = (gap.second > 0) ? 1 : 0; + + const G4int first_electrode = s_HV_Start_phi[atlas_side][eta_section][e_side]; + + if(first_electrode < 0 || first_electrode >= lwc()->GetNumberOfFans()){ + ATH_MSG_FATAL(" get_HV_value: first_electrode number is out of range"); + G4Exception("EnergyCalculator", "ElectrodeOutOfRange", FatalException, + "get_HV_value: first_electrode number is out of range"); + } + + G4int phi_section = lwc()->PhiGapNumberForWheel(gap.first) - first_electrode; + if(phi_section < 0) phi_section += lwc()->GetNumberOfFans(); + + return s_HV_Values[atlas_side][eta_section][e_side][phi_section]; + } + + /* + G4double LArG4::EC::EnergyCalculator::transform_z_to_fieldmap(const G4ThreeVector &p) + { + // fieldmap is defined for + // -- 'normal' folds : + // in the coord syst. of a halfwave of pos.slope + // in the range of 0<z<QuarterWaveLength; + // -- 0th and last fold in the range -13mm < z < QuarterWaveLength/2. + // SetHalfWave() and GetPhiGap() should be called previously; + + G4double result = 0.; + + if(s_PointFoldMapArea == 0){ + if(HalfWaveNumber == 0) result = ZinHalfWave; // 0th fold + else result = -ZinHalfWave; // last fold + } else { // normal folds + result = fabs(ZinHalfWave); + } + return result; + } + + */ diff --git a/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc b/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc index 18b642e92816..53bd5aac99a7 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/LArEMECChargeCollection.cc @@ -20,16 +20,16 @@ // 25-May-2005 (J.T.): * // - HV values for each power supplies are treated: * // read it from file * -// /afs/cern.ch/atlas/offline/data/lar/emec/efield/HVEMECMap.dat; * +// /afs/cern.ch/atlas/offline/data/lar/emec/efield/HVEMECMap.dat; * // (the values are the nominal ones from TB) * // - current computation changed: * // - HV value from the above file is taken into account * // - IonRecombination effect is taken into accont * // - drift velocity parametrized as a function of T and Efield * -// from:note ATLAS-LARG-99-008; * +// from:note ATLAS-LARG-99-008; * // T is set to te average tempr. measured for ECC0,1,5 at TB * -// - current ~ edep*1/HV* Efield*v_drift(T,Efield); * -// normalized at eta=2.25 where the gapsize is 1.3mm(=AverageGap) * +// - current ~ edep*1/HV* Efield*v_drift(T,Efield); * +// normalized at eta=2.25 where the gapsize is 1.3mm(=AverageGap) * // * // 20-May-2005 (J.T.): * // - in case of err=-999, * @@ -44,7 +44,7 @@ // Modification of the code to read either the Old or New map * // was done. * // The desired version (New or Old) of the fieldmap should be set * -// to FieldMapVersion variable of the LArEMECEnergyCorrrection.cc * +// to s_FieldMapVersion variable of the LArEMECEnergyCorrrection.cc * // The file name which contains the map should also be set * // to FieldMapFileName variable of the LArEMECEnergyCorrrection.cc * // * @@ -82,26 +82,24 @@ #include <cassert> #include <cmath> -#include "GaudiKernel/MsgStream.h" - #include "G4ThreeVector.hh" #include "globals.hh" #include "LArG4Code/LArG4BirksLaw.h" -#include "LArG4EC/EnergyCalculator.h" +#include "EnergyCalculator.h" #include "CLHEP/Units/PhysicalConstants.h" // #define DEBUGGetCur -using namespace LArG4::EC; +//using namespace LArG4::EC; // *************************************************************************** -void EnergyCalculator::CreateArrays(Wheel_Efield_Map &wheel, G4int n){ -// *************************************************************************** +void LArG4::EC::EnergyCalculator::CreateArrays(Wheel_Efield_Map &wheel, G4int n){ + // *************************************************************************** -// std::cout<<"***CreateArrays wheeltype; n="<<n -// <<std::endl; + // std::cout<<"***CreateArrays wheeltype; n="<<n + // <<std::endl; wheel.NumberOfRadialLayer = n; wheel.RadiusOfLayers =new G4double [n]; @@ -135,457 +133,429 @@ void EnergyCalculator::CreateArrays(Wheel_Efield_Map &wheel, G4int n){ // *************************************************************************** -void EnergyCalculator::IniGeomforFieldMaps(void){ -// *************************************************************************** -// std::cout - (*m_msg) << MSG::INFO - << "***IniGeomforFieldMaps() called for FieldMapVersion = " - << FieldMapVersion - << endreq; -// <<std::endl; - - if(FieldMapVersion == "v00" || FieldMapVersion == "v01" || - FieldMapVersion == "v02"){ - - ChCollInner.Fold1.FieldMapPrepared=true; - ChCollOuter.Fold1.FieldMapPrepared=true; - - ChCollInner.Fold0.FieldMapPrepared=false; - ChCollOuter.Fold0.FieldMapPrepared=false; - - if(FieldMapVersion == "v00") { - - G4int nlayer=6; // number of radial layers - std::cout<<" ***IniGeomforFieldMaps calls CreateArrays" - <<std::endl; - CreateArrays(ChCollInner,nlayer); - CreateArrays(ChCollOuter,nlayer); - - ChCollInner.RadiusOfLayers[0]=300.;//[mm] - ChCollInner.RadiusOfLayers[1]=400.; - ChCollInner.RadiusOfLayers[2]=500.; - ChCollInner.RadiusOfLayers[3]=600.; - ChCollInner.RadiusOfLayers[4]=700.; - ChCollInner.RadiusOfLayers[5]=800.; - - ChCollOuter.RadiusOfLayers[0]= 600.; //[mm] - ChCollOuter.RadiusOfLayers[1]= 900.; - ChCollOuter.RadiusOfLayers[2]=1200.; - ChCollOuter.RadiusOfLayers[3]=1500.; - ChCollOuter.RadiusOfLayers[4]=1800.; - ChCollOuter.RadiusOfLayers[5]=2100.; - - ChCollInner.FoldinAngleOfLayers[0]= 112.7;//[degree] - ChCollInner.FoldinAngleOfLayers[1]= 92.2; - ChCollInner.FoldinAngleOfLayers[2]= 78.7; - ChCollInner.FoldinAngleOfLayers[3]= 68.8; - ChCollInner.FoldinAngleOfLayers[4]= 61.3; - ChCollInner.FoldinAngleOfLayers[5]= 55.2; - - ChCollInner.HalfLArGapSizeOfLayers[0]= 1.44; //[mm] - ChCollInner.HalfLArGapSizeOfLayers[1]= 1.94; - ChCollInner.HalfLArGapSizeOfLayers[2]= 2.29; - ChCollInner.HalfLArGapSizeOfLayers[3]= 2.56; - ChCollInner.HalfLArGapSizeOfLayers[4]= 2.78; - ChCollInner.HalfLArGapSizeOfLayers[5]= 2.96; - - ChCollOuter.FoldinAngleOfLayers[0]=129.;//[degree] - ChCollOuter.FoldinAngleOfLayers[1]=101.4; - ChCollOuter.FoldinAngleOfLayers[2]= 84.8; - ChCollOuter.FoldinAngleOfLayers[3]= 73.2; - ChCollOuter.FoldinAngleOfLayers[4]= 64.5; - ChCollOuter.FoldinAngleOfLayers[5]= 57.7; - - ChCollOuter.HalfLArGapSizeOfLayers[0]=0.87; //[mm] - ChCollOuter.HalfLArGapSizeOfLayers[1]=1.5; - ChCollOuter.HalfLArGapSizeOfLayers[2]=1.96; - ChCollOuter.HalfLArGapSizeOfLayers[3]=2.31; - ChCollOuter.HalfLArGapSizeOfLayers[4]=2.58; - ChCollOuter.HalfLArGapSizeOfLayers[5]=2.79; - } - - if(FieldMapVersion == "v01") { - - G4int nlayer=6; - CreateArrays(ChCollInner,nlayer); - CreateArrays(ChCollOuter,nlayer); - - ChCollInner.RadiusOfLayers[0]=300.;//[mm] - ChCollInner.RadiusOfLayers[1]=400.; - ChCollInner.RadiusOfLayers[2]=500.; - ChCollInner.RadiusOfLayers[3]=600.; - ChCollInner.RadiusOfLayers[4]=700.; - ChCollInner.RadiusOfLayers[5]=800.; - - ChCollOuter.RadiusOfLayers[0]= 600.; //[mm] - ChCollOuter.RadiusOfLayers[1]= 900.; - ChCollOuter.RadiusOfLayers[2]=1200.; - ChCollOuter.RadiusOfLayers[3]=1500.; - ChCollOuter.RadiusOfLayers[4]=1800.; - ChCollOuter.RadiusOfLayers[5]=2100.; - - ChCollInner.FoldinAngleOfLayers[0]= 112.742024; //[degree] - ChCollInner.FoldinAngleOfLayers[1]= 92.2379512; - ChCollInner.FoldinAngleOfLayers[2]= 78.6993545; - ChCollInner.FoldinAngleOfLayers[3]= 68.8423119; - ChCollInner.FoldinAngleOfLayers[4]= 61.2714745; - ChCollInner.FoldinAngleOfLayers[5]= 55.2462062; - - ChCollInner.HalfLArGapSizeOfLayers[0]= 1.47806735; //[mm] - ChCollInner.HalfLArGapSizeOfLayers[1]= 1.95080191; - ChCollInner.HalfLArGapSizeOfLayers[2]= 2.30318731; - ChCollInner.HalfLArGapSizeOfLayers[3]= 2.57486515; - ChCollInner.HalfLArGapSizeOfLayers[4]= 2.79014569; - ChCollInner.HalfLArGapSizeOfLayers[5]= 2.96463479; - - ChCollOuter.FoldinAngleOfLayers[0]= 129.00197; //[degree] - ChCollOuter.FoldinAngleOfLayers[1]= 101.408128; - ChCollOuter.FoldinAngleOfLayers[2]= 84.7966382; - ChCollOuter.FoldinAngleOfLayers[3]= 73.1643989; - ChCollOuter.FoldinAngleOfLayers[4]= 64.4458572; - ChCollOuter.FoldinAngleOfLayers[5]= 57.6301588; - - ChCollOuter.HalfLArGapSizeOfLayers[0]= 0.877808149; //[mm] - ChCollOuter.HalfLArGapSizeOfLayers[1]= 1.5116158; - ChCollOuter.HalfLArGapSizeOfLayers[2]= 1.97238634; - ChCollOuter.HalfLArGapSizeOfLayers[3]= 2.31937997; - ChCollOuter.HalfLArGapSizeOfLayers[4]= 2.58864056; - ChCollOuter.HalfLArGapSizeOfLayers[5]= 2.80290925; - } - - if(FieldMapVersion == "v02") { - - G4int nilayer=6; // number of layers for inner/outer wheel - G4int nolayer=11; - CreateArrays(ChCollInner,nilayer); - CreateArrays(ChCollOuter,nolayer); - - ChCollInner.RadiusOfLayers[0]=300.;//[mm] - ChCollInner.RadiusOfLayers[1]=400.; - ChCollInner.RadiusOfLayers[2]=500.; - ChCollInner.RadiusOfLayers[3]=600.; - ChCollInner.RadiusOfLayers[4]=700.; - ChCollInner.RadiusOfLayers[5]=800.; - - ChCollOuter.RadiusOfLayers[0] = 600.; //[mm] - ChCollOuter.RadiusOfLayers[1] = 900.; - ChCollOuter.RadiusOfLayers[2] =1200.; - ChCollOuter.RadiusOfLayers[3] =1250.; - ChCollOuter.RadiusOfLayers[4] =1300.; - ChCollOuter.RadiusOfLayers[5] =1350.; - ChCollOuter.RadiusOfLayers[6] =1400.; - ChCollOuter.RadiusOfLayers[7] =1450.; - ChCollOuter.RadiusOfLayers[8] =1500.; - ChCollOuter.RadiusOfLayers[9] =1800.; - ChCollOuter.RadiusOfLayers[10]=2100.; - - ChCollInner.FoldinAngleOfLayers[0]= 112.742024; //[degree] - ChCollInner.FoldinAngleOfLayers[1]= 92.2379512; - ChCollInner.FoldinAngleOfLayers[2]= 78.6993545; - ChCollInner.FoldinAngleOfLayers[3]= 68.8423119; - ChCollInner.FoldinAngleOfLayers[4]= 61.2714745; - ChCollInner.FoldinAngleOfLayers[5]= 55.2462062; - - ChCollInner.HalfLArGapSizeOfLayers[0]= 1.47806735; //[mm] - ChCollInner.HalfLArGapSizeOfLayers[1]= 1.95080191; - ChCollInner.HalfLArGapSizeOfLayers[2]= 2.30318731; - ChCollInner.HalfLArGapSizeOfLayers[3]= 2.57486515; - ChCollInner.HalfLArGapSizeOfLayers[4]= 2.79014569; - ChCollInner.HalfLArGapSizeOfLayers[5]= 2.96463479; - - ChCollOuter.FoldinAngleOfLayers[0]= 129.00197; //[degree] - ChCollOuter.FoldinAngleOfLayers[1]= 101.408128; - ChCollOuter.FoldinAngleOfLayers[2]= 84.7966382; - ChCollOuter.FoldinAngleOfLayers[3]= 82.5893317; - ChCollOuter.FoldinAngleOfLayers[4]= 80.5022136; - ChCollOuter.FoldinAngleOfLayers[5]= 78.524804; - ChCollOuter.FoldinAngleOfLayers[6]= 76.6479315; - ChCollOuter.FoldinAngleOfLayers[7]= 74.8635164; - ChCollOuter.FoldinAngleOfLayers[8]= 73.1643989; - ChCollOuter.FoldinAngleOfLayers[9]= 64.4458572; - ChCollOuter.FoldinAngleOfLayers[10]= 57.6301588; - - ChCollOuter.HalfLArGapSizeOfLayers[0]= 0.877808149; //[mm] - ChCollOuter.HalfLArGapSizeOfLayers[1]= 1.5116158; - ChCollOuter.HalfLArGapSizeOfLayers[2]= 1.97238634; - ChCollOuter.HalfLArGapSizeOfLayers[3]= 2.03692756; - ChCollOuter.HalfLArGapSizeOfLayers[4]= 2.09855584; - ChCollOuter.HalfLArGapSizeOfLayers[5]= 2.15745335; - ChCollOuter.HalfLArGapSizeOfLayers[6]= 2.21378826; - ChCollOuter.HalfLArGapSizeOfLayers[7]= 2.26771591; - ChCollOuter.HalfLArGapSizeOfLayers[8]= 2.31937997; - ChCollOuter.HalfLArGapSizeOfLayers[9]= 2.58864056; - ChCollOuter.HalfLArGapSizeOfLayers[10]=2.80290925; - } - } - else if(FieldMapVersion == "v03"){ - - ChCollInner.Fold1.FieldMapPrepared=true; - ChCollOuter.Fold1.FieldMapPrepared=true; - - ChCollInner.Fold0.FieldMapPrepared=true; - ChCollOuter.Fold0.FieldMapPrepared=true; - - G4int nilayer=6; //number of radial layers; should be the same for - G4int nolayer=16;// all fold type - CreateArrays(ChCollInner,nilayer); - CreateArrays(ChCollOuter,nolayer); - - for(G4int i=0;i<nilayer;++i){ - ChCollInner.RadiusOfLayers[i]=300.+i*100.; - } - ChCollInner.FoldinAngleOfLayers[0]= 112.7420; //[degree] - ChCollInner.FoldinAngleOfLayers[1]= 92.238; - ChCollInner.FoldinAngleOfLayers[2]= 78.6994; - ChCollInner.FoldinAngleOfLayers[3]= 68.8423; - ChCollInner.FoldinAngleOfLayers[4]= 61.2715; - ChCollInner.FoldinAngleOfLayers[5]= 55.2462; - - ChCollInner.HalfLArGapSizeOfLayers[0]= 1.5326; //[mm] - ChCollInner.HalfLArGapSizeOfLayers[1]= 2.0053; - ChCollInner.HalfLArGapSizeOfLayers[2]= 2.3577; - ChCollInner.HalfLArGapSizeOfLayers[3]= 2.6294; - ChCollInner.HalfLArGapSizeOfLayers[4]= 2.8446; - ChCollInner.HalfLArGapSizeOfLayers[5]= 3.0191; - - for(G4int i=0;i<nolayer;++i){ - ChCollOuter.RadiusOfLayers[i]=600.+i*100.; - } - - ChCollOuter.FoldinAngleOfLayers[0]= 129.002; //[degree] - ChCollOuter.FoldinAngleOfLayers[1]= 117.7235; - ChCollOuter.FoldinAngleOfLayers[2]= 108.8045; - ChCollOuter.FoldinAngleOfLayers[3]= 101.4081; - ChCollOuter.FoldinAngleOfLayers[4]= 95.1012; - ChCollOuter.FoldinAngleOfLayers[5]= 89.6220; - ChCollOuter.FoldinAngleOfLayers[6]= 84.7966; - ChCollOuter.FoldinAngleOfLayers[7]= 80.5022; - ChCollOuter.FoldinAngleOfLayers[8]= 76.6479; - ChCollOuter.FoldinAngleOfLayers[9]= 73.1644; - ChCollOuter.FoldinAngleOfLayers[10]= 69.9972; - ChCollOuter.FoldinAngleOfLayers[11]= 67.1028; - ChCollOuter.FoldinAngleOfLayers[12]= 64.4459; - ChCollOuter.FoldinAngleOfLayers[13]= 61.9970; - ChCollOuter.FoldinAngleOfLayers[14]= 59.7320; - ChCollOuter.FoldinAngleOfLayers[15]= 57.6302; - - ChCollOuter.HalfLArGapSizeOfLayers[0]= 0.9367; //[mm] - ChCollOuter.HalfLArGapSizeOfLayers[1]= 1.1723; - ChCollOuter.HalfLArGapSizeOfLayers[2]= 1.3824; - ChCollOuter.HalfLArGapSizeOfLayers[3]= 1.5705; - ChCollOuter.HalfLArGapSizeOfLayers[4]= 1.7398; - ChCollOuter.HalfLArGapSizeOfLayers[5]= 1.8927; - ChCollOuter.HalfLArGapSizeOfLayers[6]= 2.0313; - ChCollOuter.HalfLArGapSizeOfLayers[7]= 2.1575; - ChCollOuter.HalfLArGapSizeOfLayers[8]= 2.2727; - ChCollOuter.HalfLArGapSizeOfLayers[9]= 2.3783; - ChCollOuter.HalfLArGapSizeOfLayers[10]=2.4754; - ChCollOuter.HalfLArGapSizeOfLayers[11]=2.5648; - ChCollOuter.HalfLArGapSizeOfLayers[12]=2.6476; - ChCollOuter.HalfLArGapSizeOfLayers[13]=2.7242; - ChCollOuter.HalfLArGapSizeOfLayers[14]=2.7955; - ChCollOuter.HalfLArGapSizeOfLayers[15]=2.8618; - - } - else{ - (*m_msg) << MSG::FATAL - << "IniGeomforFieldMaps - FieldMapVersion = '" - << FieldMapVersion << "' not found!" << endreq; - } - - ChCollInner.GridShift=0.050; - ChCollOuter.GridShift=0.0667; +void LArG4::EC::EnergyCalculator::IniGeomforFieldMaps(void){ + // *************************************************************************** + ATH_MSG_INFO("***IniGeomforFieldMaps() called for FieldMapVersion = " + << s_FieldMapVersion); + + if(s_FieldMapVersion == "v00" || s_FieldMapVersion == "v01" || + s_FieldMapVersion == "v02"){ + + s_ChCollInner.Fold1.FieldMapPrepared=true; + s_ChCollOuter.Fold1.FieldMapPrepared=true; + + s_ChCollInner.Fold0.FieldMapPrepared=false; + s_ChCollOuter.Fold0.FieldMapPrepared=false; + + if(s_FieldMapVersion == "v00") { + + G4int nlayer=6; // number of radial layers + ATH_MSG_INFO(" ***IniGeomforFieldMaps calls CreateArrays"); + CreateArrays(s_ChCollInner,nlayer); + CreateArrays(s_ChCollOuter,nlayer); + + s_ChCollInner.RadiusOfLayers[0]=300.;//[mm] + s_ChCollInner.RadiusOfLayers[1]=400.; + s_ChCollInner.RadiusOfLayers[2]=500.; + s_ChCollInner.RadiusOfLayers[3]=600.; + s_ChCollInner.RadiusOfLayers[4]=700.; + s_ChCollInner.RadiusOfLayers[5]=800.; + + s_ChCollOuter.RadiusOfLayers[0]= 600.; //[mm] + s_ChCollOuter.RadiusOfLayers[1]= 900.; + s_ChCollOuter.RadiusOfLayers[2]=1200.; + s_ChCollOuter.RadiusOfLayers[3]=1500.; + s_ChCollOuter.RadiusOfLayers[4]=1800.; + s_ChCollOuter.RadiusOfLayers[5]=2100.; + + s_ChCollInner.FoldinAngleOfLayers[0]= 112.7;//[degree] + s_ChCollInner.FoldinAngleOfLayers[1]= 92.2; + s_ChCollInner.FoldinAngleOfLayers[2]= 78.7; + s_ChCollInner.FoldinAngleOfLayers[3]= 68.8; + s_ChCollInner.FoldinAngleOfLayers[4]= 61.3; + s_ChCollInner.FoldinAngleOfLayers[5]= 55.2; + + s_ChCollInner.HalfLArGapSizeOfLayers[0]= 1.44; //[mm] + s_ChCollInner.HalfLArGapSizeOfLayers[1]= 1.94; + s_ChCollInner.HalfLArGapSizeOfLayers[2]= 2.29; + s_ChCollInner.HalfLArGapSizeOfLayers[3]= 2.56; + s_ChCollInner.HalfLArGapSizeOfLayers[4]= 2.78; + s_ChCollInner.HalfLArGapSizeOfLayers[5]= 2.96; + + s_ChCollOuter.FoldinAngleOfLayers[0]=129.;//[degree] + s_ChCollOuter.FoldinAngleOfLayers[1]=101.4; + s_ChCollOuter.FoldinAngleOfLayers[2]= 84.8; + s_ChCollOuter.FoldinAngleOfLayers[3]= 73.2; + s_ChCollOuter.FoldinAngleOfLayers[4]= 64.5; + s_ChCollOuter.FoldinAngleOfLayers[5]= 57.7; + + s_ChCollOuter.HalfLArGapSizeOfLayers[0]=0.87; //[mm] + s_ChCollOuter.HalfLArGapSizeOfLayers[1]=1.5; + s_ChCollOuter.HalfLArGapSizeOfLayers[2]=1.96; + s_ChCollOuter.HalfLArGapSizeOfLayers[3]=2.31; + s_ChCollOuter.HalfLArGapSizeOfLayers[4]=2.58; + s_ChCollOuter.HalfLArGapSizeOfLayers[5]=2.79; + } + + if(s_FieldMapVersion == "v01") { + + G4int nlayer=6; + CreateArrays(s_ChCollInner,nlayer); + CreateArrays(s_ChCollOuter,nlayer); + + s_ChCollInner.RadiusOfLayers[0]=300.;//[mm] + s_ChCollInner.RadiusOfLayers[1]=400.; + s_ChCollInner.RadiusOfLayers[2]=500.; + s_ChCollInner.RadiusOfLayers[3]=600.; + s_ChCollInner.RadiusOfLayers[4]=700.; + s_ChCollInner.RadiusOfLayers[5]=800.; + + s_ChCollOuter.RadiusOfLayers[0]= 600.; //[mm] + s_ChCollOuter.RadiusOfLayers[1]= 900.; + s_ChCollOuter.RadiusOfLayers[2]=1200.; + s_ChCollOuter.RadiusOfLayers[3]=1500.; + s_ChCollOuter.RadiusOfLayers[4]=1800.; + s_ChCollOuter.RadiusOfLayers[5]=2100.; + + s_ChCollInner.FoldinAngleOfLayers[0]= 112.742024; //[degree] + s_ChCollInner.FoldinAngleOfLayers[1]= 92.2379512; + s_ChCollInner.FoldinAngleOfLayers[2]= 78.6993545; + s_ChCollInner.FoldinAngleOfLayers[3]= 68.8423119; + s_ChCollInner.FoldinAngleOfLayers[4]= 61.2714745; + s_ChCollInner.FoldinAngleOfLayers[5]= 55.2462062; + + s_ChCollInner.HalfLArGapSizeOfLayers[0]= 1.47806735; //[mm] + s_ChCollInner.HalfLArGapSizeOfLayers[1]= 1.95080191; + s_ChCollInner.HalfLArGapSizeOfLayers[2]= 2.30318731; + s_ChCollInner.HalfLArGapSizeOfLayers[3]= 2.57486515; + s_ChCollInner.HalfLArGapSizeOfLayers[4]= 2.79014569; + s_ChCollInner.HalfLArGapSizeOfLayers[5]= 2.96463479; + + s_ChCollOuter.FoldinAngleOfLayers[0]= 129.00197; //[degree] + s_ChCollOuter.FoldinAngleOfLayers[1]= 101.408128; + s_ChCollOuter.FoldinAngleOfLayers[2]= 84.7966382; + s_ChCollOuter.FoldinAngleOfLayers[3]= 73.1643989; + s_ChCollOuter.FoldinAngleOfLayers[4]= 64.4458572; + s_ChCollOuter.FoldinAngleOfLayers[5]= 57.6301588; + + s_ChCollOuter.HalfLArGapSizeOfLayers[0]= 0.877808149; //[mm] + s_ChCollOuter.HalfLArGapSizeOfLayers[1]= 1.5116158; + s_ChCollOuter.HalfLArGapSizeOfLayers[2]= 1.97238634; + s_ChCollOuter.HalfLArGapSizeOfLayers[3]= 2.31937997; + s_ChCollOuter.HalfLArGapSizeOfLayers[4]= 2.58864056; + s_ChCollOuter.HalfLArGapSizeOfLayers[5]= 2.80290925; + } + + if(s_FieldMapVersion == "v02") { + + G4int nilayer=6; // number of layers for inner/outer wheel + G4int nolayer=11; + CreateArrays(s_ChCollInner,nilayer); + CreateArrays(s_ChCollOuter,nolayer); + + s_ChCollInner.RadiusOfLayers[0]=300.;//[mm] + s_ChCollInner.RadiusOfLayers[1]=400.; + s_ChCollInner.RadiusOfLayers[2]=500.; + s_ChCollInner.RadiusOfLayers[3]=600.; + s_ChCollInner.RadiusOfLayers[4]=700.; + s_ChCollInner.RadiusOfLayers[5]=800.; + + s_ChCollOuter.RadiusOfLayers[0] = 600.; //[mm] + s_ChCollOuter.RadiusOfLayers[1] = 900.; + s_ChCollOuter.RadiusOfLayers[2] =1200.; + s_ChCollOuter.RadiusOfLayers[3] =1250.; + s_ChCollOuter.RadiusOfLayers[4] =1300.; + s_ChCollOuter.RadiusOfLayers[5] =1350.; + s_ChCollOuter.RadiusOfLayers[6] =1400.; + s_ChCollOuter.RadiusOfLayers[7] =1450.; + s_ChCollOuter.RadiusOfLayers[8] =1500.; + s_ChCollOuter.RadiusOfLayers[9] =1800.; + s_ChCollOuter.RadiusOfLayers[10]=2100.; + + s_ChCollInner.FoldinAngleOfLayers[0]= 112.742024; //[degree] + s_ChCollInner.FoldinAngleOfLayers[1]= 92.2379512; + s_ChCollInner.FoldinAngleOfLayers[2]= 78.6993545; + s_ChCollInner.FoldinAngleOfLayers[3]= 68.8423119; + s_ChCollInner.FoldinAngleOfLayers[4]= 61.2714745; + s_ChCollInner.FoldinAngleOfLayers[5]= 55.2462062; + + s_ChCollInner.HalfLArGapSizeOfLayers[0]= 1.47806735; //[mm] + s_ChCollInner.HalfLArGapSizeOfLayers[1]= 1.95080191; + s_ChCollInner.HalfLArGapSizeOfLayers[2]= 2.30318731; + s_ChCollInner.HalfLArGapSizeOfLayers[3]= 2.57486515; + s_ChCollInner.HalfLArGapSizeOfLayers[4]= 2.79014569; + s_ChCollInner.HalfLArGapSizeOfLayers[5]= 2.96463479; + + s_ChCollOuter.FoldinAngleOfLayers[0]= 129.00197; //[degree] + s_ChCollOuter.FoldinAngleOfLayers[1]= 101.408128; + s_ChCollOuter.FoldinAngleOfLayers[2]= 84.7966382; + s_ChCollOuter.FoldinAngleOfLayers[3]= 82.5893317; + s_ChCollOuter.FoldinAngleOfLayers[4]= 80.5022136; + s_ChCollOuter.FoldinAngleOfLayers[5]= 78.524804; + s_ChCollOuter.FoldinAngleOfLayers[6]= 76.6479315; + s_ChCollOuter.FoldinAngleOfLayers[7]= 74.8635164; + s_ChCollOuter.FoldinAngleOfLayers[8]= 73.1643989; + s_ChCollOuter.FoldinAngleOfLayers[9]= 64.4458572; + s_ChCollOuter.FoldinAngleOfLayers[10]= 57.6301588; + + s_ChCollOuter.HalfLArGapSizeOfLayers[0]= 0.877808149; //[mm] + s_ChCollOuter.HalfLArGapSizeOfLayers[1]= 1.5116158; + s_ChCollOuter.HalfLArGapSizeOfLayers[2]= 1.97238634; + s_ChCollOuter.HalfLArGapSizeOfLayers[3]= 2.03692756; + s_ChCollOuter.HalfLArGapSizeOfLayers[4]= 2.09855584; + s_ChCollOuter.HalfLArGapSizeOfLayers[5]= 2.15745335; + s_ChCollOuter.HalfLArGapSizeOfLayers[6]= 2.21378826; + s_ChCollOuter.HalfLArGapSizeOfLayers[7]= 2.26771591; + s_ChCollOuter.HalfLArGapSizeOfLayers[8]= 2.31937997; + s_ChCollOuter.HalfLArGapSizeOfLayers[9]= 2.58864056; + s_ChCollOuter.HalfLArGapSizeOfLayers[10]=2.80290925; + } + } + else if(s_FieldMapVersion == "v03"){ + + s_ChCollInner.Fold1.FieldMapPrepared=true; + s_ChCollOuter.Fold1.FieldMapPrepared=true; + + s_ChCollInner.Fold0.FieldMapPrepared=true; + s_ChCollOuter.Fold0.FieldMapPrepared=true; + + G4int nilayer=6; //number of radial layers; should be the same for + G4int nolayer=16;// all fold type + CreateArrays(s_ChCollInner,nilayer); + CreateArrays(s_ChCollOuter,nolayer); + + for(G4int i=0;i<nilayer;++i){ + s_ChCollInner.RadiusOfLayers[i]=300.+i*100.; + } + s_ChCollInner.FoldinAngleOfLayers[0]= 112.7420; //[degree] + s_ChCollInner.FoldinAngleOfLayers[1]= 92.238; + s_ChCollInner.FoldinAngleOfLayers[2]= 78.6994; + s_ChCollInner.FoldinAngleOfLayers[3]= 68.8423; + s_ChCollInner.FoldinAngleOfLayers[4]= 61.2715; + s_ChCollInner.FoldinAngleOfLayers[5]= 55.2462; + + s_ChCollInner.HalfLArGapSizeOfLayers[0]= 1.5326; //[mm] + s_ChCollInner.HalfLArGapSizeOfLayers[1]= 2.0053; + s_ChCollInner.HalfLArGapSizeOfLayers[2]= 2.3577; + s_ChCollInner.HalfLArGapSizeOfLayers[3]= 2.6294; + s_ChCollInner.HalfLArGapSizeOfLayers[4]= 2.8446; + s_ChCollInner.HalfLArGapSizeOfLayers[5]= 3.0191; + + for(G4int i=0;i<nolayer;++i){ + s_ChCollOuter.RadiusOfLayers[i]=600.+i*100.; + } + + s_ChCollOuter.FoldinAngleOfLayers[0]= 129.002; //[degree] + s_ChCollOuter.FoldinAngleOfLayers[1]= 117.7235; + s_ChCollOuter.FoldinAngleOfLayers[2]= 108.8045; + s_ChCollOuter.FoldinAngleOfLayers[3]= 101.4081; + s_ChCollOuter.FoldinAngleOfLayers[4]= 95.1012; + s_ChCollOuter.FoldinAngleOfLayers[5]= 89.6220; + s_ChCollOuter.FoldinAngleOfLayers[6]= 84.7966; + s_ChCollOuter.FoldinAngleOfLayers[7]= 80.5022; + s_ChCollOuter.FoldinAngleOfLayers[8]= 76.6479; + s_ChCollOuter.FoldinAngleOfLayers[9]= 73.1644; + s_ChCollOuter.FoldinAngleOfLayers[10]= 69.9972; + s_ChCollOuter.FoldinAngleOfLayers[11]= 67.1028; + s_ChCollOuter.FoldinAngleOfLayers[12]= 64.4459; + s_ChCollOuter.FoldinAngleOfLayers[13]= 61.9970; + s_ChCollOuter.FoldinAngleOfLayers[14]= 59.7320; + s_ChCollOuter.FoldinAngleOfLayers[15]= 57.6302; + + s_ChCollOuter.HalfLArGapSizeOfLayers[0]= 0.9367; //[mm] + s_ChCollOuter.HalfLArGapSizeOfLayers[1]= 1.1723; + s_ChCollOuter.HalfLArGapSizeOfLayers[2]= 1.3824; + s_ChCollOuter.HalfLArGapSizeOfLayers[3]= 1.5705; + s_ChCollOuter.HalfLArGapSizeOfLayers[4]= 1.7398; + s_ChCollOuter.HalfLArGapSizeOfLayers[5]= 1.8927; + s_ChCollOuter.HalfLArGapSizeOfLayers[6]= 2.0313; + s_ChCollOuter.HalfLArGapSizeOfLayers[7]= 2.1575; + s_ChCollOuter.HalfLArGapSizeOfLayers[8]= 2.2727; + s_ChCollOuter.HalfLArGapSizeOfLayers[9]= 2.3783; + s_ChCollOuter.HalfLArGapSizeOfLayers[10]=2.4754; + s_ChCollOuter.HalfLArGapSizeOfLayers[11]=2.5648; + s_ChCollOuter.HalfLArGapSizeOfLayers[12]=2.6476; + s_ChCollOuter.HalfLArGapSizeOfLayers[13]=2.7242; + s_ChCollOuter.HalfLArGapSizeOfLayers[14]=2.7955; + s_ChCollOuter.HalfLArGapSizeOfLayers[15]=2.8618; + + } + else{ + ATH_MSG_FATAL("IniGeomforFieldMaps - FieldMapVersion = '" + << s_FieldMapVersion << "' not found!"); + } + + s_ChCollInner.GridShift=0.050; + s_ChCollOuter.GridShift=0.0667; } // *********************************************************** -void EnergyCalculator::GetFieldMaps(const G4String fname){ -// *********************************************************** +void LArG4::EC::EnergyCalculator::LoadFieldMaps(const G4String fname){ + // *********************************************************** + + G4int foldtypemx=0; + char fieldmapversion[10] = { 0 }; + + ATH_MSG_INFO("GetFieldMaps from file = " << fname); - G4int i,j,npoints,wheeltype,foldtype,foldtypemx=0,nlayer; - char fieldmapversion[10]; - - (*m_msg) << MSG::INFO - << "GetFieldMaps from file = " << fname << endreq; - - FILE *lun = fopen(fname, "r"); - - if(lun == 0){ - (*m_msg) << MSG::FATAL - << "GetFieldMaps - file '" << fname << "' not found!" - << endreq; - throw std::runtime_error("LArEMECChargeCollection: File not found!"); - } - - if(FieldMapVersion != "v00"){ - if (fscanf(lun, "%9s", fieldmapversion) < 1) { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - (*m_msg) << MSG::INFO - << "This file contains fieldmap of version '" << fieldmapversion - << "'" - << endreq; - } - -// Check which fold should have a map - - if (ChCollInner.Fold1.FieldMapPrepared && - ChCollOuter.Fold1.FieldMapPrepared && - ChCollInner.Fold0.FieldMapPrepared && - ChCollOuter.Fold0.FieldMapPrepared) foldtypemx=2; - else if(ChCollInner.Fold1.FieldMapPrepared && - ChCollOuter.Fold1.FieldMapPrepared && - !ChCollInner.Fold0.FieldMapPrepared && - !ChCollOuter.Fold0.FieldMapPrepared) foldtypemx=1; - else{ - - (*m_msg) << MSG::FATAL - <<" ***GetFieldMaps file format is incompatible" - <<endreq; + FILE *lun = fopen(fname, "r"); + + if(lun == 0){ + ATH_MSG_FATAL("GetFieldMaps - file '" << fname << "' not found!"); + throw std::runtime_error("LArEMECChargeCollection: File not found!"); + } + + if(s_FieldMapVersion != "v00"){ + if (fscanf(lun, "%9s", fieldmapversion) < 1) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); } + ATH_MSG_INFO("This file contains fieldmap of version '" << fieldmapversion << "'"); + } -// occupy store for the FieldMaps - - for(foldtype = 0; foldtype < foldtypemx; ++ foldtype){ - for(wheeltype = 0; wheeltype < 2; ++ wheeltype){ - - if(wheeltype == 0) ChCollWheelType = &ChCollInner; - if(wheeltype == 1) ChCollWheelType = &ChCollOuter; - if(foldtype == 0 ) ChCollFoldType = &(ChCollWheelType->Fold1); - if(foldtype == 1 ) ChCollFoldType = &(ChCollWheelType->Fold0); - - nlayer = ChCollWheelType->NumberOfRadialLayer; // should be the same for Fold0 and Fold1 - - for(i=0; i<nlayer; ++i){ - if (fscanf(lun, "%lg%lg%lg%lg", &ChCollFoldType->MinZofLayer[i], - &ChCollFoldType->MaxZofLayer[i], - &ChCollFoldType->MinYofLayer[i], - &ChCollFoldType->MaxYofLayer[i]) < 4) - { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - if (fscanf(lun, "%i%i", &ChCollFoldType->NofColofLayer[i], - &ChCollFoldType->NofRowofLayer[i]) < 2) - { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - - ChCollFoldType->NofColofLayer[i] ++; - ChCollFoldType->NofRowofLayer[i] ++; - npoints = ChCollFoldType->NofColofLayer[i]*ChCollFoldType->NofRowofLayer[i]; - if(npoints>0 && npoints < std::numeric_limits<int>::max()){ - ChCollFoldType->NofPointsinLayer[i]=npoints; - if(i==0) ChCollFoldType->pLayer[i]=0; - else{ ChCollFoldType->pLayer[i]=ChCollFoldType->pLayer[i-1]+ - 3*ChCollFoldType->NofPointsinLayer[i-1]; - } - - for(j=0;j<npoints;++j){ - G4double zdummy,ydummy,wdummy; - if (fscanf(lun, "%lg%lg%lg", &zdummy,&ydummy,&wdummy) < 3) { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - } // end for points - } -// std::cout - (*m_msg) << MSG::INFO - <<" foldtype="<<foldtype<< " wheeltype="<<wheeltype - <<" ilayer = " << i << " zmin, max = " - << ChCollFoldType->MinZofLayer[i] << " " - << ChCollFoldType->MaxZofLayer[i] << " " - << " ymin, max = " - << ChCollFoldType->MinYofLayer[i] << " " - << ChCollFoldType->MaxYofLayer[i] << " " - << " ncol = " << ChCollFoldType->NofColofLayer[i] - << " nrow = " << ChCollFoldType->NofRowofLayer[i] - << " npoints = " << npoints - <<endreq; -// << std::endl; - - } // end for layers - - G4int length=ChCollFoldType->pLayer[nlayer-1]+3*ChCollFoldType->NofPointsinLayer[nlayer-1]; - ChCollFoldType->FieldMap = new G4double [length]; - - // std::cout<<" ***GetFieldMaps : length of FieldMap="<<length - // <<std::endl; - - if(ChCollFoldType->FieldMap == 0 ) { - - (*m_msg) << MSG::FATAL - <<" ***GetFieldMaps: FATAL FieldMap array cannot be created" - <<endreq; - } - - } // end for wheels - } //end for foldtypes - - rewind(lun); - if(FieldMapVersion != "v00") { - if (fscanf(lun, "%9s", fieldmapversion) < 1) { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; + // Check which fold should have a map + + if (s_ChCollInner.Fold1.FieldMapPrepared && + s_ChCollOuter.Fold1.FieldMapPrepared && + s_ChCollInner.Fold0.FieldMapPrepared && + s_ChCollOuter.Fold0.FieldMapPrepared) foldtypemx=2; + else if(s_ChCollInner.Fold1.FieldMapPrepared && + s_ChCollOuter.Fold1.FieldMapPrepared && + !s_ChCollInner.Fold0.FieldMapPrepared && + !s_ChCollOuter.Fold0.FieldMapPrepared) foldtypemx=1; + else{ + + ATH_MSG_FATAL(" ***GetFieldMaps file format is incompatible"); + } + + // occupy store for the FieldMaps + + for(G4int foldtype = 0; foldtype < foldtypemx; ++ foldtype) { + for(G4int wheeltype = 0; wheeltype < 2; ++ wheeltype) { + //if(wheeltype == 0) ChCollWheelType = &ChCollInner; + //if(wheeltype == 1) ChCollWheelType = &ChCollOuter; + Wheel_Efield_Map *ChCollWheelType = (wheeltype == 0) ? &s_ChCollInner : + ( (wheeltype == 1) ? &s_ChCollOuter : 0 ); + + //if(foldtype == 0 ) ChCollFoldType = &(ChCollWheelType->Fold1); + //if(foldtype == 1 ) ChCollFoldType = &(ChCollWheelType->Fold0); + Fold_Efield_Map *ChCollFoldType = ( foldtype == 0 ) ? &(ChCollWheelType->Fold1) : + ( ( foldtype == 1 ) ? &(ChCollWheelType->Fold0) : 0 ); + + const G4int nlayer = ChCollWheelType->NumberOfRadialLayer; // should be the same for Fold0 and Fold1 + + for(G4int i=0; i<nlayer; ++i) { + if (fscanf(lun, "%lg%lg%lg%lg", &ChCollFoldType->MinZofLayer[i], + &ChCollFoldType->MaxZofLayer[i], + &ChCollFoldType->MinYofLayer[i], + &ChCollFoldType->MaxYofLayer[i]) < 4 + ) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); + } + if (fscanf(lun, "%i%i", &ChCollFoldType->NofColofLayer[i], &ChCollFoldType->NofRowofLayer[i]) < 2 + ) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); + } + + ChCollFoldType->NofColofLayer[i] ++; + ChCollFoldType->NofRowofLayer[i] ++; + const G4int npoints = ChCollFoldType->NofColofLayer[i]*ChCollFoldType->NofRowofLayer[i]; + if(npoints>0 && npoints < std::numeric_limits<int>::max()) { + ChCollFoldType->NofPointsinLayer[i]=npoints; + if (i==0) { + ChCollFoldType->pLayer[i]=0; + } else { + ChCollFoldType->pLayer[i]=ChCollFoldType->pLayer[i-1]+ 3*ChCollFoldType->NofPointsinLayer[i-1]; + } + + for(G4int j=0;j<npoints;++j){ + G4double zdummy,ydummy,wdummy; + if (fscanf(lun, "%lg%lg%lg", &zdummy,&ydummy,&wdummy) < 3) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); + } + } // end for points + } + ATH_MSG_INFO(" foldtype="<<foldtype<< " wheeltype="<<wheeltype + <<" ilayer = " << i << " zmin, max = " + << ChCollFoldType->MinZofLayer[i] << " " + << ChCollFoldType->MaxZofLayer[i] << " " + << " ymin, max = " + << ChCollFoldType->MinYofLayer[i] << " " + << ChCollFoldType->MaxYofLayer[i] << " " + << " ncol = " << ChCollFoldType->NofColofLayer[i] + << " nrow = " << ChCollFoldType->NofRowofLayer[i] + << " npoints = " << npoints); + } // end for layers + + const G4int length=ChCollFoldType->pLayer[nlayer-1]+3*ChCollFoldType->NofPointsinLayer[nlayer-1]; + ChCollFoldType->FieldMap = new G4double [length]; + + if(ChCollFoldType->FieldMap == 0 ) { + + ATH_MSG_FATAL(" ***GetFieldMaps: FATAL FieldMap array cannot be created"); } + + } // end for wheels + } //end for foldtypes + + rewind(lun); + if(s_FieldMapVersion != "v00") { + if (fscanf(lun, "%9s", fieldmapversion) < 1) { + ATH_MSG_ERROR( "GetFieldMaps Error reading field map"); } + } -// now fill the coordinates and efield in the FieldMaps - - for(foldtype = 0; foldtype < foldtypemx; ++ foldtype){ - for(wheeltype = 0; wheeltype < 2; ++ wheeltype){ - - if(wheeltype == 0) ChCollWheelType = &ChCollInner; - if(wheeltype == 1) ChCollWheelType = &ChCollOuter; - if(foldtype == 0 ) ChCollFoldType = &(ChCollWheelType->Fold1); - if(foldtype == 1 ) ChCollFoldType = &(ChCollWheelType->Fold0); - - nlayer = ChCollWheelType->NumberOfRadialLayer; // should be the same for Fold0 and Fold1 - - for(i=0; i<nlayer; ++i){ - - G4double dummy1,dummy2,dummy3,dummy4; - G4int dummy5,dummy6; - if (fscanf(lun, "%lg%lg%lg%lg", &dummy1, &dummy2, &dummy3, &dummy4) < 4) { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - if (fscanf(lun, "%i%i", &dummy5, &dummy6) < 2) { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - - npoints = ChCollFoldType->NofPointsinLayer[i]; - if(npoints>0){ - for(j = 0; j < npoints; ++ j){ - if (fscanf(lun, "%lg%lg%lg", &ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)], - &ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)], - &ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)]) < 3) - { - (*m_msg) << MSG::ERROR - << "GetFieldMaps Error reading field map" << endreq; - } - -/* if(j<10) G4cout<<" z,y,weight=" - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)]<<" " - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)]<<" " - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)] - <<G4endl; */ - - } // end of loop(j) on points - } - } // end of loop(i) on layers - } // end of loop on wheeltype - } // end of loop for foldtypes - // (*m_msg) << endreq; - fclose(lun); - FieldMapsRead = true; + // now fill the coordinates and efield in the FieldMaps + + for(G4int foldtype = 0; foldtype < foldtypemx; ++ foldtype) { + for(G4int wheeltype = 0; wheeltype < 2; ++ wheeltype){ + //if(wheeltype == 0) ChCollWheelType = &ChCollInner; + //if(wheeltype == 1) ChCollWheelType = &ChCollOuter; + Wheel_Efield_Map *ChCollWheelType = (wheeltype == 0) ? &s_ChCollInner : + ( (wheeltype == 1) ? &s_ChCollOuter : 0 ); + + //if(foldtype == 0 ) ChCollFoldType = &(ChCollWheelType->Fold1); + //if(foldtype == 1 ) ChCollFoldType = &(ChCollWheelType->Fold0); + Fold_Efield_Map *ChCollFoldType = ( foldtype == 0 ) ? &(ChCollWheelType->Fold1) : + ( ( foldtype == 1 ) ? &(ChCollWheelType->Fold0) : 0 ); + + const G4int nlayer = ChCollWheelType->NumberOfRadialLayer; // should be the same for Fold0 and Fold1 + for(G4int i=0; i<nlayer; ++i){ + G4double dummy1,dummy2,dummy3,dummy4; + G4int dummy5,dummy6; + if (fscanf(lun, "%lg%lg%lg%lg", &dummy1, &dummy2, &dummy3, &dummy4) < 4) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); + } + if (fscanf(lun, "%i%i", &dummy5, &dummy6) < 2) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); + } + + const G4int npoints = ChCollFoldType->NofPointsinLayer[i]; + if(npoints>0){ + for(G4int j = 0; j < npoints; ++ j){ + if (fscanf(lun, "%lg%lg%lg", &ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)], + &ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)], + &ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)]) < 3) { + ATH_MSG_ERROR("GetFieldMaps Error reading field map"); + } + + /* if(j<10) G4cout<<" z,y,weight=" + <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)]<<" " + <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)]<<" " + <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)] + <<G4endl; */ + + } // end of loop(j) on points + } + } // end of loop(i) on layers + } // end of loop on wheeltype + } // end of loop for foldtypes + fclose(lun); + s_FieldMapsRead = true; } // ********************************************************** -void EnergyCalculator::PrepareFieldMap(void){ -// ********************************************************** +void LArG4::EC::EnergyCalculator::PrepareFieldMap(Wheel_Efield_Map* ChCollWheelType) { + // ********************************************************** //Selects points which are in the range -0<z<QuarterWaveLength; //Set weights to 1 for points in LAr if they were not defined //previously; @@ -599,417 +569,456 @@ void EnergyCalculator::PrepareFieldMap(void){ //coordinates can be computed from the point-address and // minz,maxz,miny,maxy parameters. - G4int nredef,nlayer,ncol,ipnt,ipold,i,j,foldtype,foldtypemx; - G4double minz,y,z,w,wx; - G4int npoints; G4double maxz=0.; - - (*m_msg) << MSG::INFO - << "PrepareFieldMap for solidtype = " - << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type()) - << endreq; - - nlayer = ChCollWheelType->NumberOfRadialLayer; // should be the same for Fold0 and Fold1 - foldtypemx=1; - if( ChCollWheelType->Fold1.FieldMapPrepared && - ChCollWheelType->Fold0.FieldMapPrepared) foldtypemx=2; - - for(foldtype = 0; foldtype < foldtypemx; ++ foldtype){ - - if(foldtype == 0 ) ChCollFoldType = &(ChCollWheelType->Fold1); //normal fold - if(foldtype == 1 ) ChCollFoldType = &(ChCollWheelType->Fold0); //very first fold - - for(i=0; i<nlayer; ++i){ - - if(foldtype == 0) { //normal fold - minz=ChCollFoldType->MinZofLayer[i]; - maxz=lwc()->GetQuarterWaveLength(); - ncol=G4int( (maxz-minz)/GridSize+1.1 ); - ChCollFoldType->NofColofLayer[i]=ncol; - ChCollFoldType->MaxZofLayer[i]=lwc()->GetQuarterWaveLength(); - } - - ipnt=-1; // new counter for numbering the selected points - nredef=0; //counter to know how many weights are redefined to be 1 (only for V00) - npoints=ChCollFoldType->NofPointsinLayer[i]; - if(npoints>0){ - for(j=0;j<npoints;++j){ - - z=ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)]; - y=ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)]; - w=ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)]; - wx=w; - - ipold=ipnt; - - if(foldtype == 1 ){ // very first fold - ++ipnt; - if(wx < 0.00001 ) wx=0.; - } - else{ // normal folds - if(z<maxz){ // only grid points within quarterwavelength is to be included - ++ipnt; - if(w<0.00001){ // check weight in the file - if(FieldMapVersion != "v00") wx=0.; // new map - else{ // old map - SetHalfWave(lwc()->GetStraightStartSection()+WaveLength+z); - PointFoldMapArea=1; - SetYlimitsofPhigapinFieldMap(i); - if((y>=Ylimits[0] && y<=Ylimits[1]) || - (y>=Ylimits[2] && y<=Ylimits[3])){ //point in LAr - wx=1.; // Dice computes the Ylimits at (z+GridShift) value, - ++nredef; // I don't know why...By neglecting GridShift nredef - // is much less. - } - }// endif for old map - } //endif for w<0 - }// endif for z<maxz - }//end for normal fold - - if(ipold != ipnt){ - - ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,ipnt)]=z; - ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,ipnt)]=y; - ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,ipnt)]=wx; - -/* if(ipnt<10) - G4cout<<" ilayer="<<i<<" ipnt="<<ipnt<<" weights=" - <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,ipnt)] - <<G4endl;*/ - } - - } // end j loop for points - } - if(ipnt+1 != ChCollFoldType->NofColofLayer[i]*ChCollFoldType->NofRowofLayer[i] ){ - (*m_msg) << MSG::FATAL - <<" ERROR: ipnt+1="<<ipnt+1<<" npoints="<< - ChCollFoldType->NofColofLayer[i]*ChCollFoldType->NofRowofLayer[i] - <<endreq; - } - } //end i loop for layers - } //end for foldtype + //G4int nredef,nlayer,ncol,ipnt,ipold/*,i,j,foldtype,foldtypemx*/; + G4double minz/*,y,z,w,wx*/; + //G4int npoints; + G4double maxz=0.; + + ATH_MSG_INFO("PrepareFieldMap for solidtype = " + << LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())); + + const G4int nlayer = ChCollWheelType->NumberOfRadialLayer; // should be the same for Fold0 and Fold1 + //foldtypemx=1; + //if ( ChCollWheelType->Fold1.FieldMapPrepared && ChCollWheelType->Fold0.FieldMapPrepared) { + // foldtypemx=2; + //} + + const G4int foldtypemx = (ChCollWheelType->Fold1.FieldMapPrepared && ChCollWheelType->Fold0.FieldMapPrepared) ? 2 : 1; + + for(G4int foldtype = 0; foldtype < foldtypemx; ++ foldtype) { + + //if(foldtype == 0 ) ChCollFoldType = &(ChCollWheelType->Fold1); //normal fold + //if(foldtype == 1 ) ChCollFoldType = &(ChCollWheelType->Fold0); //very first fold + Fold_Efield_Map *ChCollFoldType = ( foldtype == 0 ) ? &(ChCollWheelType->Fold1) : + ( ( foldtype == 1 ) ? &(ChCollWheelType->Fold0) : 0 ); + + for(G4int i=0; i<nlayer; ++i) { + if(foldtype == 0) { //normal fold + minz = ChCollFoldType->MinZofLayer[i]; + maxz = lwc()->GetQuarterWaveLength(); + ChCollFoldType->NofColofLayer[i] = G4int( (maxz-minz)/s_GridSize+1.1 ); + ChCollFoldType->MaxZofLayer[i] = lwc()->GetQuarterWaveLength(); + } + + G4int ipnt=-1; // new counter for numbering the selected points + G4int nredef=0; //counter to know how many weights are redefined to be 1 (only for V00) + const G4int npoints=ChCollFoldType->NofPointsinLayer[i]; + //if(npoints>0) { + for(G4int j=0;j<npoints;++j){ + const G4double z=ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,j)]; + const G4double y=ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,j)]; + const G4double w=ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,j)]; + G4double wx=w; + + const G4int ipold=ipnt; + + if(foldtype == 1 ) { // very first fold + ++ipnt; + if( wx < 0.00001 ) wx=0.; + } else { // normal folds + if(z<maxz) { // only grid points within quarterwavelength is to be included + ++ipnt; + if( w<0.00001 ) { // check weight in the file + if(s_FieldMapVersion != "v00") { + wx=0.; // new map + } else { // old map + WheelGeometry _wg; + SetHalfWave(lwc()->GetStraightStartSection()+WaveLength()+z, _wg); + //PointFoldMapArea=1; // looks like this assignment does not affect on something + G4double Ylimits[4]; + SetYlimitsofPhigapinFieldMap(i, _wg, Ylimits); + if ((y>=Ylimits[0] && y<=Ylimits[1]) || + (y>=Ylimits[2] && y<=Ylimits[3])) { //point in LAr + wx=1.; // Dice computes the Ylimits at (z+GridShift) value, + ++nredef; // I don't know why...By neglecting GridShift nredef + // is much less. + } + }// endif for old map + } //endif for w<0 + }// endif for z<maxz + }//end for normal fold + + + if(ipold != ipnt){ + + ChCollFoldType->FieldMap[Index(ChCollFoldType,i,0,ipnt)]=z; + ChCollFoldType->FieldMap[Index(ChCollFoldType,i,1,ipnt)]=y; + ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,ipnt)]=wx; + + /* if(ipnt<10) + G4cout<<" ilayer="<<i<<" ipnt="<<ipnt<<" weights=" + <<ChCollFoldType->FieldMap[Index(ChCollFoldType,i,2,ipnt)] + <<G4endl;*/ + } + + } // end j loop for points + //} + if(ipnt+1 != ChCollFoldType->NofColofLayer[i]*ChCollFoldType->NofRowofLayer[i] ){ + ATH_MSG_FATAL(" ERROR: ipnt+1="<<ipnt+1<<" npoints="<< + ChCollFoldType->NofColofLayer[i]*ChCollFoldType->NofRowofLayer[i]); + } + } //end i loop for layers + } //end for foldtype } //end of function // **************************************************************************** -G4double EnergyCalculator::GetHV_Value_ChColl_Wheel( - const G4ThreeVector& p, G4int phigap, G4int phihalfgap) const{ -// **************************************************************************** - const G4int atlasside = (lwc()->GetAtlasZside() > 0) ? 0 : 1; +G4double LArG4::EC::EnergyCalculator::GetHV_Value_ChColl_Wheel( + const G4ThreeVector& p, G4int phigap, G4int phihalfgap) const{ + // **************************************************************************** + const G4int atlasside = (lwc()->GetAtlasZside() > 0) ? 0 : 1; + + const G4ThreeVector pforeta= G4ThreeVector(p.x(),p.y(),p.z()+lwc()->GetElecFocaltoWRP()+lwc()->GetdWRPtoFrontFace()); + const G4double eta=pforeta.pseudoRapidity(); + G4int etasection=-1; + for(G4int i=1;i<=s_NofEtaSection;++i){ + if(eta<=s_HV_Etalim[i]) {etasection=i-1;break;} + } - const G4ThreeVector pforeta= G4ThreeVector(p.x(),p.y(),p.z()+lwc()->GetElecFocaltoWRP()+lwc()->GetdWRPtoFrontFace()); - const G4double eta=pforeta.pseudoRapidity(); - G4int etasection=-1; - for(G4int i=1;i<=NofEtaSection;++i){ - if(eta<=HV_Etalim[i]) {etasection=i-1;break;} - } + if(!(etasection>=0 && etasection <=s_NofEtaSection-1)) throw std::runtime_error("Index out of range"); + //assert(etasection>=0 && etasection <=s_NofEtaSection-1); + /*(right side of e large phi)*/ /*left side of electrode(small phi)*/ + const G4int electrodeside = (phihalfgap%2 == 0 ) ? 1 : 0 ; - if(!(etasection>=0 && etasection <=NofEtaSection-1)) throw std::runtime_error("Index out of range"); - //assert(etasection>=0 && etasection <=NofEtaSection-1); - /*(right side of e large phi)*/ /*left side of electrode(small phi)*/ - const G4int electrodeside = (phihalfgap%2 == 0 ) ? 1 : 0 ; + const G4int firstelectrode=s_HV_Start_phi[atlasside][etasection][electrodeside]; - const G4int firstelectrode=HV_Start_phi[atlasside][etasection][electrodeside]; + if(!( firstelectrode>=0 && firstelectrode<= lwc()->GetNumberOfFans()-1)){ + ATH_MSG_FATAL(" GetCurrent:Electrode number is out of range"); + G4Exception("EnergyCalculator", "ElectrodeOutOfRange", FatalException, "GetCurrent: Electrode number is out of range"); + } + G4int electrodeindex=(phigap-1)-firstelectrode; + if(electrodeindex<0) electrodeindex=electrodeindex+lwc()->GetNumberOfFans(); + const G4int phisection=electrodeindex/NumberOfElectrodesInPhiSection();//24(8) for outer(inner) wheel - if(!( firstelectrode>=0 && firstelectrode<= lwc()->GetNumberOfFans()-1)){ - (*m_msg) << MSG::FATAL <<" GetCurrent:Electrode number is out of range" << endreq; - G4Exception("EnergyCalculator", "ElectrodeOutOfRange", FatalException, "GetCurrent: Electrode number is out of range"); - } - G4int electrodeindex=(phigap-1)-firstelectrode; - if(electrodeindex<0) electrodeindex=electrodeindex+lwc()->GetNumberOfFans(); - const G4int nofelectrodesinphisection=lwc()->GetNumberOfFans()/NofPhiSections;//24(8) for outer(inner) wheel - const G4int phisection=electrodeindex/nofelectrodesinphisection; - - if(!(phisection>=0 && phisection<=NofPhiSections-1)){ - (*m_msg) << MSG::FATAL <<" GetCurrent::Electrode number is out of range" << endreq; - G4Exception("EnergyCalculator", "ElectrodeOutOfRange", FatalException,"GetCurrent: Electrode number is out of range"); - } + if(!(phisection>=0 && phisection<=NofPhiSections()-1)){ + ATH_MSG_FATAL(" GetCurrent::Electrode number is out of range"); + G4Exception("EnergyCalculator", "ElectrodeOutOfRange", FatalException,"GetCurrent: Electrode number is out of range"); + } - G4double HV_value= HV_Values[atlasside][etasection][electrodeside][phisection]; + const G4double HV_value = s_HV_Values[atlasside][etasection][electrodeside][phisection]; - return HV_value; + return HV_value; } // ********************************************************************** -void EnergyCalculator::TransFromBarrtoWheel(G4double vb[], G4double v[]){ -// ********************************************************************** -// this is valid for BacOuterBarrett -// vb: point coord. in the local system of the BackOuterBarrett:PhiDiv -// v : point coord. in the Wheel's system (extended in - and + z direction) -// ellenorizni, hogy p.phi() 0-2pi kozott valtozik-e!! +void LArG4::EC::EnergyCalculator::TransFromBarrtoWheel(const G4double vb[], G4double PhiStartOfPhiDiv, G4double v[]) const { + // ********************************************************************** + // this is valid for BacOuterBarrett + // vb: point coord. in the local system of the BackOuterBarrett:PhiDiv + // v : point coord. in the Wheel's system (extended in - and + z direction) + // ellenorizni, hogy p.phi() 0-2pi kozott valtozik-e!! const G4ThreeVector pb=G4ThreeVector(vb[0],vb[1],vb[2]); v[2]=lwc()->GetWheelThickness()+lwc()->GetdWRPtoFrontFace()*0.5-vb[2]; const G4double rb = pb.perp(); - const G4double phib = pb.phi(); // local phi coord. of a point in the PhiDiv - G4double phi_inb = PhiStartOfPhiDiv + phib; //PhiStartOfPhiDiv defined in FindIdentifier!! - // it is the phi pos. of the PhiDiv in the Barrette system - //phi_inb is the point's phi coord. in the BArrette volume - // it can be bigger than 2pi! - if(lwc()->type() == LArWheelCalculator::OuterAbsorberWheel ){ + const G4double phib = pb.phi(); // local phi coord. of a point in the PhiDiv + G4double phi_inb = PhiStartOfPhiDiv + phib; // PhiStartOfPhiDiv defined in FindIdentifier!! + // it is the phi pos. of the PhiDiv in the Barrette system + // phi_inb is the point's phi coord. in the Barrette volume + // it can be bigger than 2pi! + if(lwc()->type() == LArG4::OuterAbsorberWheel ){ if(phi_inb<0.) phi_inb= phi_inb + CLHEP::twopi; if(phi_inb>CLHEP::twopi) phi_inb= phi_inb - CLHEP::twopi; phi_inb = CLHEP::twopi - phi_inb; //now:phi_inb is the phi coord in the Wheel's system } - else if(lwc()->type() == LArWheelCalculator::OuterAbsorberModule) { + else if(lwc()->type() == LArG4::OuterAbsorberModule) { phi_inb = CLHEP::pi - phi_inb; //now:phi_inb is the point's phi coord in the Wheel's system; }else{ // the transfromation is different bec. the back support // positioned with an extra rotation into the Mother - (*m_msg) << MSG::FATAL <<" ERROR: TransFromBarrtoWheel: type("<<LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())<<") is unknown" - <<endreq; + ATH_MSG_FATAL(" ERROR: TransFromBarrtoWheel: type("<<LArWheelCalculator::LArWheelCalculatorTypeString(lwc()->type())<<") is unknown"); } v[0]=rb*cos(phi_inb); v[1]=rb*sin(phi_inb); } -// ********************************************************************** -G4double EnergyCalculator::GetCurrent( - G4double StartofStep[],G4double EndofStep[],G4double edep) { // need to make const -// ********************************************************************** - G4double v1b[3],v2b[3],vstepb[3]/*,vstepx[3]*/,hvpoint[3]; - G4double current/*,z1,z2*/,v1[3],v2[3],vstep[3],vmap[3];//,vmid[3],vmidmap[3]; - G4double steplength,Ymid,yratiox/*,rvmid*/,gap; - G4double yratio,yonlowerlayer,yonupperlayer,weightdown,weightup,r,dr;//,weight; - G4double ds/*,curdown,curup*/,cur,rvstep/*,halflargapsizefrommap*/,rforalpha; - //G4double cura,curb,currenta,currentb; - G4double /*efield,efieldnormalized,*/tol,shift; - G4double yshift_on_map,yshift_on_wheel,cylgapcorr; +G4int LArG4::EC::EnergyCalculator::_getIRlayer(G4double rforalpha) const { + G4int irlayer=0; + const G4int numberofradiallayers=ChCollWheelType()->NumberOfRadialLayer; + for(G4int j=0;j<numberofradiallayers;++j){ + if(rforalpha < ChCollWheelType()->RadiusOfLayers[j]) { + irlayer=j-1; + break; + } + } + assert(irlayer>=0 && irlayer<numberofradiallayers-1); + return irlayer; +} + +G4double LArG4::EC::EnergyCalculator::_interpolateCurrentSubStep(G4double rforalpha, G4int gapup, const G4double vmap[], G4double tol, const FoldArea & fa, G4int & gaperr ) const { + + assert(gapup == 1 || gapup == -1); + //search for radial layers the substep is in between; + const G4int irlayer = _getIRlayer(rforalpha); + + // check whether interpolation is needed + if (!fa.ChCollFoldType->FieldMapPrepared || // fieldmap is not available for this fold + (vmap[2] < fa.ChCollFoldType->MinZofLayer[irlayer] && // or out of z range of both maps + vmap[2] < fa.ChCollFoldType->MinZofLayer[irlayer+1]) + ) { + return 1.0; // interpolation not needed + } + + // interpolation needed + // compute radial interpolation parameter + const G4double dr = (rforalpha-ChCollWheelType()->RadiusOfLayers[irlayer]) + /(ChCollWheelType()->RadiusOfLayers[irlayer+1] - ChCollWheelType()->RadiusOfLayers[irlayer]); - G4int i,j/*,yup*/,irlayer,igap1,igap2,ihalfgap1,ihalfgap2,nofstep,gapup,gaperr; + // get Ylimits limiting the LAr gap along the y axis; + G4double shift = lwc()->GetStraightStartSection(); + if(fa.PointFoldMapArea != 0) shift += WaveLength(); - yratio=0.,yonlowerlayer=0.; yonupperlayer=0.; //to avoid compiler warning + WheelGeometry _wg; + SetHalfWave(shift+vmap[2], _wg); - tol=0.1*CLHEP::mm; // tolerance for geom. check - gaperr=0; + G4double Ylimits[4]; + SetYlimitsofPhigapinWheel(rforalpha, rforalpha, _wg, Ylimits); - if(lwc()->GetisBarrette()){ - for(i=0;i<3;++i){ + //check geom. err condition if point is outside of LAr gap + if ( gaperr > -100 && + (vmap[1] > Ylimits[3]+tol || vmap[1] < Ylimits[0]-tol || + (vmap[1] < Ylimits[2]-tol && vmap[1] > Ylimits[1]+tol) ) + ) { + gaperr=gaperr-100; + } + + // get relative y coordinate + // if (gapup==-1) { + // yratio=(vmap[1]- Ylimits[0])/(Ylimits[1]- Ylimits[0]); + // } else if (gapup==+1) { + // yratio=(vmap[1]- Ylimits[2])/(Ylimits[3]- Ylimits[2]); + // } + G4double yratio = (gapup==-1) ? + (vmap[1]- Ylimits[0])/(Ylimits[1]- Ylimits[0]) + : + (vmap[1]- Ylimits[2])/(Ylimits[3]- Ylimits[2]) + ; + + const G4double yratiox=yratio; + if (yratiox<=0.) { + yratio=0.00001; // pull the point into the gap if it wouldn't be there; + } else if(yratiox>=1.) { + yratio=0.99999; // this may happen bec.G4 does not grantee that the full + } // step-line is within the same volume + // get corresponding y coordinates on the radial layers + // where the weight is to be taken from; + + SetYlimitsofPhigapinFieldMap(irlayer, _wg, Ylimits); //on the lower layer + + // if (gapup==-1) { + // yonlowerlayer = Ylimits[0]*(1.-yratio)+Ylimits[1]*yratio; + // } + // else if(gapup==1) { + // yonlowerlayer = Ylimits[2]*(1.-yratio)+Ylimits[3]*yratio; + // } + const G4double yonlowerlayer = (gapup==-1) ? + Ylimits[0]*(1.-yratio)+Ylimits[1]*yratio + : + Ylimits[2]*(1.-yratio)+Ylimits[3]*yratio + ; + + SetYlimitsofPhigapinFieldMap(irlayer+1, _wg, Ylimits); //on the upper layer + + // if(gapup==-1) { + // yonupperlayer = Ylimits[0]*(1.-yratio)+Ylimits[1]*yratio; + // } else if(gapup==1) { + // yonupperlayer = Ylimits[2]*(1.-yratio)+Ylimits[3]*yratio; + // } + const G4double yonupperlayer = (gapup==-1) ? + Ylimits[0]*(1.-yratio)+Ylimits[1]*yratio + : + Ylimits[2]*(1.-yratio)+Ylimits[3]*yratio + ; + + // get weights from the maps of lower and upper layer + const G4double weightdown = GetWeightfromFieldMap(irlayer, vmap[2], yonlowerlayer, fa); + const G4double weightup = GetWeightfromFieldMap(irlayer+1,vmap[2], yonupperlayer, fa); + + // get the interpolated normalized Efield alias cur + return weightdown*(1.-dr)+weightup*dr; + // end of interpolation +} + +// ********************************************************************** +G4double LArG4::EC::EnergyCalculator::GetCurrent( + G4double StartofStep[],G4double EndofStep[],G4double edep, G4double Barret_PhiStart) const { + // ********************************************************************** + G4double v1b[3],v2b[3],hvpoint[3]; + G4double v1[3],v2[3],vstep[3]; + + //yratio=0.; + //yonlowerlayer=0.; + //yonupperlayer=0.; //to avoid compiler warning + + const G4double tol=0.1*CLHEP::mm; // tolerance for geom. check + G4int gaperr=0; + + if(lwc()->GetisBarrette()) { + for(G4int i=0;i<3;++i) { v1b[i]=StartofStep[i]; v2b[i]=EndofStep[i]; } - TransFromBarrtoWheel(v1b,v1); - TransFromBarrtoWheel(v2b,v2); - } - else{ - for(i=0;i<3;++i){ + TransFromBarrtoWheel(v1b, Barret_PhiStart, v1); + TransFromBarrtoWheel(v2b, Barret_PhiStart, v2); + } else { + for(G4int i=0;i<3;++i) { v1[i]=StartofStep[i]; v2[i]=EndofStep[i]; } } - SetHalfWave(v2[2]); //check whether start and endpoints are in the same gap - GetPhiGap(v2); - igap2 = PhiGapNumber; - ihalfgap2= PhiHalfGapNumber; + WheelGeometry _wg; + + SetHalfWave(v2[2], _wg); //check whether start and endpoints are in the same gap + GetPhiGap(v2, _wg); + const G4int igap2 = _wg.PhiGapNumber; + const G4int ihalfgap2 = _wg.PhiHalfGapNumber; + + SetHalfWave(v1[2], _wg); + GetPhiGap(v1, _wg); - SetHalfWave(v1[2]); - GetPhiGap(v1); - SetFoldArea(v1[2]); - igap1 = PhiGapNumber; // from 1 to NumberOfFans - ihalfgap1= PhiHalfGapNumber; + FoldArea _fa; + + SetFoldArea(v1[2], _fa); + const G4int igap1 = _wg.PhiGapNumber; // from 1 to NumberOfFans + const G4int ihalfgap1 = _wg.PhiHalfGapNumber; if( (igap1 != igap2) || (ihalfgap1 != ihalfgap2) ) gaperr = -1; - chcollPhiGap=igap1-1; - -// define electrode side on the field map; -// start point is used, because G4 does not garantee that the middlepoint is in the LAr gap - - TransformWheeltoFieldMap(v1,vmap); - r=sqrt(v1[0]*v1[0]+v1[1]*v1[1]); - r=sqrt(r*r-vmap[1]*vmap[1]); - - shift = lwc()->GetStraightStartSection(); - if(PointFoldMapArea != 0) shift += WaveLength; - SetHalfWave(shift+vmap[2]); - SetYlimitsofPhigapinWheel(r,r); // get the y limits of LAr gap - - Ymid=0.5*(Ylimits[1]+Ylimits[2]); - if(vmap[1]>Ymid) gapup=+1; //step is above electrode - else gapup=-1; //step is below electrode - //this should be true for the full step - - if( vmap[1] > Ylimits[3]+tol || vmap[1] < Ylimits[0]-tol || - (vmap[1] < Ylimits[2]-tol && vmap[1] > Ylimits[1]+tol) ) gaperr=gaperr-10; - -//loop for substeps - - steplength=sqrt((v1[0]-v2[0])*(v1[0]-v2[0])+(v1[1]-v2[1])*(v1[1]-v2[1])+ - (v1[2]-v2[2])*(v1[2]-v2[2])); - nofstep=int(steplength/GridSize)+1; // step is divided to substeps - current=0.; //current to be returned - - for(i=0;i<nofstep;++i){ - - G4double supcorr =1.; - -// compute substep point - ds=(i+0.5)/nofstep; - for(j=0;j<3;++j){ - vstep[j]=v1[j]*(1.-ds)+v2[j]*ds; // get the middle point of substep - hvpoint[j]=vstep[j]; // hvpoint is always in local coord. Wheel or PhiDiv) - if(lwc()->GetisBarrette()){ - vstepb[j]=v1b[j]*(1.-ds)+v2b[j]*ds; - hvpoint[j]=vstepb[j]; - } - } - - G4double HV_value; - if(lwc()->GetisBarrette()) - HV_value=GetHV_Value_Barrett( - G4ThreeVector(hvpoint[0],hvpoint[1],hvpoint[2])); - else - HV_value=GetHV_Value_ChColl_Wheel( - G4ThreeVector(hvpoint[0],hvpoint[1],hvpoint[2]),igap1,ihalfgap1); - - G4ThreeVector tmp = G4ThreeVector( hvpoint[0],hvpoint[1],hvpoint[2]); - G4double dte = (this->*distance_to_the_nearest_electrode_type)(tmp); - - if(fabs(dte) < CHC_Esr) continue; //skip point if too close to the electrode - - G4double agap=(this->*GetGapSize_type)(tmp); //correction to electrode suppression not to - G4double x= agap/(agap-CHC_Esr); // change av. signal in the gap - if(x >=0.) supcorr=x; - - SetFoldArea(vstep[2]); // set fold type - SetHalfWave(vstep[2]); // set halfwave parameters for substep - TransformWheeltoFieldMap(vstep,vmap); //get corresponding point in Map - //system (it is equivalent to the - //halfwave system of pos. slope) - rvstep =sqrt(vstep[0]*vstep[0]+vstep[1]*vstep[1]); - rforalpha=sqrt(rvstep*rvstep-vmap[1]*vmap[1]); // radius in the electrode system - gap=HalfLArGapSize(rforalpha,rforalpha); // gapsize in the straight section - yshift_on_map = rforalpha*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness+FanEleThickness)/2.; - yshift_on_wheel= rvstep*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness+FanEleThickness)/2.; - cylgapcorr=yshift_on_wheel/yshift_on_map; // scale difference between plane and cylindrical surface - /* - std::cout<< " GetCurrent0**Nabs="<<lwc()->GetNumberOfFans()<<" absthick="<<FanAbsThickness - <<" elethick="<<FanEleThickness - <<" cylgapcorr-1="<<cylgapcorr-1 - <<" ZinHalfWave="<<ZinHalfWave<<" HalfWaveNumber="<<HalfWaveNumber - <<std::endl; - */ -//search for radial layers the substep is in between; - - irlayer=0; - G4int numberofradiallayers=ChCollWheelType->NumberOfRadialLayer; - for(j=0;j<numberofradiallayers;++j){ - if(rforalpha<ChCollWheelType->RadiusOfLayers[j]) { - irlayer=j-1; - break;} - } - assert(irlayer>=0 && irlayer<numberofradiallayers-1); - -// check whether interpolation is needed - - if(!ChCollFoldType->FieldMapPrepared || // fieldmap is not available for this fold - (vmap[2]<ChCollFoldType->MinZofLayer[irlayer] && // or out of z range of both maps - vmap[2]<ChCollFoldType->MinZofLayer[irlayer+1]) ){ - - cur=1.; // interpolation not needed - } - else{ // interpolation needed - -// compute radial interpolation parameter - - dr=(rforalpha-ChCollWheelType->RadiusOfLayers[irlayer]) - /(ChCollWheelType->RadiusOfLayers[irlayer+1]- - ChCollWheelType->RadiusOfLayers[irlayer]); - -// get Ylimits limiting the LAr gap along the y axis; - - shift = lwc()->GetStraightStartSection(); - if(PointFoldMapArea != 0) shift += WaveLength; - SetHalfWave(shift+vmap[2]); - SetYlimitsofPhigapinWheel(rforalpha,rforalpha); - -//check geom. err condition if point is outside of LAr gap - if( gaperr > -100 && - ( vmap[1] > Ylimits[3]+tol || vmap[1] < Ylimits[0]-tol || - (vmap[1] < Ylimits[2]-tol && vmap[1] > Ylimits[1]+tol) )) gaperr=gaperr-100; - -// get relative y coordinate - - if (gapup==-1) yratio=(vmap[1]- Ylimits[0])/(Ylimits[1]- Ylimits[0]); - else if (gapup==+1) yratio=(vmap[1]- Ylimits[2])/(Ylimits[3]- Ylimits[2]); - - yratiox=yratio; - if(yratiox<=0.) yratio=0.00001; // pull the point into the gap if it wouldn't be there; - else if(yratiox>=1.) yratio=0.99999; // this may happen bec.G4 does not grantee that the full - // step-line is within the same volume -// get corresponding y coordinates on the radial layers -// where the weight is to be taken from; - - SetYlimitsofPhigapinFieldMap(irlayer); //on the lower layer - - if (gapup==-1) - yonlowerlayer=Ylimits[0]*(1.-yratio)+Ylimits[1]*yratio; - else if(gapup==1) - yonlowerlayer=Ylimits[2]*(1.-yratio)+Ylimits[3]*yratio; - - SetYlimitsofPhigapinFieldMap(irlayer+1); //on the upper layer - - if(gapup==-1) - yonupperlayer=Ylimits[0]*(1.-yratio)+Ylimits[1]*yratio; - else if(gapup==1) - yonupperlayer=Ylimits[2]*(1.-yratio)+Ylimits[3]*yratio; - -// get weights from the maps of lower and upper layer - - weightdown=GetWeightfromFieldMap(irlayer, vmap[2],yonlowerlayer); - weightup =GetWeightfromFieldMap(irlayer+1,vmap[2],yonupperlayer); - - // get the interpolated normalized Efield alias cur - - cur=weightdown*(1.-dr)+weightup*dr; - - } // end of interpolation - -// old current calculation: edep*E**1.3*(gap0/gap)**1.3 -// normalized so, that signal=edep in the straight section of gap0=1.3mm -// (it is at eta=2.25, r=787mm, foldingangle~110 degree) -// currentb=currentb+(edep/nofstep)*pow(curb*AverageGap/gap,1.3); -//(25-05-2005) new current calculation: edep*1/U*IonReco*E*v_drift -// normalized so that signal=edep in the straight section of the same gap -// as above; -// where: HV=1250V,E=9.615 [kv/cm] ,T=88.16 K, -// vdrift=4.62 [mm/mikrosec], Ionreco=96.4% -// ==> AverageCurrent=3.425/[mikrosec]; - - G4double efield=0.01*cur*HV_value/gap/cylgapcorr; // [kV/cm], bec.HV[V],gap[mm] - - double dc = (edep/nofstep)/AverageCurrent* - cur/gap/cylgapcorr*IonReco(efield)*DriftVelo(LArTemperature_av,efield)* - supcorr; - - current += dc; + // define electrode side on the field map; + // start point is used, because G4 does not garantee that the middlepoint is in the LAr gap + + G4double vmap[3]; + TransformWheeltoFieldMap(v1 ,vmap, _wg, _fa); + //r=sqrt(v1[0]*v1[0]+v1[1]*v1[1]); + //r=sqrt(r*r-vmap[1]*vmap[1]); + const G4double r = sqrt(v1[0]*v1[0] + v1[1]*v1[1] - vmap[1]*vmap[1]); + + { // shift scope + G4double shift = lwc()->GetStraightStartSection(); + if(_fa.PointFoldMapArea != 0) shift += WaveLength(); + + SetHalfWave(shift+vmap[2], _wg); + } + + G4double Ylimits[4]; + SetYlimitsofPhigapinWheel(r, r, _wg, Ylimits); // get the y limits of LAr gap + + const G4double Ymid=0.5*(Ylimits[1]+Ylimits[2]); + + //if(vmap[1]>Ymid) gapup=+1; //step is above electrode + //else gapup=-1; //step is below electrode + //this should be true for the full step + const G4int gapup = (vmap[1]>Ymid) ? +1 : -1; + + if ( vmap[1] > Ylimits[3]+tol || vmap[1] < Ylimits[0]-tol || + (vmap[1] < Ylimits[2]-tol && vmap[1] > Ylimits[1]+tol) + ) { + gaperr=gaperr-10; + } + + //loop for substeps + const G4double steplength=sqrt( + (v1[0]-v2[0])*(v1[0]-v2[0]) + + (v1[1]-v2[1])*(v1[1]-v2[1]) + + (v1[2]-v2[2])*(v1[2]-v2[2]) + ); + const G4int nofstep=G4int(steplength/s_GridSize)+1; // step is divided to substeps + G4double current=0.; //current to be returned + + for(G4int _nstep=0;_nstep < nofstep;++_nstep) { + G4double supcorr =1.; + + // compute substep point + const G4double ds=(_nstep+0.5)/nofstep; + for(G4int j=0;j<3;++j){ + vstep[j]=v1[j]*(1.-ds)+v2[j]*ds; // get the middle point of substep + hvpoint[j]=vstep[j]; // hvpoint is always in local coord. Wheel or PhiDiv) + if(lwc()->GetisBarrette()){ + //vstepb[j]=v1b[j]*(1.-ds)+v2b[j]*ds; + //hvpoint[j]=vstepb[j]; + hvpoint[j]=v1b[j]*(1.-ds)+v2b[j]*ds; + } + } + + G4double HV_value; + if(lwc()->GetisBarrette()) { + HV_value=GetHV_Value_Barrett( + G4ThreeVector(hvpoint[0],hvpoint[1],hvpoint[2]), Barret_PhiStart); + } else { + HV_value=GetHV_Value_ChColl_Wheel( + G4ThreeVector(hvpoint[0],hvpoint[1],hvpoint[2]),igap1,ihalfgap1); + } + + const G4ThreeVector tmp = G4ThreeVector( hvpoint[0],hvpoint[1],hvpoint[2]); + const G4double dte = (this->*m_distance_to_the_nearest_electrode_type)(tmp, Barret_PhiStart); + + if( fabs(dte) < CHC_Esr() ) continue; //skip point if too close to the electrode + + const G4double agap=(this->*m_GetGapSize_type)(tmp); //correction to electrode suppression not to + G4double x = agap/( agap - CHC_Esr() ); // change av. signal in the gap + if(x >=0.) supcorr=x; + + SetFoldArea(vstep[2], _fa); // set fold type + SetHalfWave(vstep[2], _wg); // set halfwave parameters for substep + TransformWheeltoFieldMap(vstep, vmap, _wg, _fa); //get corresponding point in Map + //system (it is equivalent to the + //halfwave system of pos. slope) + //rvstep = sqrt(vstep[0]*vstep[0]+vstep[1]*vstep[1]); + const G4double rvstep = hypot(vstep[0], vstep[1]); + const G4double rforalpha = sqrt(rvstep*rvstep-vmap[1]*vmap[1]); // radius in the electrode system + const G4double gap = HalfLArGapSize(rforalpha,rforalpha); // gapsize in the straight section + const G4double yshift_on_map = rforalpha*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness() + FanEleThickness())/2.; + const G4double yshift_on_wheel= rvstep*M_PI/lwc()->GetNumberOfFans()-(FanAbsThickness() + FanEleThickness())/2.; + const G4double cylgapcorr=yshift_on_wheel/yshift_on_map; // scale difference between plane and cylindrical surface + + const G4double cur = _interpolateCurrentSubStep( rforalpha, gapup, vmap, tol, _fa, gaperr ); + // old current calculation: edep*E**1.3*(gap0/gap)**1.3 + // normalized so, that signal=edep in the straight section of gap0=1.3mm + // (it is at eta=2.25, r=787mm, foldingangle~110 degree) + // currentb=currentb+(edep/nofstep)*pow(curb*AverageGap/gap,1.3); + //(25-05-2005) new current calculation: edep*1/U*IonReco*E*v_drift + // normalized so that signal=edep in the straight section of the same gap + // as above; + // where: HV=1250V,E=9.615 [kv/cm] ,T=88.16 K, + // vdrift=4.62 [mm/mikrosec], Ionreco=96.4% + // ==> AverageCurrent=3.425/[mikrosec]; + + const G4double efield=0.01*cur*HV_value/gap/cylgapcorr; // [kV/cm], bec.HV[V],gap[mm] + + const G4double dc = (edep/nofstep)/s_AverageCurrent* + cur/gap/cylgapcorr*IonReco(efield)*DriftVelo(s_LArTemperature_av,efield)* + supcorr; + + current += dc; } // end of loop for substeps - + if(current < 0.) { gaperr=gaperr-1000; current=0.; } + +#ifdef DEBUG_CHCL if(gaperr != 0 ) { - CHCEbad=CHCEbad+edep; - if(CHCIprint < CHCMaxPrint ){ - CHCIprint=CHCIprint+1; - (*m_msg) << MSG::WARNING - <<"GetCurrent has strange step,gaperr="<<gaperr<<" correction still computed" - <<" bad edep ratio="<<CHCEbad/CHCEtotal - << endreq; + s_CHCEbad=s_CHCEbad+edep; + if(s_CHCIprint < s_CHCMaxPrint ){ + s_CHCIprint=s_CHCIprint+1; + ATH_MSG_WARNING("GetCurrent has strange step,gaperr="<<gaperr<<" correction still computed" + <<" bad edep ratio="<<CHCEbad/CHCEtotal); } } //std::cout <<"GetCurrent0:: edep="<<edep<<" current="<<current<<" gaperr="<<gaperr<<std::endl; - +#endif + return current; } // ********************************************************** -G4double EnergyCalculator::GetWeightfromFieldMap( - G4int ilayer, G4double z, G4double y){ -// ********************************************************** +G4double LArG4::EC::EnergyCalculator::GetWeightfromFieldMap( + G4int ilayer, G4double z, G4double y, const FoldArea & fa) const { + // ********************************************************** //return interpolated weight from the fieldmap; // inp: ilayer= layernumber; // z,y = z and y coord. of the point where the weight @@ -1017,186 +1026,185 @@ G4double EnergyCalculator::GetWeightfromFieldMap( // they are defined in the coord system of the Map; // interpolated weight =1 by default; - G4int i,icol,irow,ip11,ip12,ip21,ip22; - G4double weight,eps; + G4int /*i,*/icol,irow,ip11,ip12,ip21,ip22; + G4double weight/*,eps*/; G4double w11,w12,w21,w22,z11/*,z12,z21,z22*/,y11/*,y12,y21,y22*/,wdown,wup, - w,dz,dy,dzx,dyx; + w,dz,dy,dzx,dyx; w11=1.; w12=1.; w21=1.; w22=1.; z11=0.; y11=0.; // to avoid compiler warning - weight=1.; - eps=0.0005; - i=ilayer; + weight=1.; + const G4double eps=0.0005; + const G4int i=ilayer; - //check whether the point is in the area of validity of the table - if(z<ChCollFoldType->MinZofLayer[i]-eps || z>ChCollFoldType->MaxZofLayer[i]+eps || - y<ChCollFoldType->MinYofLayer[i]-eps || y>ChCollFoldType->MaxYofLayer[i]+eps ){ - return weight; - } - - //Search for the 4 points in the grid surrounding P(z,y). - //Index of points in the FieldMap: - // (21)----(22) - // | P | - // (11)----(12) - //If some of them is outside of LAr their weight=0 by default. - //Weights set to zero by hand for those surrounding points which - //have no correspondant grid point in the table. - //Such situation will happen for example at the z border, - //because the z coordinate of the last - //column is less then QuarteWaveLength by 50 and 67 mikron for - //inner and outer wheel respectively; - //Only gridpoints of nonzero weight are taken into account - //for interpolation. - //The case of all 4 weights are zero should not happen. If still, - // interpolated weight =1 is returned. - - - icol=int((z-ChCollFoldType->MinZofLayer[i])/GridSize)+1; //column number of left corners - - if(icol>ChCollFoldType->NofColofLayer[i]) icol=ChCollFoldType->NofColofLayer[i]; - - irow=int((y-ChCollFoldType->MinYofLayer[i])/GridSize)+1; //row number of lower corners - if(irow>ChCollFoldType->NofRowofLayer[i]) irow=ChCollFoldType->NofRowofLayer[i]; - - assert(icol>0 && irow>0); - - ip11=(icol-1)*ChCollFoldType->NofRowofLayer[i]+irow-1; //index of points in the FieldMap - ip21=ip11+1; // (21)----(22) - ip12= icol *ChCollFoldType->NofRowofLayer[i]+irow-1; // (11)----(12) - ip22=ip12+1; - - G4int i2ip11=Index(ChCollFoldType,i,2,ip11); - G4int i2ip12=Index(ChCollFoldType,i,2,ip12); - G4int i2ip21=Index(ChCollFoldType,i,2,ip21); - G4int i2ip22=Index(ChCollFoldType,i,2,ip22); - G4int i0ip11=Index(ChCollFoldType,i,0,ip11); - //G4int i0ip12=Index(ChCollFoldType,i,0,ip12); - //G4int i0ip21=Index(ChCollFoldType,i,0,ip21); - //G4int i0ip22=Index(ChCollFoldType,i,0,ip22); - G4int i1ip11=Index(ChCollFoldType,i,1,ip11); - //G4int i1ip12=Index(ChCollFoldType,i,1,ip12); - //G4int i1ip21=Index(ChCollFoldType,i,1,ip21); - //G4int i1ip22=Index(ChCollFoldType,i,1,ip22); - - - if(icol<ChCollFoldType->NofColofLayer[i] && irow<ChCollFoldType->NofRowofLayer[i]){ - w11=ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; - w12=ChCollFoldType->FieldMap[i2ip12]; //[i][2][ip12]; - w21=ChCollFoldType->FieldMap[i2ip21]; //[i][2][ip21]; - w22=ChCollFoldType->FieldMap[i2ip22]; //[i][2][ip22]; - z11=ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; - //z12=ChCollFoldType->FieldMap[i0ip12]; //[i][0][ip12]; - //z21=ChCollFoldType->FieldMap[i0ip21]; //[i][0][ip21]; - //z22=ChCollFoldType->FieldMap[i0ip22]; //[i][0][ip22]; - y11=ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; - //y12=ChCollFoldType->FieldMap[i1ip12]; //[i][1][ip12]; - //y21=ChCollFoldType->FieldMap[i1ip21]; //[i][1][ip21]; - //y22=ChCollFoldType->FieldMap[i1ip22]; //[i][1][ip22]; - } - else if(icol==ChCollFoldType->NofColofLayer[i] && irow<ChCollFoldType->NofRowofLayer[i]){ - w11=ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; - w12=0.; - w21=ChCollFoldType->FieldMap[i2ip21]; //[i][2][ip21]; - w22=0.; - z11=ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; - //z12=z11+GridSize; - //z21=ChCollFoldType->FieldMap[i0ip21]; //[i][0][ip21]; - //z22=z11+GridSize; - y11=ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; - //y12=y11; - //y21=ChCollFoldType->FieldMap[i1ip21]; //[i][1][ip21]; - //y22=y11+GridSize; - } - else if(icol<ChCollFoldType->NofColofLayer[i] && irow==ChCollFoldType->NofRowofLayer[i]){ - w11=ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; - w12=ChCollFoldType->FieldMap[i2ip12]; //[i][2][ip12]; - w21=0.; - w22=0.; - z11=ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; - //z12=ChCollFoldType->FieldMap[i0ip12]; //[i][0][ip12]; - //z21=z11; - //z22=z11+GridSize; - y11=ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; - //y12=ChCollFoldType->FieldMap[i1ip12]; //[i][1][ip12]; - //y21=y11+GridSize; - //y22=y11+GridSize; - } - else if(icol==ChCollFoldType->NofColofLayer[i] && irow==ChCollFoldType->NofRowofLayer[i]){ - w11=ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; - w12=0.; - w21=0.; - w22=0.; - z11=ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; - //z12=z11+GridSize; - //z21=z11; - //z22=z11+GridSize; - y11=ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; - //y12=y11; - //y21=y11+GridSize; - //y22=y11+GridSize; - } + //check whether the point is in the area of validity of the table + if(z<fa.ChCollFoldType->MinZofLayer[i]-eps || z>fa.ChCollFoldType->MaxZofLayer[i]+eps || + y<fa.ChCollFoldType->MinYofLayer[i]-eps || y>fa.ChCollFoldType->MaxYofLayer[i]+eps ){ + return weight; + } - dz=(z-z11)/GridSize; - dy=(y-y11)/GridSize; - - if(dz<0.) dz=0.; - if(dz>1.) dz=1.; - if(dy<0.) dy=0.; - if(dy>1.) dy=1.; - - dzx=dz; - if(w11<0.000001) dzx=1.; - if(w12<0.000001) dzx=0.; - wdown=w11*(1.-dzx)+w12*dzx; //interpol. along lower line - dzx=dz; - if(w21<0.000001) dzx=1.; - if(w22<0.000001) dzx=0.; - wup=w21*(1.-dzx)+w22*dzx; //interpol. along upper line - - dyx=dy; - if(wdown<0.000001) dyx=1.; - if(wup <0.000001) dyx=0.; - w=wdown*(1.-dyx)+wup*dyx; //interpol along column - if(w>0.000001) weight=w; + //Search for the 4 points in the grid surrounding P(z,y). + //Index of points in the FieldMap: + // (21)----(22) + // | P | + // (11)----(12) + //If some of them is outside of LAr their weight=0 by default. + //Weights set to zero by hand for those surrounding points which + //have no correspondant grid point in the table. + //Such situation will happen for example at the z border, + //because the z coordinate of the last + //column is less then QuarteWaveLength by 50 and 67 mikron for + //inner and outer wheel respectively; + //Only gridpoints of nonzero weight are taken into account + //for interpolation. + //The case of all 4 weights are zero should not happen. If still, + // interpolated weight =1 is returned. + + + icol=int((z-fa.ChCollFoldType->MinZofLayer[i])/s_GridSize)+1; //column number of left corners + + if(icol>fa.ChCollFoldType->NofColofLayer[i]) icol=fa.ChCollFoldType->NofColofLayer[i]; + + irow=int((y-fa.ChCollFoldType->MinYofLayer[i])/s_GridSize)+1; //row number of lower corners + if(irow>fa.ChCollFoldType->NofRowofLayer[i]) irow=fa.ChCollFoldType->NofRowofLayer[i]; + + assert(icol>0 && irow>0); + + ip11=(icol-1)*fa.ChCollFoldType->NofRowofLayer[i]+irow-1; //index of points in the FieldMap + ip21=ip11+1; // (21)----(22) + ip12= icol *fa.ChCollFoldType->NofRowofLayer[i]+irow-1; // (11)----(12) + ip22=ip12+1; + + G4int i2ip11=Index(fa.ChCollFoldType,i,2,ip11); + G4int i2ip12=Index(fa.ChCollFoldType,i,2,ip12); + G4int i2ip21=Index(fa.ChCollFoldType,i,2,ip21); + G4int i2ip22=Index(fa.ChCollFoldType,i,2,ip22); + G4int i0ip11=Index(fa.ChCollFoldType,i,0,ip11); + //G4int i0ip12=Index(fa.ChCollFoldType,i,0,ip12); + //G4int i0ip21=Index(fa.ChCollFoldType,i,0,ip21); + //G4int i0ip22=Index(fa.ChCollFoldType,i,0,ip22); + G4int i1ip11=Index(fa.ChCollFoldType,i,1,ip11); + //G4int i1ip12=Index(fa.ChCollFoldType,i,1,ip12); + //G4int i1ip21=Index(fa.ChCollFoldType,i,1,ip21); + //G4int i1ip22=Index(fa.ChCollFoldType,i,1,ip22); + + + if(icol<fa.ChCollFoldType->NofColofLayer[i] && irow<fa.ChCollFoldType->NofRowofLayer[i]){ + w11=fa.ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; + w12=fa.ChCollFoldType->FieldMap[i2ip12]; //[i][2][ip12]; + w21=fa.ChCollFoldType->FieldMap[i2ip21]; //[i][2][ip21]; + w22=fa.ChCollFoldType->FieldMap[i2ip22]; //[i][2][ip22]; + z11=fa.ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; + //z12=fa.ChCollFoldType->FieldMap[i0ip12]; //[i][0][ip12]; + //z21=fa.ChCollFoldType->FieldMap[i0ip21]; //[i][0][ip21]; + //z22=fa.ChCollFoldType->FieldMap[i0ip22]; //[i][0][ip22]; + y11=fa.ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; + //y12=fa.ChCollFoldType->FieldMap[i1ip12]; //[i][1][ip12]; + //y21=fa.ChCollFoldType->FieldMap[i1ip21]; //[i][1][ip21]; + //y22=fa.ChCollFoldType->FieldMap[i1ip22]; //[i][1][ip22]; + } + else if(icol==fa.ChCollFoldType->NofColofLayer[i] && irow<fa.ChCollFoldType->NofRowofLayer[i]){ + w11=fa.ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; + w12=0.; + w21=fa.ChCollFoldType->FieldMap[i2ip21]; //[i][2][ip21]; + w22=0.; + z11=fa.ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; + //z12=z11+GridSize; + //z21=fa.ChCollFoldType->FieldMap[i0ip21]; //[i][0][ip21]; + //z22=z11+GridSize; + y11=fa.ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; + //y12=y11; + //y21=fa.ChCollFoldType->FieldMap[i1ip21]; //[i][1][ip21]; + //y22=y11+GridSize; + } + else if(icol<fa.ChCollFoldType->NofColofLayer[i] && irow==fa.ChCollFoldType->NofRowofLayer[i]){ + w11=fa.ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; + w12=fa.ChCollFoldType->FieldMap[i2ip12]; //[i][2][ip12]; + w21=0.; + w22=0.; + z11=fa.ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; + //z12=fa.ChCollFoldType->FieldMap[i0ip12]; //[i][0][ip12]; + //z21=z11; + //z22=z11+GridSize; + y11=fa.ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; + //y12=fa.ChCollFoldType->FieldMap[i1ip12]; //[i][1][ip12]; + //y21=y11+GridSize; + //y22=y11+GridSize; + } + else if(icol==fa.ChCollFoldType->NofColofLayer[i] && irow==fa.ChCollFoldType->NofRowofLayer[i]){ + w11=fa.ChCollFoldType->FieldMap[i2ip11]; //[i][2][ip11]; + w12=0.; + w21=0.; + w22=0.; + z11=fa.ChCollFoldType->FieldMap[i0ip11]; //[i][0][ip11]; + //z12=z11+GridSize; + //z21=z11; + //z22=z11+GridSize; + y11=fa.ChCollFoldType->FieldMap[i1ip11]; //[i][1][ip11]; + //y12=y11; + //y21=y11+s_GridSize; + //y22=y11+s_GridSize; + } - return weight; + dz=(z-z11)/s_GridSize; + dy=(y-y11)/s_GridSize; + + if(dz<0.) dz=0.; + if(dz>1.) dz=1.; + if(dy<0.) dy=0.; + if(dy>1.) dy=1.; + + dzx=dz; + if(w11<0.000001) dzx=1.; + if(w12<0.000001) dzx=0.; + wdown=w11*(1.-dzx)+w12*dzx; //interpol. along lower line + dzx=dz; + if(w21<0.000001) dzx=1.; + if(w22<0.000001) dzx=0.; + wup=w21*(1.-dzx)+w22*dzx; //interpol. along upper line + + dyx=dy; + if(wdown<0.000001) dyx=1.; + if(wup <0.000001) dyx=0.; + w=wdown*(1.-dyx)+wup*dyx; //interpol along column + if(w>0.000001) weight=w; + + return weight; } // *********************************************************** -void EnergyCalculator::SetFoldArea(G4double zinwheel){ -// *********************************************************** +void LArG4::EC::EnergyCalculator::SetFoldArea(G4double zinwheel, FoldArea & fa) const { + // *********************************************************** if(zinwheel > lwc()->GetStraightStartSection()+lwc()->GetQuarterWaveLength()*0.5 && zinwheel < lwc()->GetWheelThickness()-lwc()->GetStraightStartSection()-lwc()->GetQuarterWaveLength()*0.5){ - PointFoldMapArea=1; - ChCollFoldType=&(ChCollWheelType->Fold1); + fa.PointFoldMapArea=1; + fa.ChCollFoldType=&(ChCollWheelType()->Fold1); } else{ - PointFoldMapArea=0; - ChCollFoldType=&(ChCollWheelType->Fold0); + fa.PointFoldMapArea=0; + fa.ChCollFoldType=&(ChCollWheelType()->Fold0); } } // *********************************************************** -void EnergyCalculator::SetHalfWave(G4double zinwheel){ -// *********************************************************** +void LArG4::EC::EnergyCalculator::SetHalfWave(G4double zinwheel, WheelGeometry & wg) const { + // *********************************************************** -// G4cout<<"***SetHalfWave zin="<<zinwheel<<G4endl; + // G4cout<<"***SetHalfWave zin="<<zinwheel<<G4endl; - G4double z; - z=zinwheel - lwc()->GetStraightStartSection(); - HalfWaveNumber =int((z+lwc()->GetQuarterWaveLength())/lwc()->GetHalfWaveLength()); - ZinHalfWave=z-HalfWaveNumber*lwc()->GetHalfWaveLength(); - SignofZinHalfWave=+1; - if(ZinHalfWave<0.) SignofZinHalfWave=-1; - SignofSlopeofHalfWave=-1; - if(HalfWaveNumber %2 == 0) SignofSlopeofHalfWave=+1; + const G4double z = zinwheel - lwc()->GetStraightStartSection(); + wg.HalfWaveNumber = int((z+lwc()->GetQuarterWaveLength())/lwc()->GetHalfWaveLength()); + wg.ZinHalfWave=z - wg.HalfWaveNumber*lwc()->GetHalfWaveLength(); + wg.SignofZinHalfWave = (wg.ZinHalfWave < 0.) ? -1 : +1; + wg.SignofSlopeofHalfWave = (wg.HalfWaveNumber % 2 == 0) ? +1 : -1; } // *********************************************************** -void EnergyCalculator::TransformWheeltoFieldMap( - G4double PointinWheel[], G4double PointinFieldMap[]){ -// *********************************************************** +void LArG4::EC::EnergyCalculator::TransformWheeltoFieldMap( + const G4double PointinWheel[], G4double PointinFieldMap[], + const WheelGeometry & wg, const FoldArea & fa + ) const { + // *********************************************************** // fieldmap is defined for // -- 'normal' folds : // in the coord syst. of a halfwave of pos.slope @@ -1204,48 +1212,45 @@ void EnergyCalculator::TransformWheeltoFieldMap( // -- 0th and last fold in the range -13mm < z < QuarterWaveLength/2. // SetHalfWave() and GetPhiGap() should be called previously; - PointinFieldMap[0]=PointinWheel[0]* CosPhiGap +PointinWheel[1]*SinPhiGap; - PointinFieldMap[1]=PointinWheel[0]*(-SinPhiGap)+PointinWheel[1]*CosPhiGap; + PointinFieldMap[0]=PointinWheel[0]* wg.CosPhiGap + PointinWheel[1]*wg.SinPhiGap; + PointinFieldMap[1]=PointinWheel[0]*(-wg.SinPhiGap) + PointinWheel[1]*wg.CosPhiGap; - if(PointFoldMapArea == 0){ - if(HalfWaveNumber == 0 ) /*0th fold*/ - PointinFieldMap[2]= ZinHalfWave; + if(fa.PointFoldMapArea == 0){ + if(wg.HalfWaveNumber == 0 ) /*0th fold*/ + PointinFieldMap[2]= wg.ZinHalfWave; else{ /*last fold*/ - PointinFieldMap[1]=-PointinFieldMap[1]; - PointinFieldMap[2]= -ZinHalfWave; + PointinFieldMap[1]=-PointinFieldMap[1]; + PointinFieldMap[2]= -wg.ZinHalfWave; } - } - else{ // normal folds - PointinFieldMap[1]=SignofZinHalfWave*SignofSlopeofHalfWave - *PointinFieldMap[1]; - PointinFieldMap[2]=fabs(ZinHalfWave); + } else{ // normal folds + PointinFieldMap[1]=wg.SignofZinHalfWave*wg.SignofSlopeofHalfWave + *PointinFieldMap[1]; + PointinFieldMap[2]=fabs(wg.ZinHalfWave); } } // ********************************************************************* -void EnergyCalculator::SetYlimitsofPhigapinFieldMap(G4int ilayer){ -// ********************************************************************* +void LArG4::EC::EnergyCalculator::SetYlimitsofPhigapinFieldMap(G4int ilayer, const WheelGeometry & wg, G4double Ylimits[4]) const { + // ********************************************************************* // compute limits of LAr gap along y axis in the system of Halfwaves // using the geometry defined at the time when fieldmap was created; - // + // // SetHalfWave, GetPhiGap, TransformWheeltoFieldMap should be called previously - G4double /*y[4],*/alpha/*,s*/,halfgap;//,eleshift,absshift; - - alpha=ChCollWheelType->FoldinAngleOfLayers[ilayer] / CLHEP::rad * CLHEP::deg; + const G4double alpha = ChCollWheelType()->FoldinAngleOfLayers[ilayer] / CLHEP::rad * CLHEP::deg; //s=sin(alpha/2.); - halfgap=ChCollWheelType->RadiusOfLayers[ilayer]*CLHEP::pi/lwc()->GetNumberOfFans(); //half of y distance + const G4double halfgap = ChCollWheelType()->RadiusOfLayers[ilayer]*CLHEP::pi/lwc()->GetNumberOfFans(); //half of y distance - Ylimits[3]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanAbsThickness)+halfgap; - Ylimits[2]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanEleThickness); - Ylimits[1]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanEleThickness); - Ylimits[0]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanAbsThickness)-halfgap; + Ylimits[3]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanAbsThickness(), wg)+halfgap; + Ylimits[2]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanEleThickness(), wg); + Ylimits[1]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanEleThickness(), wg); + Ylimits[0]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanAbsThickness(), wg)-halfgap; } // ****************************************************************** -void EnergyCalculator::SetYlimitsofPhigapinWheel( - G4double rforpoint, G4double rforalpha){ -// ****************************************************************** +void LArG4::EC::EnergyCalculator::SetYlimitsofPhigapinWheel( + G4double rforpoint, G4double rforalpha, const WheelGeometry & wg, G4double Ylimits[4]) const { + // ****************************************************************** // compute limits of LAr gap in the system of Halfwaves using the // present geometry of the wheels; // valid in 0<z<QuaterWavelength for normal fold; @@ -1253,39 +1258,36 @@ void EnergyCalculator::SetYlimitsofPhigapinWheel( // SetHalfWave GetPhiGap and // TransformWheeltoFieldMap should be called previously - G4double /*y[4],*/alpha/*,s*/,halfgap;//,eleshift,absshift; - - alpha=FoldingAngle(rforalpha); + const G4double alpha = FoldingAngle(rforalpha); //s=sin(alpha*0.5); - halfgap=rforpoint*CLHEP::pi/lwc()->GetNumberOfFans(); //half of y distance between 2 abs. + const G4double halfgap = rforpoint*CLHEP::pi/lwc()->GetNumberOfFans(); //half of y distance between 2 abs. - Ylimits[3]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanAbsThickness)+halfgap; - Ylimits[2]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanEleThickness); - Ylimits[1]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanEleThickness); - Ylimits[0]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanAbsThickness)-halfgap; + Ylimits[3]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanAbsThickness(), wg)+halfgap; + Ylimits[2]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanEleThickness(), wg); + Ylimits[1]=YofSurface(alpha,lwc()->GetFanFoldRadius(),-FanEleThickness(), wg); + Ylimits[0]=YofSurface(alpha,lwc()->GetFanFoldRadius(),+FanAbsThickness(), wg)-halfgap; } // *********************************************************** -void EnergyCalculator::GetPhiGap(G4double SpacePoint[]){ // need to make const -// *********************************************************** -// inp: x,y of SpacePoint defined in the Wheel's system -// outp: gap number(=1,2,..NumberOfFans); -// first gap is at phi=0 +- FanStepOnPhi/2 -// : HalfGapNumber, number of half LAr gaps, -// indexed from 1 to 2*NumberOfFans -// 1st and 2nd halfgaps are in the 1st gap -// SetHalfWave(z) should be called previously - - G4double x,y,r,r2,phiofSpacePoint,y0,phiCross,dphi,phi; - G4int phigap,phihalfgap; - - x=SpacePoint[0]; - y=SpacePoint[1]; - r2=x*x+y*y; - r=sqrt(r2); - phiofSpacePoint=atan2(y,x); //-pi<phi<+pi; - if(phiofSpacePoint<0.) phiofSpacePoint=CLHEP::twopi+phiofSpacePoint; +void LArG4::EC::EnergyCalculator::GetPhiGap(const G4double SpacePoint[], WheelGeometry & wg) const { + // *********************************************************** + // inp: x,y of SpacePoint defined in the Wheel's system + // outp: gap number(=1,2,..NumberOfFans); + // first gap is at phi=0 +- FanStepOnPhi/2 + // : HalfGapNumber, number of half LAr gaps, + // indexed from 1 to 2*NumberOfFans + // 1st and 2nd halfgaps are in the 1st gap + // SetHalfWave(z) should be called previously + + const G4double x=SpacePoint[0]; + const G4double y=SpacePoint[1]; + const G4double r2=x*x+y*y; + G4double r = sqrt(r2); + + // G4double phiofSpacePoint = atan2(y,x); //-pi<phi<+pi; + // if(phiofSpacePoint<0.) phiofSpacePoint=CLHEP::twopi+phiofSpacePoint; + const G4double phiofSpacePoint = _normalizeAngle2Pi( atan2(y,x) ); assert(phiofSpacePoint>0. && phiofSpacePoint<CLHEP::twopi); //compute the crossingpoint of the circle of radius r on the x-y plane @@ -1293,53 +1295,54 @@ void EnergyCalculator::GetPhiGap(G4double SpacePoint[]){ // need to make const // fan 1 positioned at phi=0. One iteration gives precise result. // It was checked by solving exact equations. - y0=YofNeutralFibre(FoldingAngle(r),lwc()->GetFanFoldRadius()); - r =sqrt(r2-y0*y0); // this is an approximation, based on 2 conditons: - // surface tangent in the transvrsal plane is almost - // pointing to the beamline, - // (rold-rnew)/rold << 1. - y0=YofNeutralFibre(FoldingAngle(r),lwc()->GetFanFoldRadius()); - phiCross=atan(y0/r); //-pi<phi<+pi; // asin is used in Dice - it is a bug - phiCross=phiCross-lwc()->GetFanStepOnPhi()/2.; - if(phiCross<0.) phiCross=CLHEP::twopi+phiCross; - //position of the crossing point - //on the neutral fibre of the left absorber of the first gap - dphi=phiofSpacePoint-phiCross; - if(dphi<0.) dphi=CLHEP::twopi+dphi; //distance in phi from the SpacePoint to the - //point on the left absorber's neu.fibre - //at the same radius + G4double y0=YofNeutralFibre(FoldingAngle(r),lwc()->GetFanFoldRadius(), wg); + r = sqrt(r2-y0*y0); // this is an approximation, based on 2 conditons: + // surface tangent in the transvrsal plane is almost + // pointing to the beamline, + // (rold-rnew)/rold << 1. + y0=YofNeutralFibre(FoldingAngle(r),lwc()->GetFanFoldRadius(), wg); + //phiCross=atan(y0/r); //-pi<phi<+pi; // asin is used in Dice - it is a bug + //phiCross=phiCross-lwc()->GetFanStepOnPhi()/2.; + //if(phiCross<0.) phiCross=CLHEP::twopi+phiCross; + const G4double phiCross = _normalizeAngle2Pi( atan2(y0, r) - lwc()->GetFanStepOnPhi()/2. ); + //position of the crossing point + //on the neutral fibre of the left absorber of the first gap + const G4double dphi = _normalizeAngle2Pi( phiofSpacePoint - phiCross ); + //if(dphi<0.) dphi=CLHEP::twopi+dphi; //distance in phi from the SpacePoint to the + //point on the left absorber's neu.fibre + //at the same radius assert (dphi>=0. && dphi<=CLHEP::twopi); - phigap=int(dphi/lwc()->GetFanStepOnPhi())+1; + const G4int phigap=int(dphi/lwc()->GetFanStepOnPhi())+1; assert(phigap>=1 && phigap<=lwc()->GetNumberOfFans()); - phihalfgap=int(2.*dphi/lwc()->GetFanStepOnPhi())+1; + const G4int phihalfgap=int(2.*dphi/lwc()->GetFanStepOnPhi())+1; assert(phihalfgap>=1 && phihalfgap<=2*lwc()->GetNumberOfFans()); - PhiGapNumber=phigap; - PhiHalfGapNumber=phihalfgap; - phi=(phigap-1)*lwc()->GetFanStepOnPhi(); - CosPhiGap=cos(phi); - SinPhiGap=sin(phi); + wg.PhiGapNumber=phigap; + wg.PhiHalfGapNumber=phihalfgap; + const G4double phi=(phigap-1)*lwc()->GetFanStepOnPhi(); + wg.CosPhiGap=cos(phi); + wg.SinPhiGap=sin(phi); } // *********************************************************************************** -G4double EnergyCalculator::YofSurface(G4double alpha,G4double rho,G4double thickness) const { -// *********************************************************************************** -// compute y coord of of the fan surface -// -// coord system of halfwave is used -// y axis: parallel to y axis of ATLAS -// z axis: parallel to z axis of Atlas -// z is limited by: -wavelength/4 < z < +wavelength/4 -// origin of the system is fixed at the node of the halfwave -// inp: -// halfwave parameters: should be set previously by SetHalfWave(); -// ZinHalfWave :z coord of a point where YofSurf is to be computed -// alpha :folding angle[rad] -// rho : curvature radius of the fold -// thickness: >0 --> compute y of the upper surface -// =0 --> compute y of the neutral fibre -// <0 --> compute y of the lower surface +G4double LArG4::EC::EnergyCalculator::YofSurface(G4double alpha,G4double rho,G4double thickness, const WheelGeometry & wg) const { + // *********************************************************************************** + // compute y coord of of the fan surface + // + // coord system of halfwave is used + // y axis: parallel to y axis of ATLAS + // z axis: parallel to z axis of Atlas + // z is limited by: -wavelength/4 < z < +wavelength/4 + // origin of the system is fixed at the node of the halfwave + // inp: + // halfwave parameters: should be set previously by SetHalfWave(); + // m_ZinHalfWave :z coord of a point where YofSurf is to be computed + // alpha :folding angle[rad] + // rho : curvature radius of the fold + // thickness: >0 --> compute y of the upper surface + // =0 --> compute y of the neutral fibre + // <0 --> compute y of the lower surface const G4double alp=alpha/2.; @@ -1348,55 +1351,58 @@ G4double EnergyCalculator::YofSurface(G4double alpha,G4double rho,G4double thick const G4double t=s/c; //tan(alpha/2); const G4double tb=(1.-s)/c; //tan(beta); beta=0.5*(90-alpha/2); const G4double th=thickness/2.; - - if(HalfWaveNumber==0){ //0.th 'halfwave' + + if(wg.HalfWaveNumber==0){ //0.th 'halfwave' const G4double zminoffirstfold = -rho*tb; const G4double zmaxoffirstfold = -rho*tb+(rho-th)*tb*(1.+s); const G4double zminofsecondfold = lwc()->GetQuarterWaveLength()-(rho+th)*c; - - if(ZinHalfWave<=zminoffirstfold) return th; - if(ZinHalfWave<=zmaxoffirstfold) return rho-sqrt( pow((rho-th),2)-pow((ZinHalfWave+rho*tb),2) ); - if(ZinHalfWave<=zminofsecondfold)return ZinHalfWave/t+th/s; - return (lwc()->GetQuarterWaveLength()*c-rho)/s + sqrt( pow((rho+th),2)-pow((ZinHalfWave-lwc()->GetQuarterWaveLength()),2)); - + + if(wg.ZinHalfWave<=zminoffirstfold) return th; + if(wg.ZinHalfWave<=zmaxoffirstfold) return rho-sqrt( pow((rho-th),2)-pow((wg.ZinHalfWave+rho*tb),2) ); + if(wg.ZinHalfWave<=zminofsecondfold) return wg.ZinHalfWave/t+th/s; + return (lwc()->GetQuarterWaveLength()*c-rho)/s + sqrt( pow((rho+th),2)-pow((wg.ZinHalfWave-lwc()->GetQuarterWaveLength()),2)); + } // end of first fold - - else if(HalfWaveNumber==lwc()->GetNumberOfHalfWaves()){ //last 'halfwave' - + + else if(wg.HalfWaveNumber==lwc()->GetNumberOfHalfWaves()){ //last 'halfwave' + const G4double zmaxoflastfold=rho*tb; const G4double zminoflastfold=rho*tb-(rho+th)*tb*(1.+s); const G4double zmaxofpreviousfold=-lwc()->GetQuarterWaveLength()+(rho-th)*c; - - if(ZinHalfWave>=zmaxoflastfold) return th; - if(ZinHalfWave>=zminoflastfold) return -rho+sqrt( pow((rho+th),2)-pow((ZinHalfWave-rho*tb),2) ); - if(ZinHalfWave>=zmaxofpreviousfold) return ZinHalfWave/t+th/s; - return -(lwc()->GetQuarterWaveLength()*c-rho)/s-sqrt( pow((rho-th),2)-pow((ZinHalfWave+lwc()->GetQuarterWaveLength()),2) ); - + + if(wg.ZinHalfWave>=zmaxoflastfold) return th; + if(wg.ZinHalfWave>=zminoflastfold) return -rho+sqrt( pow((rho+th),2)-pow((wg.ZinHalfWave-rho*tb),2) ); + if(wg.ZinHalfWave>=zmaxofpreviousfold) return wg.ZinHalfWave/t+th/s; + return -(lwc()->GetQuarterWaveLength()*c-rho)/s-sqrt( pow((rho-th),2)-pow((wg.ZinHalfWave+lwc()->GetQuarterWaveLength()),2) ); + } // end of last fold - - else if(HalfWaveNumber>0 && HalfWaveNumber<lwc()->GetNumberOfHalfWaves()){ - - const G4double sn=SignofZinHalfWave*SignofSlopeofHalfWave; - const G4double z2= -lwc()->GetQuarterWaveLength()+(rho-SignofSlopeofHalfWave*th)*c; - const G4double z3= lwc()->GetQuarterWaveLength()-(rho+SignofSlopeofHalfWave*th)*c; - - if(ZinHalfWave<=z2 || z3<=ZinHalfWave) + + else if(wg.HalfWaveNumber>0 && wg.HalfWaveNumber<lwc()->GetNumberOfHalfWaves()) { + + const G4double sn=wg.SignofZinHalfWave*wg.SignofSlopeofHalfWave; + const G4double z2= -lwc()->GetQuarterWaveLength()+(rho-wg.SignofSlopeofHalfWave*th)*c; + const G4double z3= lwc()->GetQuarterWaveLength()-(rho+wg.SignofSlopeofHalfWave*th)*c; + + if(wg.ZinHalfWave<=z2 || z3<=wg.ZinHalfWave) { return sn*(lwc()->GetQuarterWaveLength()*c-rho)/s+ - sn*sqrt( pow((rho+sn*th),2)-pow((ZinHalfWave-SignofZinHalfWave*lwc()->GetQuarterWaveLength()),2) ); - - if(z2<=ZinHalfWave && ZinHalfWave<=z3) return SignofSlopeofHalfWave*ZinHalfWave/t+th/s; - + sn*sqrt( pow((rho+sn*th),2)-pow((wg.ZinHalfWave-wg.SignofZinHalfWave*lwc()->GetQuarterWaveLength()),2) ); + } + + if(z2<=wg.ZinHalfWave && wg.ZinHalfWave<=z3) { + return wg.SignofSlopeofHalfWave*wg.ZinHalfWave/t+th/s; + } + // std::cout<<"*** ERROR1 in YofSURF!!!!"<<std::endl; - return 0.; + return 0.; } //std::cout<<"*** ERROR2 in YofSURF!!!!"<<std::endl; - return 0.; + return 0.; } // ********************************************************** -G4double EnergyCalculator::FoldingAngle(G4double radius) const { -// ********************************************************** +G4double LArG4::EC::EnergyCalculator::FoldingAngle(G4double radius) const { + // ********************************************************** // inp: radius in [mm] // outp: angle in [radian] // @@ -1410,29 +1416,21 @@ G4double EnergyCalculator::FoldingAngle(G4double radius) const { // is present as well, however it is smaller by a factor of 2. // In case of 'medium' radia the fitted parameters are ok. - return CLHEP::pi - 2. * lwc()->parameterized_slant_angle(radius); + return CLHEP::pi - 2. * lwc()->parameterized_slant_angle(radius); } // *************************************************************** -G4double EnergyCalculator::HalfLArGapSizeOld(G4double radius) const { -// *************************************************************** +G4double LArG4::EC::EnergyCalculator::HalfLArGapSizeOld(G4double radius) const { + // *************************************************************** const G4double alpha=FoldingAngle(radius); const G4double s=sin(alpha *0.5); - const G4double halfgap=CLHEP::pi*radius/lwc()->GetNumberOfFans()*s-(FanAbsThickness+FanEleThicknessOld)*0.5; + const G4double halfgap=CLHEP::pi*radius/lwc()->GetNumberOfFans()*s-( FanAbsThickness() + FanEleThicknessOld() )*0.5; return halfgap; } // *************************************************************** -G4double EnergyCalculator::HalfLArGapSize(G4double rforpoint,G4double rforalpha) const { -// *************************************************************** +G4double LArG4::EC::EnergyCalculator::HalfLArGapSize(G4double rforpoint,G4double rforalpha) const { + // *************************************************************** const G4double alpha=FoldingAngle(rforalpha); const G4double s=sin(alpha/2.); - const G4double halfgap=CLHEP::pi*rforpoint/lwc()->GetNumberOfFans()*s-(FanAbsThickness+FanEleThickness)/2.; + const G4double halfgap=CLHEP::pi*rforpoint/lwc()->GetNumberOfFans()*s-( FanAbsThickness() + FanEleThickness() )/2.; return halfgap; } - - - - - - - - diff --git a/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.cc index c36fa83981e3..c6ed07a808cf 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.cc @@ -14,13 +14,12 @@ // 17-Aug-2004 WGS: Use a "common geometry" routine for both the // standard calculator and the calibration hits. -#include "LArG4EC/LArEndcapPresamplerCalculator.h" -#include "LArG4EC/PresamplerGeometry.h" +#include "LArEndcapPresamplerCalculator.h" +#include "LArG4EC/IECPresamplerGeometry.h" #include "LArG4Code/LArG4Identifier.h" #include "LArG4Code/LArVG4DetectorParameters.h" #include "LArG4Code/LArG4BirksLaw.h" -#include "LArG4RunControl/LArG4EMECOptions.h" #include "G4ThreeVector.hh" #include "G4StepPoint.hh" @@ -29,90 +28,54 @@ #include "G4NavigationHistory.hh" #include "G4VTouchable.hh" #include "G4TouchableHistory.hh" -#include "LArG4RunControl/LArG4EMECOptions.h" -#include "LArG4RunControl/LArG4GlobalOptions.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" #include "globals.hh" +#include "AthenaKernel/Units.h" // 03-Jan-2002 WGS: For 'copysign'. #include <cmath> #include <climits> -// Standard implementation of a singleton pattern. +namespace Units = Athena::Units; -LArEndcapPresamplerCalculator* LArEndcapPresamplerCalculator::GetCalculator() +LArEndcapPresamplerCalculator::LArEndcapPresamplerCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_geometry("EMECPresamplerGeometry", name) // LArG4::EC::PresamplerGeometry + , m_birksLaw(nullptr) { - static LArEndcapPresamplerCalculator instance; - return &instance; + declareProperty("GeometryCalculator", m_geometry); } - -LArEndcapPresamplerCalculator::LArEndcapPresamplerCalculator() : - birksLaw(NULL) +StatusCode LArEndcapPresamplerCalculator::initialize() { - // Constructor initializes the geometry. - - // Make sure we don't have any undefined values. - //m_identifier = LArG4Identifier(); - - //m_time = 0.; - //m_energy = 0.; - m_isInTime = false; - - StoreGateSvc* detStore; - LArG4EMECOptions *emecOptions; - LArG4GlobalOptions *globalOptions; - StatusCode status; - ISvcLocator* svcLocator = Gaudi::svcLocator(); - status = svcLocator->service("DetectorStore", detStore); - - if(status.isSuccess()){ - status = detStore->retrieve(emecOptions, "LArG4EMECOptions"); - if(status.isFailure()){ - throw std::runtime_error("LArWheelEnergyCalculator: cannot retrieve \ -LArG4EMECOptions"); + + if(m_BirksLaw) + { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); + ATH_MSG_INFO(" LArEndcapPresamplerCalculator: Birks' law ON "); + ATH_MSG_INFO(" LArEndcapPresamplerCalculator: parameter k " << m_birksLaw->k()); } - status = detStore->retrieve(globalOptions, "LArG4GlobalOptions"); - if(status.isFailure()){ - throw std::runtime_error("LArWheelEnergyCalculator: cannot retrieve \ -LArG4GlobalOptions"); + else + { + ATH_MSG_INFO(" LArEndcapPresamplerCalculator: Birks' law OFF"); } - } else { - throw std::runtime_error("LArWheelEnergyCalculator: cannot initialize \ -StoreGate interface"); - } - - - - // Get the values from the detector parameters routine. - m_OOTcut = globalOptions->OutOfTimeCut(); - - if(emecOptions->EMECBirksLaw()){ - const double Birks_LAr_density = 1.396; - const double Birks_k = emecOptions->EMECBirksk(); - birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); - } - - - if(birksLaw) { - std::cout << " LArEndcapPresamplerCalculator: Birks' law ON " << std::endl; - std::cout << " LArEndcapPresamplerCalculator: parameter k " << birksLaw->k() << std::endl; - } - else - std::cout << " LArEndcapPresamplerCalculator: Birks' law OFF" << std::endl; - // Get the geometry routine. - m_geometry = LArG4::EC::PresamplerGeometry::GetInstance(); + ATH_CHECK(m_geometry.retrieve()); + + return StatusCode::SUCCESS; } -LArEndcapPresamplerCalculator::~LArEndcapPresamplerCalculator() { - if (birksLaw) delete birksLaw; +StatusCode LArEndcapPresamplerCalculator::finalize() +{ + if (m_birksLaw) delete m_birksLaw; + return StatusCode::SUCCESS; } -G4bool LArEndcapPresamplerCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) +G4bool LArEndcapPresamplerCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const { // make sure hdata is reset hdata.resize(1); @@ -124,10 +87,10 @@ G4bool LArEndcapPresamplerCalculator::Process(const G4Step* a_step, std::vector< // with the hit and it should be ignored. double energy = a_step->GetTotalEnergyDeposit(); - if (birksLaw) { - G4double wholeStepLengthCm = a_step->GetStepLength() / CLHEP::cm; + if (m_birksLaw) { + G4double wholeStepLengthCm = a_step->GetStepLength() / Units::cm; G4double efield = 10.; // 10 kV/cm simple approximation of electric field - energy = (*birksLaw)(energy, wholeStepLengthCm,efield); + energy = (*m_birksLaw)(energy, wholeStepLengthCm,efield); } @@ -144,11 +107,7 @@ G4bool LArEndcapPresamplerCalculator::Process(const G4Step* a_step, std::vector< G4ThreeVector p = (startPoint + endPoint) * 0.5; // Determine if the hit was in-time. - hdata[0].time = timeOfFlight/CLHEP::ns - p.mag()/CLHEP::c_light/CLHEP::ns; - if (hdata[0].time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; + hdata[0].time = timeOfFlight/Units::ns - p.mag()/CLHEP::c_light/Units::ns; // Use the geometry routine to determine the identifier. hdata[0].id = m_geometry->CalculateIdentifier( a_step ); diff --git a/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.h new file mode 100644 index 000000000000..4d0998341f64 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/src/LArEndcapPresamplerCalculator.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArEndcapPresamplerCalculator.hh +// Prepared 27-Dec-2002 Bill Seligman + +// This is a separate "calculator" class for the endcap presampler. +// For more information about what a "calculator" class does, see the +// documentation: LArG4/doc/LArG4.ps. + +#ifndef LARG4EC_LARENDCAPPRESAMPLERCALCULATOR_H +#define LARG4EC_LARENDCAPPRESAMPLERCALCULATOR_H + +#include "globals.hh" +#include "G4ThreeVector.hh" +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include "LArG4Code/LArVG4DetectorParameters.h" +#include <stdexcept> +// Forward declarations. +class G4Step; +class LArG4BirksLaw; + +namespace LArG4 { + class IECPresamplerGeometry; +} + +class LArEndcapPresamplerCalculator : public LArCalculatorSvcImp { +public: + + LArEndcapPresamplerCalculator(const std::string& name, ISvcLocator *pSvcLocator); + + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + + ///////////////////////////////////////////// + + virtual G4float OOTcut() const override final { return m_OOTcut; } + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); //FIXME should we be checking the absolute value of hitTime here? + } + + virtual G4bool Process(const G4Step*, std::vector<LArHitData>&) const override final; + + +private: + + // Pointer to geometry routine. + ServiceHandle<LArG4::IECPresamplerGeometry> m_geometry; + + LArG4BirksLaw *m_birksLaw; + + LArEndcapPresamplerCalculator (const LArEndcapPresamplerCalculator&); + LArEndcapPresamplerCalculator& operator= (const LArEndcapPresamplerCalculator&); +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.cc index f062557dc371..e3f18dd93cce 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.cc @@ -10,8 +10,8 @@ #undef DEBUG_HITS -#include "LArG4EC/PresamplerCalibrationCalculator.h" -#include "LArG4EC/PresamplerGeometry.h" +#include "PresamplerCalibrationCalculator.h" +#include "LArG4EC/IECPresamplerGeometry.h" #include "LArG4Code/LArG4Identifier.h" @@ -22,62 +22,69 @@ namespace LArG4 { namespace EC { - PresamplerCalibrationCalculator::PresamplerCalibrationCalculator() + PresamplerCalibrationCalculator::PresamplerCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_geometryCalculator("EMECPresamplerGeometry", name) // LArG4::EC::PresamplerGeometry { - // Initialize the geometry calculator. - m_geometryCalculator = PresamplerGeometry::GetInstance(); + declareProperty("GeometryCalculator", m_geometryCalculator); } + StatusCode PresamplerCalibrationCalculator::initialize() + { + // Initialize the geometry calculator. + ATH_CHECK(m_geometryCalculator.retrieve()); + return StatusCode::SUCCESS; + } PresamplerCalibrationCalculator::~PresamplerCalibrationCalculator() { } - G4bool PresamplerCalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) + G4bool PresamplerCalibrationCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const { // Use the calculators to determine the energies and the // identifier associated with this G4Step. Note that the // default is to process both the energy and the ID. - m_energies.clear(); + _energies.clear(); if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { + { #ifdef DEBUG_HITS - std::cout << "LArG4::EC::PresamplerCalibrationCalculator::Process" - << " calling SimulationEnergies" << std::endl; + ATH_MSG_DEBUG("Process(): calling SimulationEnergies"); #endif - m_energyCalculator.Energies( a_step, m_energies ); - } + m_energyCalculator.Energies( a_step, _energies ); + } else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) _energies.push_back( 0. ); if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - m_identifier = m_geometryCalculator->CalculateIdentifier( a_step ); - } + { + // Calculate the identifier. + _identifier = m_geometryCalculator->CalculateIdentifier( a_step ); + } else - m_identifier = LArG4Identifier(); + _identifier = LArG4Identifier(); + - #ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::EC::PresamplerCalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + G4double energy = accumulate(_energies.begin(),_energies.end(),0.); + ATH_MSG_DEBUG("Process(): " + << " ID=" << std::string(_identifier) + << " energy=" << energy + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")"); #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; + if ( _identifier == LArG4Identifier() ) + return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.h similarity index 68% rename from LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.h index db324279b30a..658b0cbe9e86 100644 --- a/LArCalorimeter/LArG4/LArG4EC/LArG4EC/PresamplerCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerCalibrationCalculator.h @@ -16,7 +16,7 @@ #ifndef LArG4_EC_PresamplerCalibrationCalculator_H #define LArG4_EC_PresamplerCalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -33,17 +33,18 @@ class G4Step; namespace LArG4 { - namespace EC { + // Forward declaration + class IECPresamplerGeometry; - // Forward declaration - class PresamplerGeometry; + namespace EC { - class PresamplerCalibrationCalculator : public VCalibrationCalculator { + class PresamplerCalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - PresamplerCalibrationCalculator(); + + PresamplerCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() override final; virtual ~PresamplerCalibrationCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -55,22 +56,15 @@ namespace LArG4 { // yet, but you can never tell). Use the enum (defined in // VCalibrationCalculator.h) to control any special processing. - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + + virtual G4bool Process (const G4Step* step, LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; // Geometry calculator - const PresamplerGeometry* m_geometryCalculator; + ServiceHandle<IECPresamplerGeometry> m_geometryCalculator; // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; diff --git a/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc index ef553fd066e4..e9defcd796f3 100644 --- a/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc +++ b/LArCalorimeter/LArG4/LArG4EC/src/PresamplerGeometry.cc @@ -48,107 +48,106 @@ namespace LArG4 { double zPosInMother; }; - // Standard implementation of a singleton pattern. - - const PresamplerGeometry* PresamplerGeometry::GetInstance() + PresamplerGeometry::PresamplerGeometry(const std::string& name, ISvcLocator * pSvcLocator) + : AthService(name, pSvcLocator) + , m_c(new Clockwork()) { - static PresamplerGeometry instance; // used as const after initialization - return &instance; + } - PresamplerGeometry::PresamplerGeometry(): - c(new Clockwork()) + StatusCode PresamplerGeometry::initialize() { - - StatusCode status; // Access the GeoModelSvc: ISvcLocator *svcLocator = Gaudi::svcLocator(); - IGeoModelSvc *geoModel; - status = svcLocator->service ("GeoModelSvc",geoModel); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); - } - + IGeoModelSvc *geoModel(nullptr); + ATH_CHECK(svcLocator->service ("GeoModelSvc",geoModel)); // Access the geometry database: - IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); - } - + IRDBAccessSvc *pAccessSvc(nullptr); + ATH_CHECK(svcLocator->service("RDBAccessSvc",pAccessSvc)); // Obtain the geometry version information: - const std::string AtlasVersion = geoModel->atlasVersion(); const std::string LArVersion = geoModel->LAr_VersionOverride(); - const std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; const std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; - pAccessSvc->connect(); // Note Presampler Lives In DB under "cryostats".. const IRDBRecordset *presamplerPosition = pAccessSvc->getRecordset("PresamplerPosition",AtlasVersion,"ATLAS"); - if (presamplerPosition->size()==0) { - presamplerPosition = pAccessSvc->getRecordset("PresamplerPosition","PresamplerPosition-00"); - if (presamplerPosition->size()==0) { - throw std::runtime_error("Cannot find the PresamplerPosition Table"); - } - } + if (presamplerPosition->size()==0) + { + presamplerPosition = pAccessSvc->getRecordset("PresamplerPosition","PresamplerPosition-00"); + if (presamplerPosition->size()==0) + { + ATH_MSG_ERROR("Cannot find the PresamplerPosition Table"); + return StatusCode::FAILURE; + } + } pAccessSvc->disconnect(); - - - c->rMinEndcap=(*presamplerPosition)[0]->getDouble("RMIN")*CLHEP::cm; - c->rMaxEndcap=(*presamplerPosition)[0]->getDouble("RMAX")*CLHEP::cm; - c->halfThickness=(*presamplerPosition)[0]->getDouble("TCK")*CLHEP::cm/2;; - c->zEndcapFrontFace=(*presamplerPosition)[0]->getDouble("ZPOS")*CLHEP::cm-c->halfThickness; - c->zEndcapBackFace =(*presamplerPosition)[0]->getDouble("ZPOS")*CLHEP::cm+c->halfThickness; - - c->zPosInMother=30.5*CLHEP::mm; - + + + m_c->rMinEndcap=(*presamplerPosition)[0]->getDouble("RMIN")*CLHEP::cm; + m_c->rMaxEndcap=(*presamplerPosition)[0]->getDouble("RMAX")*CLHEP::cm; + m_c->halfThickness=(*presamplerPosition)[0]->getDouble("TCK")*CLHEP::cm/2;; + m_c->zEndcapFrontFace=(*presamplerPosition)[0]->getDouble("ZPOS")*CLHEP::cm-m_c->halfThickness; + m_c->zEndcapBackFace =(*presamplerPosition)[0]->getDouble("ZPOS")*CLHEP::cm+m_c->halfThickness; + + m_c->zPosInMother=30.5*CLHEP::mm; + return StatusCode::SUCCESS; } - + PresamplerGeometry::~PresamplerGeometry() { - delete c; + delete m_c; } + StatusCode PresamplerGeometry::queryInterface( const InterfaceID & riid, void** ppvInterface ) + { + if ( IECPresamplerGeometry::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<IECPresamplerGeometry*>(this); + } else { + // Interface is not directly available : try out a base class + return AthService::queryInterface(riid, ppvInterface); + } + addRef(); + return StatusCode::SUCCESS; + } - G4double PresamplerGeometry::GetValue(const kValue a_valueType) const + double PresamplerGeometry::GetValue(const kValue a_valueType) const { // Look up a value based on name. - switch (a_valueType) { - case rMinEndcapPresampler: - //return 1231.74 * mm; - return c->rMinEndcap; - break; - case rMaxEndcapPresampler: - //return 1701.98 * mm; - return c->rMaxEndcap; - break; - // At nominal (zShift=0) endcap position absolute z-coordinates: - // of the faces of the EndcapPresampler - case zEndcapPresamplerFrontFace: - //return 3622. * mm; - return c->zEndcapFrontFace; - break; - case zEndcapPresamplerBackFace: - //return 3626. * mm; - return c->zEndcapBackFace; - break; - case EndcapPresamplerHalfThickness: - //return ( GetValue(zEndcapPresamplerBackFace) - GetValue(zEndcapPresamplerFrontFace) ) / 2.; - return c->halfThickness; - break; - case EndcapPresamplerZpositionInMother: - // between cold wall center and presampler center which is at - // 3624 mm nominal (zShift=0) absolute position - return c->zPosInMother; - break; - default: - G4cerr << "LArEndcapPresamplerCalculator::GetValue -- type '" - << a_valueType - << "' not recognized; using zero" << G4endl; - return 0.; - } + switch (a_valueType) { + case rMinEndcapPresampler: + //return 1231.74 * mm; + return m_c->rMinEndcap; + break; + case rMaxEndcapPresampler: + //return 1701.98 * mm; + return m_c->rMaxEndcap; + break; + // At nominal (zShift=0) endcap position absolute z-coordinates: + // of the faces of the EndcapPresampler + case zEndcapPresamplerFrontFace: + //return 3622. * mm; + return m_c->zEndcapFrontFace; + break; + case zEndcapPresamplerBackFace: + //return 3626. * mm; + return m_c->zEndcapBackFace; + break; + case EndcapPresamplerHalfThickness: + //return ( GetValue(zEndcapPresamplerBackFace) - GetValue(zEndcapPresamplerFrontFace) ) / 2.; + return m_c->halfThickness; + break; + case EndcapPresamplerZpositionInMother: + // between cold wall center and presampler center which is at + // 3624 mm nominal (zShift=0) absolute position + return m_c->zPosInMother; + break; + default: + G4cerr << "LArEndcapPresamplerCalculator::GetValue -- type '" + << a_valueType + << "' not recognized; using zero" << G4endl; + return 0.; + } } @@ -169,7 +168,7 @@ namespace LArG4 { } geometry_t; static const geometry_t geometry = - // zSide sampling region etaScale etaOffset maxEta gapsPerBin maxPhi + // zSide sampling region etaScale etaOffset maxEta gapsPerBin maxPhi { 2, 0, 0, 40, 60 , 11, 0, 63 }; @@ -203,16 +202,13 @@ namespace LArG4 { const G4ThreeVector pinLocal =(startPointinLocal+endPointinLocal)*0.5; const G4ThreeVector pForCell(pinLocal.x(), pinLocal.y(), pinLocal.z() - + GetValue(zEndcapPresamplerFrontFace) - + GetValue(EndcapPresamplerHalfThickness)); + + GetValue(zEndcapPresamplerFrontFace) + + GetValue(EndcapPresamplerHalfThickness)); // pForCell.z() > 0 by definition (pinLocal.z() from -2 to +2) const G4double eta=pForCell.pseudoRapidity(); G4double phi=pForCell.phi(); if (phi < 0.) phi += 2.*M_PI; - // Start with a blank identifier. - LArG4Identifier identifier; - // zSide is negative if z<0. G4int zSide = geometry.zSide; if (p.z() < 0.) zSide = -zSide; @@ -229,40 +225,44 @@ namespace LArG4 { G4int etaBin = G4int( eta * geometry.etaScale - geometry.etaOffset ); // 28-Apr-2004 ML: Bug fix if ( etaBin == 12 && eta < 1.801 ) - { - etaBin = 11; - } + { + etaBin = 11; + } G4int phiBin = G4int( phi * phiScale ); if( zSide < 0 ) - { - phiBin = halfMaxPhi1 - phiBin; - if(phiBin < 0 ) phiBin += maxPhi1; - } + { + phiBin = halfMaxPhi1 - phiBin; + if(phiBin < 0 ) phiBin += maxPhi1; + } // Consistency asserts: assert ( etaBin >= 0 ); assert ( phiBin >= 0 ); // assert ( etaBin <= geometry[c].maxEta ); + + // Start with a blank identifier. + LArG4Identifier identifier; + if ( etaBin > geometry.maxEta ) - { - G4cerr << "LArG4::EC::PresamplerGeometry::CalculateIdentifier: invalid hit, etaBin=" - << etaBin - << " > geometry.maxEta=" - << geometry.maxEta - << G4endl; - return identifier; - } + { + G4cerr << "LArG4::EC::PresamplerGeometry::CalculateIdentifier: invalid hit, etaBin=" + << etaBin + << " > geometry.maxEta=" + << geometry.maxEta + << G4endl; + return identifier; + } assert ( phiBin <= geometry.maxPhi ); // Append the values to the empty identifier. identifier << 4 // LArCalorimeter - << 1 // LArEM - << zSide - << sampling - << region - << etaBin - << phiBin; + << 1 // LArEM + << zSide + << sampling + << region + << etaBin + << phiBin; return identifier; } diff --git a/LArCalorimeter/LArG4/LArG4EC/src/components/LArG4EC_entries.cxx b/LArCalorimeter/LArG4/LArG4EC/src/components/LArG4EC_entries.cxx new file mode 100644 index 000000000000..49c617a8fcc5 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4EC/src/components/LArG4EC_entries.cxx @@ -0,0 +1,21 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" + +#include "../CalibrationCalculator.h" +#include "../CryostatCalibrationLArCalculator.h" +#include "../EMECSupportCalibrationCalculator.h" +#include "../LArEndcapPresamplerCalculator.h" +#include "../CryostatCalibrationCalculator.h" +#include "../CryostatCalibrationMixedCalculator.h" +#include "../EnergyCalculator.h" +#include "../PresamplerCalibrationCalculator.h" +#include "LArG4EC/PresamplerGeometry.h" + +DECLARE_SERVICE_FACTORY(LArG4::EC::CalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EMECSupportCalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArEndcapPresamplerCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EndcapCryostat::CalibrationLArCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EndcapCryostat::CalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EndcapCryostat::CalibrationMixedCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EC::EnergyCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EC::PresamplerCalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::EC::PresamplerGeometry) diff --git a/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt index 1c098ab59572..77bec6a06dd3 100644 --- a/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4FCAL/CMakeLists.txt @@ -6,16 +6,15 @@ atlas_subdir( LArG4FCAL ) # Declare the package's dependencies: -atlas_depends_on_subdirs( PUBLIC +atlas_depends_on_subdirs( PRIVATE Calorimeter/CaloG4Sim LArCalorimeter/LArG4/LArG4Code LArCalorimeter/LArGeoModel/LArReadoutGeometry - PRIVATE + Control/AthenaKernel Control/StoreGate Database/AthenaPOOL/RDBAccessSvc DetectorDescription/GeoModel/GeoModelInterfaces GaudiKernel - LArCalorimeter/LArG4/LArG4RunControl Tools/PathResolver ) # External dependencies: @@ -26,11 +25,14 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_library( LArG4FCAL +atlas_add_component( LArG4FCAL src/*.cc + src/components/*.cxx PUBLIC_HEADERS LArG4FCAL PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES LArG4Code LArReadoutGeometry CaloG4SimLib StoreGateLib SGtests PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} GaudiKernel LArG4RunControl PathResolver ) +atlas_install_python_modules( python/*.py ) + diff --git a/LArCalorimeter/LArG4/LArG4FCAL/GNUmakefile b/LArCalorimeter/LArG4/LArG4FCAL/GNUmakefile old mode 100755 new mode 100644 diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1Calculator.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1Calculator.h deleted file mode 100755 index 5bf80dab7608..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1Calculator.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArFCAL1Calculator -// Prepared 20-Feb-2003 Bill Seligman (from Peter Loch) - -// Defines constants specific to a single FCAL module. - -#ifndef LArFCAL1Calculator_H -#define LArFCAL1Calculator_H - -#include "LArG4FCAL/LArFCALCalculatorBase.h" -#include "globals.hh" - -class LArFCAL1Calculator: public LArFCALCalculatorBase -{ -public: - - // This class follows the singleton design pattern; there can be - // only one calculator class for this module. - static LArFCAL1Calculator* GetInstance(); - - // destructor - virtual ~LArFCAL1Calculator() { }; - -protected: - - // The constructor is protected according to the singleton pattern. - LArFCAL1Calculator(); - -private: - - // Private instance required by the singleton pattern. - static LArFCAL1Calculator* m_instance; - -}; -#endif diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1CalibCalculator.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1CalibCalculator.h deleted file mode 100755 index 611be467e7fd..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL1CalibCalculator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#ifndef LArFCAL1CalibCalculator_H -#define LArFCAL1CalibCalculator_H - -//#include "LArG4FCAL/LArFCAL1CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "globals.hh" - - -// Standard implementation of a singleton pattern. -namespace LArG4 { - - namespace FCAL { - - class LArFCAL1CalibCalculator : public LArFCALCalibCalculatorBase { - - public: - - static LArFCAL1CalibCalculator* GetCalculator(); - - virtual ~LArFCAL1CalibCalculator(); - - protected: - - LArFCAL1CalibCalculator(); - private: - - static LArFCAL1CalibCalculator* m_calculator; - - }; - - } - -} -#endif diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2Calculator.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2Calculator.h deleted file mode 100755 index b9d9889299df..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2Calculator.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArFCAL2Calculator -// Prepared 20-Feb-2003 Bill Seligman (from Peter Loch) - -// Defines constants specific to a single FCAL module. - -#ifndef LArFCAL2Calculator_H -#define LArFCAL2Calculator_H - -#include "LArG4FCAL/LArFCALCalculatorBase.h" -#include "globals.hh" - -class LArFCAL2Calculator: public LArFCALCalculatorBase -{ -public: - - // This class follows the singleton design pattern; there can be - // only one calculator class for this module. - static LArFCAL2Calculator* GetInstance(); - - // destructor - virtual ~LArFCAL2Calculator() { }; - -protected: - - // The constructor is protected according to the singleton pattern. - LArFCAL2Calculator(); - -private: - - // Private instance required by the singleton pattern. - static LArFCAL2Calculator* m_instance; - -}; -#endif diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2CalibCalculator.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2CalibCalculator.h deleted file mode 100755 index be059f09174c..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL2CalibCalculator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#ifndef LArFCAL2CalibCalculator_H -#define LArFCAL2CalibCalculator_H - -//#include "LArG4FCAL/LArFCAL2CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "globals.hh" - - -// Standard implementation of a singleton pattern. -namespace LArG4 { - - namespace FCAL { - - class LArFCAL2CalibCalculator : public LArFCALCalibCalculatorBase { - - public: - - static LArFCAL2CalibCalculator* GetCalculator(); - - virtual ~LArFCAL2CalibCalculator(); - - protected: - - LArFCAL2CalibCalculator(); - private: - - static LArFCAL2CalibCalculator* m_calculator; - - }; - - } - -} -#endif diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3Calculator.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3Calculator.h deleted file mode 100755 index 2735283b83c6..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3Calculator.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArFCAL3Calculator -// Prepared 20-Feb-2003 Bill Seligman (from Peter Loch) - -// Defines constants specific to a single FCAL module. - -#ifndef LArFCAL3Calculator_H -#define LArFCAL3Calculator_H - -#include "LArG4FCAL/LArFCALCalculatorBase.h" -#include "globals.hh" - -class LArFCAL3Calculator: public LArFCALCalculatorBase -{ -public: - - // This class follows the singleton design pattern; there can be - // only one calculator class for this module. - static LArFCAL3Calculator* GetInstance(); - - // destructor - virtual ~LArFCAL3Calculator() { }; - -protected: - - // The constructor is protected according to the singleton pattern. - LArFCAL3Calculator(); - -private: - - // Private instance required by the singleton pattern. - static LArFCAL3Calculator* m_instance; - -}; -#endif diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3CalibCalculator.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3CalibCalculator.h deleted file mode 100755 index ea3b88ce66c3..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCAL3CalibCalculator.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#ifndef LArFCAL3CalibCalculator_H -#define LArFCAL3CalibCalculator_H - -//#include "LArG4FCAL/LArFCAL3CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "globals.hh" - - -// Standard implementation of a singleton pattern. -namespace LArG4 { - - namespace FCAL { - - class LArFCAL3CalibCalculator : public LArFCALCalibCalculatorBase { - - public: - - static LArFCAL3CalibCalculator* GetCalculator(); - - virtual ~LArFCAL3CalibCalculator(); - - protected: - - LArFCAL3CalibCalculator(); - private: - - static LArFCAL3CalibCalculator* m_calculator; - - }; - - } - -} -#endif diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalculatorBase.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalculatorBase.h deleted file mode 100755 index 87b6158231f3..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalculatorBase.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArFCALCalculator -// 20-Feb-2003 Bill Seligman (from Peter Loch) - -// A base class for the calculators required for the individual -// modules. - -#ifndef LArFCALCalculatorBase_H -#define LArFCALCalculatorBase_H - -//----------------------------------------------------------------------------- -// -// Forward Calorimeter Construction in GEANT4 -// -//----------------------------------------------------------------------------- -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArReadoutGeometry/FCAL_ChannelMap.h" -#include "globals.hh" -#include <stdexcept> -class LArG4BirksLaw; -class FCALModule; - -class LArFCALCalculatorBase : public LArVCalculator -{ - public: - // constructor - LArFCALCalculatorBase(); - // destructor - virtual ~LArFCALCalculatorBase(); - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step*, std::vector<LArHitData>&); - - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - }; - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - ///////////////////////////////////////////// - - - protected: - - // Store the endcap shift and out-of-time cut from the description: - G4float m_OOTcut; - - // The results of the Process calculation: - //LArG4Identifier m_identifier; - //G4double m_time; - //G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4bool m_isInTime; - - FCAL_ChannelMap *m_ChannelMap; - const FCALModule *m_posModule; // for hv access here... - const FCALModule *m_negModule; // for hv access here... - // sampling - G4int m_FCalSampling; - LArG4BirksLaw *birksLaw; - - LArFCALCalculatorBase (const LArFCALCalculatorBase&); - LArFCALCalculatorBase operator= (const LArFCALCalculatorBase&); -}; - -#endif // LArFCALCalculatorBase_H - - diff --git a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalibCalculatorBase.h b/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalibCalculatorBase.h deleted file mode 100755 index 1c9a301c13c9..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/LArG4FCAL/LArFCALCalibCalculatorBase.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::FCAL::LArFCALCalibCalculator -// Prepared Oct./2004 Mohsen Khakzad - -// This class calculates the values needed for calibration hits in the -// simulation. - -// A "calculator" is used in much the same way as a hand-held -// calculator might be. The user supplies a value and hits 'Enter' -// Forward declaractions: -// (i.e., invokes the Process() method). Then they read off whatever -// values are of interest. - -#ifndef LArFCALCalibCalculatorBase_H -#define LArFCALCalibCalculatorBase_H - -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4Code/LArG4Identifier.h" - -#include "LArG4FCAL/LArFCALCalculatorBase.h" - -#include "CaloG4Sim/SimulationEnergies.h" - -#include "LArG4Code/LArVCalculator.h" -#include "globals.hh" -#include <vector> -// Forward declaration for namespace CaloG4. -class G4Step; - -namespace LArG4 { - - namespace FCAL { - - class LArFCALCalibCalculatorBase : public VCalibrationCalculator { - public: - LArFCALCalibCalculatorBase(); - virtual ~LArFCALCalibCalculatorBase(); - - - // The Process method returns a boolean value. If it's true, the - // hit can be used by Geant4; if it's false, there's something wrong - // with the energy deposit and it should be ignored. - - // For calibration work, most of the time we want the calculator - // to determine both the energy and the identifier. However, - // sometimes we want it calculate only the identifier (for - // escaped energy), or only the energy (no known application - // yet, but you can never tell). Use the enum (defined in - // VCalibrationCalculator.h) to control any special processing. - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - - virtual G4float OOTcut() const { return m_OOTcut; } - - virtual G4double time() const { return m_time; } - virtual const std::vector<G4double>& energies() const { return m_energies; } - virtual G4bool isInTime() const { return m_isInTime; } - virtual G4bool isOutOfTime() const { return ( ! m_isInTime ); } - ///////////////////////////////////////////// - - virtual G4double GetdeltaX(){return m_deltaX;} - virtual G4double GetdeltaY(){return m_deltaY;} - - protected: - - G4double m_deltaX; - G4double m_deltaY; - - G4int m_FCalSampling; - - private: - - // The values calculated by Process() - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - - - // Energy calculator - CaloG4::SimulationEnergies m_energyCalculator; - - ////$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$CalculatorBase - // Store the endcap shift and out-of-time cut from the description: - G4float m_OOTcut; - G4float m_zShift; - - // The results of the Process calculation: - G4double m_time; - G4bool m_isInTime; - - FCAL_ChannelMap *m_ChannelMap; - - }; - } // namespace FCAL - -} // namespace LArG4 - -#endif // LArG4_HEC_CalibrationCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4FCAL/cmt/requirements b/LArCalorimeter/LArG4/LArG4FCAL/cmt/requirements index f2d603142d36..96d72cd59584 100755 --- a/LArCalorimeter/LArG4/LArG4FCAL/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4FCAL/cmt/requirements @@ -9,25 +9,27 @@ author Mikhail Leltchouk <lelchuk@nevis.columbia.edu> # forward calorimeter (FCAL). use AtlasPolicy AtlasPolicy-* -use LArG4Code LArG4Code-* LArCalorimeter/LArG4 # The following lines assure us that the FCAL data files are loaded # into the InstallArea - and give us the tools to read them. -use LArReadoutGeometry LArReadoutGeometry-* LArCalorimeter/LArGeoModel -use CaloG4Sim CaloG4Sim-* Calorimeter # Build the library (and export the headers) -library LArG4FCAL *.cc +library LArG4FCAL *.cc -s=components *.cxx +apply_pattern declare_python_modules files="*.py" -apply_pattern installed_library +apply_pattern component_library private +use AthenaKernel AthenaKernel-* Control use StoreGate StoreGate-* Control use Geant4 Geant4-* External use PathResolver PathResolver-* Tools -use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 +#use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 use GaudiInterface GaudiInterface-* External use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL +use LArReadoutGeometry LArReadoutGeometry-* LArCalorimeter/LArGeoModel +use CaloG4Sim CaloG4Sim-* Calorimeter +use LArG4Code LArG4Code-* LArCalorimeter/LArG4 diff --git a/LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfig.py b/LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfig.py new file mode 100644 index 000000000000..5fbb6d40e84b --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfig.py @@ -0,0 +1,36 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr +from AthenaCommon.SystemOfUnits import mm,deg +import math + +def getFCAL1Calculator(name="FCAL1Calculator", **kwargs): + kwargs.setdefault("FCALSampling",1); + return CfgMgr.LArFCALCalculatorBase(name, **kwargs) + +def getFCAL2Calculator(name="FCAL2Calculator", **kwargs): + kwargs.setdefault("FCALSampling",2); + return CfgMgr.LArFCALCalculatorBase(name, **kwargs) + +def getFCAL3Calculator(name="FCAL3Calculator", **kwargs): + kwargs.setdefault("FCALSampling",3); + return CfgMgr.LArFCALCalculatorBase(name, **kwargs) + +def getFCAL1CalibCalculator(name="FCAL1CalibCalculator", **kwargs): + kwargs.setdefault("FCALdeltaX",7.5*mm); + kwargs.setdefault("FCALdeltaY",7.5*mm*math.sin(60*deg)); + kwargs.setdefault("FCALSampling",1); + return CfgMgr.LArG4__FCAL__LArFCALCalibCalculatorBase(name, **kwargs) + +def getFCAL2CalibCalculator(name="FCAL2CalibCalculator", **kwargs): + kwargs.setdefault("FCALdeltaX",8.179*mm); + kwargs.setdefault("FCALdeltaY",8.179*mm*math.sin(60*deg)); + kwargs.setdefault("FCALSampling",2); + return CfgMgr.LArG4__FCAL__LArFCALCalibCalculatorBase(name, **kwargs) + +def getFCAL3CalibCalculator(name="FCAL3CalibCalculator", **kwargs): + kwargs.setdefault("FCALdeltaX",9.0*mm); + kwargs.setdefault("FCALdeltaY",9.0*mm*math.sin(60*deg)); + kwargs.setdefault("FCALSampling",3); + return CfgMgr.LArG4__FCAL__LArFCALCalibCalculatorBase(name, **kwargs) + diff --git a/LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfigDb.py b/LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfigDb.py new file mode 100644 index 000000000000..02c9f4a00b79 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4FCAL/python/LArG4FCALConfigDb.py @@ -0,0 +1,10 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addService + +addService("LArG4FCAL.LArG4FCALConfig.getFCAL1Calculator","FCAL1Calculator") +addService("LArG4FCAL.LArG4FCALConfig.getFCAL2Calculator","FCAL2Calculator") +addService("LArG4FCAL.LArG4FCALConfig.getFCAL3Calculator","FCAL3Calculator") +addService("LArG4FCAL.LArG4FCALConfig.getFCAL1CalibCalculator","FCAL1CalibCalculator") +addService("LArG4FCAL.LArG4FCALConfig.getFCAL2CalibCalculator","FCAL2CalibCalculator") +addService("LArG4FCAL.LArG4FCALConfig.getFCAL3CalibCalculator","FCAL3CalibCalculator") diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1Calculator.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1Calculator.cc deleted file mode 100755 index ab3e02007fe7..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1Calculator.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "LArG4FCAL/LArFCAL1Calculator.h" -#include "LArG4FCAL/LArFCALCalculatorBase.h" - -#include "globals.hh" - - -// Standard implementation of a singleton pattern. - -LArFCAL1Calculator* LArFCAL1Calculator::m_instance = 0; - -LArFCAL1Calculator* LArFCAL1Calculator::GetInstance() -{ - if (m_instance == 0) - { - m_instance = new LArFCAL1Calculator(); - } - return m_instance; -} - -// constructor -LArFCAL1Calculator::LArFCAL1Calculator() -{ - m_FCalSampling = 1; -} diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1CalibCalculator.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1CalibCalculator.cc deleted file mode 100755 index 2197a8270f66..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL1CalibCalculator.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "LArG4FCAL/LArFCAL1CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" - -#include <algorithm> - -namespace LArG4 { - - namespace FCAL { - - LArFCAL1CalibCalculator* LArFCAL1CalibCalculator::m_calculator = 0; - - LArFCAL1CalibCalculator* LArFCAL1CalibCalculator::GetCalculator() - - { - if (m_calculator == 0 ) - { - m_calculator = new LArFCAL1CalibCalculator(); - } - return m_calculator; - } - - LArFCAL1CalibCalculator::LArFCAL1CalibCalculator() - { - - m_deltaX = 7.5*CLHEP::mm; - m_deltaY = 7.5*CLHEP::mm*sin(60*CLHEP::deg); - - m_FCalSampling = 1; - } - LArFCAL1CalibCalculator::~LArFCAL1CalibCalculator(){} - } - -} diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2Calculator.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2Calculator.cc deleted file mode 100755 index ff90ad0105c5..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2Calculator.cc +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "LArG4FCAL/LArFCAL2Calculator.h" -#include "LArG4FCAL/LArFCALCalculatorBase.h" - -#include "globals.hh" - - -// Standard implementation of a singleton pattern. - -LArFCAL2Calculator* LArFCAL2Calculator::m_instance = 0; - -LArFCAL2Calculator* LArFCAL2Calculator::GetInstance() -{ - if (m_instance == 0) - { - m_instance = new LArFCAL2Calculator(); - } - return m_instance; -} - -// constructor -LArFCAL2Calculator::LArFCAL2Calculator() -{ - m_FCalSampling = 2; -} diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2CalibCalculator.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2CalibCalculator.cc deleted file mode 100755 index 51be8ed2b1e6..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL2CalibCalculator.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "LArG4FCAL/LArFCAL2CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" - -#include <algorithm> - -namespace LArG4 { - - namespace FCAL { - - LArFCAL2CalibCalculator* LArFCAL2CalibCalculator::m_calculator = 0; - - LArFCAL2CalibCalculator* LArFCAL2CalibCalculator::GetCalculator() - - { - if (m_calculator == 0 ) - { - m_calculator = new LArFCAL2CalibCalculator(); - } - return m_calculator; - } - - LArFCAL2CalibCalculator::LArFCAL2CalibCalculator() - { - - m_deltaX = 8.179*CLHEP::mm; - m_deltaY = 8.179*CLHEP::mm*sin(60*CLHEP::deg); - - m_FCalSampling = 2; - } - LArFCAL2CalibCalculator::~LArFCAL2CalibCalculator(){} - } - -} diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3Calculator.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3Calculator.cc deleted file mode 100755 index 99e43240b5b8..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3Calculator.cc +++ /dev/null @@ -1,30 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "LArG4FCAL/LArFCAL3Calculator.h" -#include "LArG4FCAL/LArFCALCalculatorBase.h" - -#include "globals.hh" - - -// Standard implementation of a singleton pattern. - -LArFCAL3Calculator* LArFCAL3Calculator::m_instance = 0; - -LArFCAL3Calculator* LArFCAL3Calculator::GetInstance() -{ - if (m_instance == 0) - { - m_instance = new LArFCAL3Calculator(); - } - return m_instance; -} - - -// constructor -LArFCAL3Calculator::LArFCAL3Calculator() -{ - m_FCalSampling = 3; -} diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3CalibCalculator.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3CalibCalculator.cc deleted file mode 100755 index 888ebb6ffbbb..000000000000 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCAL3CalibCalculator.cc +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - - -#include "LArG4FCAL/LArFCAL3CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" - -#include <algorithm> - -namespace LArG4 { - - namespace FCAL { - - LArFCAL3CalibCalculator* LArFCAL3CalibCalculator::m_calculator = 0; - - LArFCAL3CalibCalculator* LArFCAL3CalibCalculator::GetCalculator() - - { - if (m_calculator == 0 ) - { - m_calculator = new LArFCAL3CalibCalculator(); - } - return m_calculator; - } - - LArFCAL3CalibCalculator::LArFCAL3CalibCalculator() - { - - m_deltaX = 9.0*CLHEP::mm; - m_deltaY = 9.0*CLHEP::mm*sin(60*CLHEP::deg); - - m_FCalSampling = 3; - } - LArFCAL3CalibCalculator::~LArFCAL3CalibCalculator(){} - } - -} diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc old mode 100755 new mode 100644 index c5122657eb00..b593f6262869 --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.cc @@ -8,12 +8,12 @@ // //---------------------------------------------------------------------------- -#include "LArG4FCAL/LArFCALCalculatorBase.h" +#include "LArFCALCalculatorBase.h" #include "LArG4Code/LArG4Identifier.h" #include "LArG4Code/LArG4BirksLaw.h" #include "StoreGate/StoreGate.h" -#include "LArG4RunControl/LArG4FCALOptions.h" +//#include "LArG4RunControl/LArG4FCALOptions.h" // Geant4 includes #include "G4LogicalVolume.hh" #include "G4VPhysicalVolume.hh" @@ -27,60 +27,63 @@ #include "LArReadoutGeometry/FCALModule.h" #include "LArReadoutGeometry/FCALTile.h" #include "LArReadoutGeometry/FCALTube.h" +#include "AthenaKernel/Units.h" +namespace Units = Athena::Units; // // constructor // -LArFCALCalculatorBase::LArFCALCalculatorBase() - : m_OOTcut(2.5*CLHEP::ns),m_posModule(NULL),m_negModule(NULL), m_FCalSampling(0), birksLaw(NULL) +LArFCALCalculatorBase::LArFCALCalculatorBase(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_doHV(false) + , m_ChannelMap(nullptr) + , m_posModule(nullptr) + , m_negModule(nullptr) + , m_FCalSampling(0) + , m_birksLaw(nullptr) { - //m_identifier = LArG4Identifier(); - - //m_time = 0.; - //m_energy = 0.; - m_isInTime = false; + declareProperty("FCALHVEnable",m_doHV); + declareProperty("FCALSampling",m_FCalSampling); + //m_FCalSampling.verifier().setUpper(3); //Would need to make m_FCalSampling an IntegerProperty for this to work. Overkill? +} +StatusCode LArFCALCalculatorBase::initialize() +{ + m_OOTcut = (2.5*CLHEP::ns); //FIXME should be done via configurable property - LArG4FCALOptions *fcalOptions=NULL; StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); if (detStore->retrieve(m_ChannelMap)==StatusCode::FAILURE) { } - if (detStore->retrieve(fcalOptions, "LArG4FCALOptions")==StatusCode::FAILURE) { + if (m_BirksLaw) { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); } + if(m_doHV) { - if (fcalOptions) { - if (fcalOptions->FCALBirksLaw()) { - const double Birks_LAr_density = 1.396; - const double Birks_k = fcalOptions->FCALBirksk(); - birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); + const LArDetectorManager *manager=nullptr; + if (detStore->retrieve(manager)!=StatusCode::SUCCESS) { + throw std::runtime_error("Cannot locate FCAL Manager"); } - - if (fcalOptions->FCALHVEnable()) { - const LArDetectorManager *manager=NULL; - if (detStore->retrieve(manager)!=StatusCode::SUCCESS) { - throw std::runtime_error("Cannot locate FCAL Manager"); - } - else { - const FCALDetectorManager* fcalManager=manager->getFcalManager(); - m_posModule = fcalManager->getFCAL(FCALModule::Module(m_FCalSampling),FCALModule::POS); - m_negModule = fcalManager->getFCAL(FCALModule::Module(m_FCalSampling),FCALModule::NEG); - } + else { + const FCALDetectorManager* fcalManager=manager->getFcalManager(); + m_posModule = fcalManager->getFCAL(FCALModule::Module(m_FCalSampling),FCALModule::POS); + m_negModule = fcalManager->getFCAL(FCALModule::Module(m_FCalSampling),FCALModule::NEG); } } + return StatusCode::SUCCESS; } // // destructor // -LArFCALCalculatorBase::~LArFCALCalculatorBase() -{ - delete birksLaw; +StatusCode LArFCALCalculatorBase::finalize() +{ + if(m_birksLaw) delete m_birksLaw; + return StatusCode::SUCCESS; } - - -G4bool LArFCALCalculatorBase::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) +G4bool LArFCALCalculatorBase::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const { // Given a G4Step, determine the cell identifier. @@ -89,12 +92,12 @@ G4bool LArFCALCalculatorBase::Process(const G4Step* a_step, std::vector<LArHitDa // with the hit and it should be ignored. // make sure hdata is reset - hdata.resize(1); + hdata.resize(1); // First, get the energy. hdata[0].energy = a_step->GetTotalEnergyDeposit(); - G4double stepLengthCm = a_step->GetStepLength() / CLHEP::cm; - if(birksLaw) hdata[0].energy = (*birksLaw)(hdata[0].energy, stepLengthCm, 10); + G4double stepLengthCm = a_step->GetStepLength() / Units::cm; + if(m_birksLaw) hdata[0].energy = (*m_birksLaw)(hdata[0].energy, stepLengthCm, 10); // Find out how long it took the energy to get here. G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); @@ -107,17 +110,13 @@ G4bool LArFCALCalculatorBase::Process(const G4Step* a_step, std::vector<LArHitDa // Determine if the hit was in-time. - hdata[0].time = timeOfFlight/CLHEP::ns - p.mag()/CLHEP::c_light/CLHEP::ns; - if (hdata[0].time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; + hdata[0].time = (timeOfFlight - p.mag()/CLHEP::c_light)/Units::ns; // zSide is negative if z<0. G4int zSide = 2; if (p.z() < 0.) zSide = -zSide; - + // Get the physical volume associated with this G4Step. G4VPhysicalVolume* thisPV = a_step->GetPreStepPoint()->GetPhysicalVolume(); //a_step->GetTrack()->GetVolume(); G4int sampling = m_FCalSampling; @@ -136,35 +135,34 @@ G4bool LArFCALCalculatorBase::Process(const G4Step* a_step, std::vector<LArHitDa const FCALTile *tile = fcalMod->getTile(phiIndex, etaIndex); for (unsigned int i=0;i<tile->getNumTubes();i++) { - FCALTubeConstLink tube=tile->getTube(i); - if (tube->getXLocal() == (*t).second.x() && tube->getYLocal()==(*t).second.y()) { - FCALHVLineConstLink line =tube->getHVLine(); - if (line) { - double voltage = line->voltage(); - //double current = line->current(); - bool hvOn = line->hvOn(); - if (!hvOn) hdata[0].energy=0.0; - hdata[0].energy *= pow((voltage)/2000.0,0.6); - tubeFound=true; - break; - } - } + FCALTubeConstLink tube=tile->getTube(i); + if (tube->getXLocal() == (*t).second.x() && tube->getYLocal()==(*t).second.y()) { + FCALHVLineConstLink line =tube->getHVLine(); + if (line) { + double voltage = line->voltage(); + //double current = line->current(); + bool hvOn = line->hvOn(); + if (!hvOn) hdata[0].energy=0.0; + hdata[0].energy *= pow((voltage)/2000.0,0.6); + tubeFound=true; + break; + } + } } - if (!tubeFound) throw std::runtime_error("FCAL Tube not found (for HV calculation)"); + if (!tubeFound) throw std::runtime_error("FCAL Tube not found (for HV calculation)"); } - + } hdata[0].id.clear(); // Append the values to the empty identifier. hdata[0].id << 4 // LArCalorimeter - << 3 // LArFCAL - << zSide // EndCap - << sampling // FCal Module # - << etaIndex - << phiIndex; + << 3 // LArFCAL + << zSide // EndCap + << sampling // FCal Module # + << etaIndex + << phiIndex; return true; } - diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h new file mode 100644 index 000000000000..f57ee3a9401d --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalculatorBase.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArFCALCalculator +// 20-Feb-2003 Bill Seligman (from Peter Loch) + +// A base class for the calculators required for the individual +// modules. + +#ifndef LArFCALCalculatorBase_H +#define LArFCALCalculatorBase_H + +//----------------------------------------------------------------------------- +// +// Forward Calorimeter Construction in GEANT4 +// +//----------------------------------------------------------------------------- +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include "LArReadoutGeometry/FCAL_ChannelMap.h" +#include "globals.hh" +#include <stdexcept> +class LArG4BirksLaw; +class FCALModule; + +class LArFCALCalculatorBase : public LArCalculatorSvcImp +{ + public: + // constructor + LArFCALCalculatorBase(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize(); + StatusCode finalize(); + + ///////////////////////////////////////////// + + virtual G4float OOTcut() const override final { return m_OOTcut; } + + virtual G4bool Process(const G4Step*, std::vector<LArHitData>&) const override final; + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); //FIXME should we be checking the absolute value of hitTime here? + } + + ///////////////////////////////////////////// + + + protected: + + // Store the endcap shift and out-of-time cut from the description: + G4float m_OOTcut; + + bool m_doHV; + + FCAL_ChannelMap *m_ChannelMap; + const FCALModule *m_posModule; // for hv access here... + const FCALModule *m_negModule; // for hv access here... + // sampling + G4int m_FCalSampling; + LArG4BirksLaw *m_birksLaw; + + LArFCALCalculatorBase (const LArFCALCalculatorBase&); + LArFCALCalculatorBase operator= (const LArFCALCalculatorBase&); +}; + +#endif // LArFCALCalculatorBase_H diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc old mode 100755 new mode 100644 index 59f9272ced70..e2d70928cbac --- a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.cc @@ -2,7 +2,6 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ - //----------------------------------------------------------------------------- // // Base class describing common behaviour in FCal G4 calculator. @@ -10,12 +9,13 @@ //---------------------------------------------------------------------------- // ATLAS LAr includes -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" -#include "LArG4FCAL/LArFCALCalculatorBase.h" +#include "LArFCALCalibCalculatorBase.h" +#include "LArFCALCalculatorBase.h" #include "LArG4Code/LArG4Identifier.h" //#include "LArG4Code/SimulationEnergies.h" #include "CaloG4Sim/SimulationEnergies.h" +#include "LArReadoutGeometry/FCAL_ChannelMap.h" // For reading the data files in Athena. #ifndef LARG4_STAND_ALONE @@ -63,10 +63,21 @@ namespace LArG4 { namespace FCAL { - LArFCALCalibCalculatorBase::LArFCALCalibCalculatorBase() - : m_deltaX(0), m_deltaY(0), m_FCalSampling(0), m_identifier(LArG4Identifier()), m_OOTcut(0), m_zShift(0.), - m_time(0), m_isInTime(0) - { + LArFCALCalibCalculatorBase::LArFCALCalibCalculatorBase(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_deltaX(0.) + , m_deltaY(0.) + , m_FCalSampling(0) + , m_zShift(0.) + , m_ChannelMap(nullptr) + { + declareProperty("FCALdeltaX",m_deltaX); + declareProperty("FCALdeltaY",m_deltaY); + declareProperty("FCALSampling",m_FCalSampling); + //m_FCalSampling.verifier().setUpper(3); //Would need to make m_FCalSampling an IntegerProperty for this to work. Overkill? + } + + StatusCode LArFCALCalibCalculatorBase::initialize() { // Initialize the energy calculators. // m_electrode.GetElectrodes(); //// m_ElectrodeFile = "FCal1-electrodes.sorted.dat"; @@ -74,24 +85,24 @@ namespace LArG4 { ////m_deltaY=7.5*sin(60.0); StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); - if (detStore->retrieve(m_ChannelMap)==StatusCode::FAILURE) - throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot retrieve FCAL Channel Map!"); + if (detStore->retrieve(m_ChannelMap)==StatusCode::FAILURE) + throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot retrieve FCAL Channel Map!"); // get GeoModelSvc & RDBAccessSvc ISvcLocator *svcLocator = Gaudi::svcLocator(); IGeoModelSvc *geoModel(0); StatusCode status = svcLocator->service ("GeoModelSvc",geoModel); - if (status != StatusCode::SUCCESS) - throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate GeoModelSvc!"); - + if (status != StatusCode::SUCCESS) + throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate GeoModelSvc!"); + // Access the geometry database: IRDBAccessSvc *pAccessSvc(0); status=svcLocator->service("RDBAccessSvc",pAccessSvc); - if (status != StatusCode::SUCCESS) - throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate RDBAccessSvc!"); + if (status != StatusCode::SUCCESS) + throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot locate RDBAccessSvc!"); // Obtain the geometry version information: - + std::string AtlasVersion = geoModel->atlasVersion(); std::string LArVersion = geoModel->LAr_VersionOverride(); @@ -100,37 +111,29 @@ namespace LArG4 { pAccessSvc->connect(); IRDBRecordset_ptr emecGeoPtr = pAccessSvc->getRecordsetPtr("EmecGeometry",detectorKey,detectorNode); - if (emecGeoPtr->size()==0) - throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot find the EmecGeometry Table"); - + if (emecGeoPtr->size()==0) + throw std::runtime_error ("LArFCALCalibCalculatorBase ERROR: Cannot find the EmecGeometry Table"); + m_zShift = (*emecGeoPtr)[0]->getDouble("ZSHIFT")*CLHEP::cm; pAccessSvc->disconnect(); + return StatusCode::SUCCESS; } -// -// destructor -// - LArFCALCalibCalculatorBase::~LArFCALCalibCalculatorBase() - { - } - - - G4bool LArFCALCalibCalculatorBase::Process(const G4Step* a_step, - const eCalculatorProcessing a_process) + G4bool LArFCALCalibCalculatorBase::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const { // First, get the energy. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) + if ( process == kEnergyAndID || process == kOnlyEnergy ) { - m_energyCalculator.Energies( a_step, m_energies ); + m_energyCalculator.Energies( step, energies ); } else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); // find the space point for this deposit - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); + G4StepPoint* pre_step_point = step->GetPreStepPoint(); + G4StepPoint* post_step_point = step->GetPostStepPoint(); G4ThreeVector startPoint = pre_step_point->GetPosition(); G4ThreeVector endPoint = post_step_point->GetPosition(); G4ThreeVector p = (startPoint + endPoint) * 0.5; @@ -142,22 +145,22 @@ namespace LArG4 { // instead ... // S.M. // get LOCAL (u,v) coordinates! - // S.M. G4Navigator* theNavigator = - // S.M. G4TransportationManager::GetTransportationManager()-> - // S.M. GetNavigatorForTracking(); + // S.M. G4Navigator* theNavigator = + // S.M. G4TransportationManager::GetTransportationManager()-> + // S.M. GetNavigatorForTracking(); // S.M. G4ThreeVector theLocalPoint = theNavigator-> - // S.M. GetGlobalToLocalTransform(). - // S.M. TransformPoint(p); - + // S.M. GetGlobalToLocalTransform(). + // S.M. TransformPoint(p); + G4ThreeVector theLocalPoint(p); // we've shifted the endcap, we have to project the geometry to a // different point). G4double pointZ = p.z(); - + G4double pointZshift = pointZ - copysign(m_zShift,pointZ); - + G4ThreeVector pointShift(p.x(), p.y(), pointZshift); @@ -166,137 +169,131 @@ namespace LArG4 { float x = theLocalPoint.x(),y=theLocalPoint.y(); int sampling = m_FCalSampling; bool ok = m_ChannelMap->getTileID(sampling, - x, - y, - etaIndex, - phiIndex); + x, + y, + etaIndex, + phiIndex); + - // zSide is negative if z<0. G4int zSide = 2; if (pointZshift < 0.) zSide = -zSide; - - m_identifier.clear(); - if (ok) { - // we have a active or non-active hit inside the FCal - G4int sampling = m_FCalSampling; - - - // Append the values to the empty identifier. - m_identifier << 4 // LArCalorimeter - << 3 // LArFCAL - << zSide // EndCap - << sampling // FCal Module # - << etaIndex - << phiIndex; - -// std::cout << "LArG4FCAL/LArFCALCalibCalculatorBase: 4/3/" -// <<zSide<<"/" -// <<sampling<<"/" -// <<etaIndex<<"/" -// <<phiIndex<<": " -// << m_energies[0] << ", " -// << m_energies[1] << ", " -// << m_energies[2] << ", " -// << m_energies[3] -// << ", i=" << i -// << ", j=" << j -// << ", l.x=" << theLocalPoint.x() -// << ", l.y=" << theLocalPoint.y() -// << ", p.x=" << p.x() -// << ", p.y=" << p.y() -// << ", deltaX=" << m_deltaX -// << ", deltaY=" << m_deltaY -// << std::endl; + + identifier.clear(); + if (ok) { + // we have a active or non-active hit inside the FCal + G4int sampling = m_FCalSampling; + + + // Append the values to the empty identifier. + identifier << 4 // LArCalorimeter + << 3 // LArFCAL + << zSide // EndCap + << sampling // FCal Module # + << etaIndex + << phiIndex; + + // std::cout << "LArG4FCAL/LArFCALCalibCalculatorBase: 4/3/" + // <<zSide<<"/" + // <<sampling<<"/" + // <<etaIndex<<"/" + // <<phiIndex<<": " + // << energies[0] << ", " + // << energies[1] << ", " + // << energies[2] << ", " + // << energies[3] + // << ", i=" << i + // << ", j=" << j + // << ", l.x=" << theLocalPoint.x() + // << ", l.y=" << theLocalPoint.y() + // << ", p.x=" << p.x() + // << ", p.y=" << p.y() + // << ", deltaX=" << m_deltaX + // << ", deltaY=" << m_deltaY + // << std::endl; } else { - // S.M.: we have a hit which fails the electrode identifier - // calculation. It's likely just a the border of the FCAL - // (outer or inner) and not really dead material ... Lacking a - // better method of assigning it to a correct cell I make a - // dead material identifier for it ... - G4int sampling(3); // FCAL leakage - G4int type(1); // FCAL leakage - G4double eta = fabs( pointShift.pseudoRapidity() ); - G4double phi = pointShift.phi(); + // S.M.: we have a hit which fails the electrode identifier + // calculation. It's likely just a the border of the FCAL + // (outer or inner) and not really dead material ... Lacking a + // better method of assigning it to a correct cell I make a + // dead material identifier for it ... + G4int sampling(3); // FCAL leakage + G4int type(1); // FCAL leakage + G4double eta = fabs( pointShift.pseudoRapidity() ); + G4double phi = pointShift.phi(); G4double rho = pointShift.perp(); // since the outer edge of the FCal has a irregular shape we // take the innermost position of the outermost tubes as min // radius - this is about 3 cm from the outermost tube // position ... const G4double fcal_edge_approx = 415.0*CLHEP::mm; - G4int subdet; // LAr - if ( pointZshift < 0. ) - subdet = -4; - else - subdet = 4; - if (phi < 0) phi += 2*M_PI; - G4int etaIndex; - G4int phiIndex; - G4int region; - if ( eta < 5 ) { - if(rho > fcal_edge_approx) { - type = 2; - sampling = m_FCalSampling; - region = 4; - etaIndex = 0; - phiIndex = G4int(32*phi/M_PI); - } else { - region = 0; - etaIndex = G4int((eta-1.7)/0.1); - phiIndex = G4int(32*phi/M_PI); + G4int subdet; // LAr + if ( pointZshift < 0. ) + subdet = -4; + else + subdet = 4; + if (phi < 0) phi += 2*M_PI; + G4int etaIndex; + G4int phiIndex; + G4int region; + if ( eta < 5 ) { + if(rho > fcal_edge_approx) { + type = 2; + sampling = m_FCalSampling; + region = 4; + etaIndex = 0; + phiIndex = G4int(phi*(32/M_PI)); + } else { + region = 0; + etaIndex = G4int((eta-1.7)/0.1); + phiIndex = G4int(phi*(32/M_PI)); + } + } + else if ( eta < 8 ) { + region = 1; + etaIndex = G4int((eta-5)/0.2); + phiIndex = G4int(phi*(32/M_PI)); } - } - else if ( eta < 8 ) { - region = 1; - etaIndex = G4int((eta-5)/0.2); - phiIndex = G4int(32*phi/M_PI); - } - else { - region = 2; - etaIndex = 0; - phiIndex = 0; - } - - // Append the values to the empty identifier. - m_identifier << 10 // Calorimeter Dead Material - << subdet // LAr - << type - << sampling - << region - << etaIndex - << phiIndex; - -// std::cout << "LArG4FCAL/LArFCALCalibCalculatorBase: 10/4/" -// <<type<<"/" -// <<sampling<<"/" -// <<region<<"/" -// <<etaIndex<<"/" -// <<phiIndex<<": " -// << m_energies[0] << ", " -// << m_energies[1] << ", " -// << m_energies[2] << ", " -// << m_energies[3] -// << ", i=" << i -// << ", j=" << j -// << ", l.x=" << theLocalPoint.x() -// << ", l.y=" << theLocalPoint.y() -// << ", p.x=" << p.x() -// << ", p.y=" << p.y() -// << ", deltaX=" << m_deltaX -// << ", deltaY=" << m_deltaY -// << std::endl; + else { + region = 2; + etaIndex = 0; + phiIndex = 0; + } + + // Append the values to the empty identifier. + identifier << 10 // Calorimeter Dead Material + << subdet // LAr + << type + << sampling + << region + << etaIndex + << phiIndex; + + // std::cout << "LArG4FCAL/LArFCALCalibCalculatorBase: 10/4/" + // <<type<<"/" + // <<sampling<<"/" + // <<region<<"/" + // <<etaIndex<<"/" + // <<phiIndex<<": " + // << energies[0] << ", " + // << energies[1] << ", " + // << energies[2] << ", " + // << energies[3] + // << ", i=" << i + // << ", j=" << j + // << ", l.x=" << theLocalPoint.x() + // << ", l.y=" << theLocalPoint.y() + // << ", p.x=" << p.x() + // << ", p.y=" << p.y() + // << ", deltaX=" << m_deltaX + // << ", deltaY=" << m_deltaY + // << std::endl; } - + return true; } } // namespace FCAL - -} // namespace LArG4 - - - - - +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.h b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.h new file mode 100644 index 000000000000..43420b7dfd90 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/LArFCALCalibCalculatorBase.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4::FCAL::LArFCALCalibCalculator +// Prepared Oct./2004 Mohsen Khakzad + +// This class calculates the values needed for calibration hits in the +// simulation. + +// A "calculator" is used in much the same way as a hand-held +// calculator might be. The user supplies a value and hits 'Enter' +// Forward declaractions: +// (i.e., invokes the Process() method). Then they read off whatever +// values are of interest. + +#ifndef LArFCALCalibCalculatorBase_H +#define LArFCALCalibCalculatorBase_H + +#include "LArG4Code/LArCalibCalculatorSvcImp.h" +#include "LArG4Code/LArG4Identifier.h" + +//#include "LArG4FCAL/LArFCALCalculatorBase.h" + +#include "CaloG4Sim/SimulationEnergies.h" + +#include "globals.hh" +#include <vector> +// Forward declaration for namespace CaloG4. +class G4Step; +class FCAL_ChannelMap; + +namespace LArG4 { + + namespace FCAL { + + class LArFCALCalibCalculatorBase : public LArCalibCalculatorSvcImp { + public: + LArFCALCalibCalculatorBase(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize(); + StatusCode finalize() {return StatusCode::SUCCESS;} + virtual ~LArFCALCalibCalculatorBase(){}; + + + // The Process method returns a boolean value. If it's true, the + // hit can be used by Geant4; if it's false, there's something wrong + // with the energy deposit and it should be ignored. + + // For calibration work, most of the time we want the calculator + // to determine both the energy and the identifier. However, + // sometimes we want it calculate only the identifier (for + // escaped energy), or only the energy (no known application + // yet, but you can never tell). Use the enum (defined in + // VCalibrationCalculator.h) to control any special processing. + + + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + + ///////////////////////////////////////////// + + virtual G4double GetdeltaX(){return m_deltaX;} //FIXME public but not part of interface class + virtual G4double GetdeltaY(){return m_deltaY;} //FIXME public but not part of interface class + + protected: + + G4double m_deltaX; + G4double m_deltaY; + + G4int m_FCalSampling; + + private: + + // Energy calculator + CaloG4::SimulationEnergies m_energyCalculator; + + G4float m_zShift; + + FCAL_ChannelMap *m_ChannelMap; + + }; + } // namespace FCAL + +} // namespace LArG4 + +#endif // LArG4_HEC_CalibrationCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4FCAL/src/components/LArG4FCAL_entries.cxx b/LArCalorimeter/LArG4/LArG4FCAL/src/components/LArG4FCAL_entries.cxx new file mode 100644 index 000000000000..935550b81f09 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4FCAL/src/components/LArG4FCAL_entries.cxx @@ -0,0 +1,7 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" + +#include "../LArFCALCalculatorBase.h" +#include "../LArFCALCalibCalculatorBase.h" + +DECLARE_SERVICE_FACTORY(LArG4::FCAL::LArFCALCalibCalculatorBase) +DECLARE_SERVICE_FACTORY(LArFCALCalculatorBase) diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/doc/mainpage.h b/LArCalorimeter/LArG4/LArG4FastSimulation/doc/mainpage.h deleted file mode 100644 index 4755c885f75e..000000000000 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/doc/mainpage.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** - -@mainpage The LArG4 Fast Simulation Package - - - This class is the base class for the fast simulation in athena - - - LArFastShower: the main guiding code for the fast simulation. Controls application of the - various types of fast simulation. - - - For each subdetector in {FCAL, FCAL2, EMB, EMEC}, a separate class contains all constants - for parameterization (ShowerParameters) which inherit from a base class - - - For each subdetector in {HEC, FCAL, FCAL2, EMB, EMEC}, a separate class contains all flags and - energy cut offs for parameterization, frozen showers, and killing application (ParticleBounds) - which inherit from a base class - - - For each subdetector in {FCAL, EMB, EMEC}, a separate class contains special sensitive - detectors for frozen shower library application (FastSimDedicatedSD) which inherit from - a base class - - - TestActionTimer: a class for recording simulation time divided by subdetector and by particle type - - - LArG4FastSimulation_setupTimer_jobOptions.py: job options for enabling the TestActionTimer class - - - analyzeTimer.pl: a perl script for analyzing the results of the TestActionTimer in the sim log file - - - LArG4FastSimulation_frozenShowers_jobOptions.py: job option script for setting up frozen showers - during simulation. Not necessary any more. - - - LArG4FastSimulation_setup_jobOptions.py: job options script for setting up fast simulation. - Not necessary any more with current flag construction. - - - For questions or comments: Joe Boudreau (boudreau@pitt.edu) or the Atlas Fast Simulation Group (atlas-shower-param@cern.ch) - - - --------------------------------- - REQUIREMENTS --------------------------------- - -@include requirements -@htmlinclude used_packages.html - -*/ - diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py index 6dfc534ca5f2..d6cbf51a3896 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/python/LArG4FastSimulationConfig.py @@ -53,7 +53,7 @@ def getFCALFastShower(name="FCALFastShower", **kwargs): kwargs.setdefault("AbsHighEta", 4.4) kwargs.setdefault("DetectorTag", 300000) kwargs.setdefault("SensitiveDetector", "FCALFastSimDedicatedSD") - kwargs.setdefault("EMinEneShowerLib", 3.0) + kwargs.setdefault("EMinEneShowerLib", 0.51) return CfgMgr.LArFastShowerTool(name, **kwargs) def getFCAL2FastShower(name="FCAL2FastShower", **kwargs): @@ -68,5 +68,5 @@ def getFCAL2FastShower(name="FCAL2FastShower", **kwargs): kwargs.setdefault("AbsHighEta", 4.4) kwargs.setdefault("DetectorTag", 400000) kwargs.setdefault("SensitiveDetector", "FCALFastSimDedicatedSD") - kwargs.setdefault("EMinEneShowerLib", 1.0) + kwargs.setdefault("EMinEneShowerLib", 0.51) return CfgMgr.LArFastShowerTool(name, **kwargs) diff --git a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx index e1001702ad31..4b8f0082eb02 100644 --- a/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx +++ b/LArCalorimeter/LArG4/LArG4FastSimulation/src/EndcapFastSimDedicatedSD.cxx @@ -28,10 +28,10 @@ EndcapFastSimDedicatedSD::EndcapFastSimDedicatedSD(StoreGateSvc* detStore) if ( detStore->retrieve( m_emecManager ).isFailure() ){ throw std::runtime_error("Could not retrieve EMEC manager"); } - m_innerWheelCalculatorPos = new LArWheelCalculator(LArWheelCalculator::InnerAbsorberWheel,+1); - m_innerWheelCalculatorNeg = new LArWheelCalculator(LArWheelCalculator::InnerAbsorberWheel,-1); - m_outerWheelCalculatorPos = new LArWheelCalculator(LArWheelCalculator::OuterAbsorberWheel,+1); - m_outerWheelCalculatorNeg = new LArWheelCalculator(LArWheelCalculator::OuterAbsorberWheel,-1); + m_innerWheelCalculatorPos = new LArWheelCalculator(LArG4::InnerAbsorberWheel,+1); + m_innerWheelCalculatorNeg = new LArWheelCalculator(LArG4::InnerAbsorberWheel,-1); + m_outerWheelCalculatorPos = new LArWheelCalculator(LArG4::OuterAbsorberWheel,+1); + m_outerWheelCalculatorNeg = new LArWheelCalculator(LArG4::OuterAbsorberWheel,-1); } // ProcessHitsMethod diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4GenShowerLib/CMakeLists.txt index 617f8fdde3b3..e8d2a61b33c6 100644 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/CMakeLists.txt @@ -15,16 +15,12 @@ atlas_depends_on_subdirs( PUBLIC GaudiKernel Simulation/G4Atlas/G4AtlasTools Simulation/G4Atlas/G4AtlasInterfaces + LArCalorimeter/LArG4/LArG4Code PRIVATE - Control/CxxUtils + Control/CxxUtils DetectorDescription/GeoModel/GeoModelInterfaces Event/EventInfo Generators/GeneratorObjects - LArCalorimeter/LArG4/LArG4Barrel - LArCalorimeter/LArG4/LArG4Code - LArCalorimeter/LArG4/LArG4EC - LArCalorimeter/LArG4/LArG4FCAL - LArCalorimeter/LArG4/LArG4HEC LArCalorimeter/LArG4/LArG4ShowerLib ) # External dependencies: @@ -40,18 +36,18 @@ atlas_add_library( LArG4GenShowerLibLib PRIVATE_INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES AthenaBaseComps DataModel SGTools GaudiKernel G4AtlasToolsLib - PRIVATE_LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} EventInfo GeneratorObjects LArG4Barrel LArG4Code LArG4EC LArG4FCAL LArG4HEC LArG4ShowerLib ) + PRIVATE_LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} EventInfo GeneratorObjects LArG4Code LArG4ShowerLib ) -atlas_add_component( LArG4GenShowerLib - src/components/*.cxx - INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps DataModel SGTools GaudiKernel G4AtlasToolsLib EventInfo GeneratorObjects LArG4Barrel LArG4Code LArG4EC LArG4FCAL LArG4HEC LArG4ShowerLib LArG4GenShowerLibLib ) + atlas_add_component( LArG4GenShowerLib + src/components/*.cxx + INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps DataModel SGTools GaudiKernel G4AtlasToolsLib EventInfo GeneratorObjects LArG4Code LArG4ShowerLib LArG4GenShowerLibLib ) atlas_add_dictionary( LArG4GenShowerLibDict LArG4GenShowerLib/LArG4GenShowerLibDict.h LArG4GenShowerLib/selection.xml INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps DataModel SGTools GaudiKernel G4AtlasToolsLib EventInfo GeneratorObjects LArG4Barrel LArG4Code LArG4EC LArG4FCAL LArG4HEC LArG4ShowerLib LArG4GenShowerLibLib ) + LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${ROOT_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps DataModel SGTools GaudiKernel G4AtlasToolsLib EventInfo GeneratorObjects LArG4Code LArG4ShowerLib LArG4GenShowerLibLib ) # Install files from the package: atlas_install_python_modules( python/*.py ) diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/LArG4GenShowerLib/TestActionShowerLib.h b/LArCalorimeter/LArG4/LArG4GenShowerLib/LArG4GenShowerLib/TestActionShowerLib.h index 54aba7528dd1..9223a34bbfdd 100755 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/LArG4GenShowerLib/TestActionShowerLib.h +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/LArG4GenShowerLib/TestActionShowerLib.h @@ -2,7 +2,6 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ - #ifndef TestActionShowerLib_H #define TestActionShowerLib_H @@ -19,7 +18,7 @@ namespace HepMC { } // forward declarations in global namespace //class StoreGateSvc; -class LArVCalculator; +class EnergyCalculator; class G4VSolid; class G4AffineTransform; @@ -34,7 +33,7 @@ class G4AffineTransform; * @author Wolfgang Ehrenfeld, University of Hamburg, Germany * @author Sasha Glazov, DESY Hamburg, Germany * - * @version \$Id: TestActionShowerLib.h 746605 2016-05-12 13:25:40Z disimone $ + * @version \$Id: TestActionShowerLib.h 780759 2016-10-27 13:48:04Z pavol $ * */ @@ -44,6 +43,8 @@ class G4AffineTransform; #include "G4AtlasInterfaces/IEndRunAction.h" #include "G4AtlasInterfaces/ISteppingAction.h" +#include "LArG4Code/ILArCalculatorSvc.h" + #include "StoreGate/StoreGateSvc.h" #include "GaudiKernel/ServiceHandle.h" namespace G4UA{ @@ -70,14 +71,17 @@ namespace G4UA{ /* data members */ - LArVCalculator* m_current_calculator; + ServiceHandle<ILArCalculatorSvc> m_current_calculator; G4VSolid* m_current_solid; G4AffineTransform* m_current_transform; // calculators - LArVCalculator* m_calculator_EMECIW; //!< pointer to EMEC inner wheel calculator - LArVCalculator* m_calculator_EMECOW; //!< pointer to EMEC outer wheel calculator - + ServiceHandle<ILArCalculatorSvc> m_calculator_EMECIW; //!< pointer to EMEC inner wheel calculator + ServiceHandle<ILArCalculatorSvc> m_calculator_EMECOW; //!< pointer to EMEC outer wheel calculator + ServiceHandle<ILArCalculatorSvc> m_calculator_FCAL1; + ServiceHandle<ILArCalculatorSvc> m_calculator_FCAL2; + ServiceHandle<ILArCalculatorSvc> m_calculator_FCAL3; + ServiceHandle<ILArCalculatorSvc> m_calculator_EMB; ShowerLib::StepInfoCollection* m_eventSteps; //!< collection of StepInfo @@ -87,4 +91,4 @@ namespace G4UA{ } // namespace G4UA -#endif // TestActionShowerLib_H +#endif // TestActionShowerLib_H \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/cmt/requirements b/LArCalorimeter/LArG4/LArG4GenShowerLib/cmt/requirements index 7f2d87038e80..9cb471e70991 100755 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/cmt/requirements @@ -13,6 +13,7 @@ use GaudiInterface GaudiInterface-* External use G4AtlasInterfaces G4AtlasInterfaces-* Simulation/G4Atlas use G4AtlasTools G4AtlasTools-* Simulation/G4Atlas use StoreGate StoreGate-* Control +use LArG4Code LArG4Code-* LArCalorimeter/LArG4 private use AtlasROOT AtlasROOT-* External @@ -21,11 +22,6 @@ use EventInfo EventInfo-* Event use Geant4 Geant4-* External use GeneratorObjects GeneratorObjects-* Generators use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel -use LArG4Barrel LArG4Barrel-* LArCalorimeter/LArG4 -use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use LArG4EC LArG4EC-* LArCalorimeter/LArG4 -use LArG4FCAL LArG4FCAL-* LArCalorimeter/LArG4 -use LArG4HEC LArG4HEC-* LArCalorimeter/LArG4 use LArG4ShowerLib LArG4ShowerLib-* LArCalorimeter/LArG4 end_private diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/doc/mainpage.h b/LArCalorimeter/LArG4/LArG4GenShowerLib/doc/mainpage.h deleted file mode 100644 index 836082bae2fd..000000000000 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/doc/mainpage.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/** -@mainpage LArG4GenShowerLib Package - -@author Wolfgang Ehrenfeld <Wolfgang.Ehrenfeld@desy.de> -@author Alexandre Glazov <alexandre.glazov@desy.de> - -@section LArG4GenShowerLibIntro Introduction - -This package contains the algorithms to generate the Geant 4 based -shower parametrisation libraries. The generation process is a two step -process. First, full Geant 4 simulation is run with single -particles. The information about the hits in the sensitive calorimeter -detectors is store using the ShowerLib::StepInfo class. In a second -step the collected hits are clusterd and collected into a frozen -shower library using the ShowerLib::ShowerLib class. - -@section LArG4GenShowerLibOverview Class Overview - The LArG4GenShowerLib package contains of following algorithms: - - - LArG4GenShowerLib: clustering and collecting hits into shower library - - TestActionShowerLib: collecting of hit information in full Geant 4 simulation - - The data structure of the the shower library is contained in the - LArG4ShowerLib package. The entry point is the ShowerLib::ShowerLib class. - The hit information collected by the test action is contained in the - LArG4ShowerLib package. The entry point is the - ShowerLib::StepInfoCollection class. - -@section LArG4GenShowerLibJobOptions Job Options - For both algorithms dedicated job options are supplied which are used by the script - generateShowerLib.py. - - - LArG4GenShowerLib_generateHits_topoptions.py: configuration of single particle gun for hit generation - - LArG4GenShowerLib_testActionShowerLib_joboptions.py: configuration of test action for hit generation - - LArG4GenShowerLib_combine_topoptions.py: configuration of hit clustering and output options - - LArG4GenShowerLib_setupCalo_joboptions.py: configure calorimeter - - LArG4GenShowerLib_setup_joboptions.py: configure general LArG4GenShowerLib algorithm properties - - The list of properties for each algorithm can be found here: - - @link LArG4GenShowerLib::LArG4GenShowerLib @endlink - -@section LArG4GenShowerLibScripts Scripts - The whole shower library generation process can be done in one step using the - generateShowerLib.py script. For the options see the help function of the script. - - -@section LArG4GenShowerLibDefaultSettings Default Settings - - The default settings of the library generation process are stored in - @include generate_libs.txt. - -@section LArG4GenShowerLib Extra Pages - -- @ref used_LArG4GenShowerLib -- @ref requirements_LArG4GenShowerLib -*/ - -/** - @page used_LArG4GenShowerLib Used Packages - @htmlinclude used_packages.html -*/ - -/** - @page requirements_LArG4GenShowerLib Requirements - @include requirements -*/ - - diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/python/LArG4GenShowerLibConfig.py b/LArCalorimeter/LArG4/LArG4GenShowerLib/python/LArG4GenShowerLibConfig.py index b68b7bd9c64a..8cbe86990d79 100644 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/python/LArG4GenShowerLibConfig.py +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/python/LArG4GenShowerLibConfig.py @@ -9,4 +9,4 @@ def getLArG4GenShowerLib(name="LArG4GenShowerLib", **kwargs): def getTestActionShowerLibTool(name="G4UA::TestActionShowerLibTool", **kwargs): from LArG4GenShowerLib.LArG4GenShowerLibConf import G4UA__TestActionShowerLibTool - return G4UA__TestActionShowerLibTool(name,**kwargs) + return G4UA__TestActionShowerLibTool(name,**kwargs) \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/share/LArG4GenerateShowerLib.py b/LArCalorimeter/LArG4/LArG4GenShowerLib/share/LArG4GenerateShowerLib.py index 0549591d8921..f4f0c39cdfe6 100755 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/share/LArG4GenerateShowerLib.py +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/share/LArG4GenerateShowerLib.py @@ -1,7 +1,7 @@ #!/usr/bin/env physh # print command line for logging from optparse import OptionParser -parser = OptionParser(usage = "usage: %prog", version="%prog $Id: LArG4GenerateShowerLib.py 746605 2016-05-12 13:25:40Z disimone $") +parser = OptionParser(usage = "usage: %prog", version="%prog $Id: LArG4GenerateShowerLib.py 767177 2016-08-10 08:49:45Z disimone $") parser.add_option("--inputEvtFileList", dest="inputevt", action="append", help="select the input file name") parser.add_option("--inputStructFileList", dest="inputstruct", action="append", help="select the output file name") @@ -79,16 +79,7 @@ simFlags.RandomSeedOffset = randint(1,443921180) #add G4 function from G4AtlasApps.SimFlags import simFlags -if hasattr(simFlags, 'UseV2UserActions') and simFlags.UseV2UserActions(): - # V2 user actions, for hive - simFlags.OptionalUserActionList.addAction('G4UA::TestActionShowerLibTool',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) -else: - # V1 userActions - try: - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - except ImportError: - from G4AtlasServices.UserActionStore import UAStore - UAStore.addAction('TestActionShowerLib',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) +simFlags.OptionalUserActionList.addAction('G4UA::TestActionShowerLibTool',['BeginOfEvent','EndOfEvent','BeginOfRun','EndOfRun','Step']) topSeq += PyG4AtlasAlg() diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/src/LArG4GenShowerLib.cxx b/LArCalorimeter/LArG4/LArG4GenShowerLib/src/LArG4GenShowerLib.cxx index f453214343a9..13278d491129 100755 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/src/LArG4GenShowerLib.cxx +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/src/LArG4GenShowerLib.cxx @@ -3,14 +3,14 @@ */ /** - * $Id: LArG4GenShowerLib.cxx 746605 2016-05-12 13:25:40Z disimone $: + * $Id: LArG4GenShowerLib.cxx 770430 2016-08-26 20:49:25Z ssnyder $: * * @short Implementation of shower library generation algorithm * * * @author Wolfgang Ehrenfeld, University of Hamburg, Germany * @author Sasha Glazov, DESY Hamburg, Germany - * @version $Revision: 746605 $ + * @version $Revision: 770430 $ * */ @@ -45,7 +45,7 @@ using CLHEP::Hep3Vector; // definition for helper struct class Dist { public: - Dist(ShowerLib::StepInfo* _h1, ShowerLib::StepInfo* _h2) : h1(_h1), h2(_h2) {} + Dist(ShowerLib::StepInfo* the_h1, ShowerLib::StepInfo* the_h2) : h1(the_h1), h2(the_h2) {} ShowerLib::StepInfo* h1; ShowerLib::StepInfo* h2; ShowerLib::StepInfo* merge () @@ -60,21 +60,21 @@ public: class stepInfoDistCompare{ public: enum CompareType {RHO,R,Z}; - stepInfoDistCompare(const CompareType _type) : type(_type) {} + stepInfoDistCompare(const CompareType type) : m_type(type) {} bool operator()( const ShowerLib::StepInfo * first, const ShowerLib::StepInfo * second) const { - return sortFunction(first, second, type ); + return sortFunction(first, second, m_type ); } private: - CompareType type; + CompareType m_type; //returns true if first is closer to the origin. this should sort from closest to farest - bool sortFunction ( const ShowerLib::StepInfo* first, const ShowerLib::StepInfo* second, const CompareType _type) const { - if (_type == RHO) { + bool sortFunction ( const ShowerLib::StepInfo* first, const ShowerLib::StepInfo* second, const CompareType type) const { + if (type == RHO) { if (first->position().mag2() < second->position().mag2()) return true; return false; - } else if (_type == R) { + } else if (type == R) { if (first->position().perp2() < second->position().perp2()) return true; return false; - } else if (_type == Z) { + } else if (type == Z) { if (first->position().z() < second->position().z()) return true; return false; } @@ -415,8 +415,9 @@ void LArG4GenShowerLib::truncate(ShowerLib::StepInfoList* stepinfo) return; } + const double inv_rsum = 1. / rsum; for (iterCut = stepinfo->begin(); iterCut != stepinfo->end(); ++iterCut){ - (*iterCut)->setE((*iterCut)->dep() * etot/rsum); + (*iterCut)->setE((*iterCut)->dep() * etot*inv_rsum); } } @@ -521,11 +522,12 @@ void LArG4GenShowerLib::calculateMoments(const ShowerLib::StepInfoCollection& ev } // Center of gravity: - xavfra = xav/escal; - yavfra = yav/escal; + const double inv_escal = 1. / escal; + xavfra = xav*inv_escal; + yavfra = yav*inv_escal; // Second momentum: - ravfra = std::sqrt(std::abs((xav2/escal-xavfra*xavfra) + - (yav2/escal-yavfra*yavfra))); + ravfra = std::sqrt(std::abs((xav2*inv_escal-xavfra*xavfra) + + (yav2*inv_escal-yavfra*yavfra))); // energy is used as weights weights = escal; diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLib.cxx b/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLib.cxx index a46662c84a0d..7cd83ecbd49b 100755 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLib.cxx +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLib.cxx @@ -2,7 +2,6 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ - #include "LArG4GenShowerLib/TestActionShowerLib.h" #include <stdexcept> @@ -16,16 +15,6 @@ #include "G4EventManager.hh" #include "G4ThreeVector.hh" -// all the LAr calculators -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Barrel/LArBarrelCalculator.h" -#include "LArG4EC/EnergyCalculator.h" -#include "LArG4FCAL/LArFCAL1Calculator.h" -#include "LArG4FCAL/LArFCAL2Calculator.h" -#include "LArG4FCAL/LArFCAL3Calculator.h" -#include "LArG4HEC/LArHECCalculator.h" -#include "LArG4HEC/LArHECLocalCalculator.h" - #include "LArG4GenShowerLib/StepInfo.h" #include "LArG4GenShowerLib/StepInfoCollection.h" @@ -34,17 +23,27 @@ namespace G4UA{ - TestActionShowerLib::TestActionShowerLib(): m_evtStore("StoreGateSvc/StoreGateSvc","TestActionShowerLib"), m_detStore("StoreGateSvc/DetectorStore","TestActionShowerLib"), - m_current_calculator(0), - m_current_solid(0), - m_current_transform(0), - m_calculator_EMECIW(0), - m_calculator_EMECOW(0), - m_eventSteps(0) + m_current_calculator("","TestActionShowerLib"), + m_current_solid(nullptr), + m_current_transform(nullptr), + m_calculator_EMECIW("EMECPosInnerWheelCalculator","TestActionShowerLib"), + m_calculator_EMECOW("EMECPosOuterWheelCalculator","TestActionShowerLib"), + m_calculator_FCAL1("FCAL1Calculator","TestActionShowerLib"), + m_calculator_FCAL2("FCAL2Calculator","TestActionShowerLib"), + m_calculator_FCAL3("FCAL3Calculator","TestActionShowerLib"), + m_calculator_EMB("EMBCalculator","TestActionShowerLib"), + m_eventSteps(nullptr) { + + //declareProperty("EMECIWCalculator", m_calculator_EMECIW); + //declareProperty("EMECOWCalculator", m_calculator_EMECOW); + //declareProperty("FCAL1Calculator", m_calculator_FCAL1); + //declareProperty("FCAL2Calculator", m_calculator_FCAL2); + //declareProperty("FCAL3Calculator", m_calculator_FCAL3); + //declareProperty("EMBCalculator",m_calculator_EMB); #ifdef _myDEBUG_ G4cout << "#########################################" << G4endl << "## TestActionShowerLib - Constructor ##" << G4endl @@ -54,11 +53,6 @@ namespace G4UA{ void TestActionShowerLib::beginOfEvent(const G4Event*){ - // init calculator - if (m_calculator_EMECIW == 0) - m_calculator_EMECIW = new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel); - if (m_calculator_EMECOW == 0) - m_calculator_EMECOW = new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel); if (m_current_transform == 0) m_current_transform = new G4AffineTransform (); @@ -139,41 +133,53 @@ namespace G4UA{ << "## TestActionShowerLib - BeginOfRun ##" << G4endl << "#########################################" << G4endl; #endif - // init calculator - if (m_calculator_EMECIW == 0) - m_calculator_EMECIW = new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel); - if (m_calculator_EMECOW == 0) - m_calculator_EMECOW = new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel); - if (m_current_transform == 0) - m_current_transform = new G4AffineTransform (); - - return; - } - - void TestActionShowerLib::endOfRun(const G4Run*){ - - if (m_calculator_EMECIW != 0) { - delete m_calculator_EMECIW; - m_calculator_EMECIW = 0; + if(!m_calculator_EMECIW.retrieve().isSuccess()) { + G4cout<<"Could not get ILArCalculatorSvc/InnerAbsorberWheel"<<G4endl; + return; } - - if (m_calculator_EMECOW != 0) { - delete m_calculator_EMECOW; - m_calculator_EMECOW = 0; + if(!m_calculator_EMECOW.retrieve().isSuccess()) { + G4cout<<"Could not get ILArCalculatorSvc/OuterAbsorberWheel"<<G4endl; + return; + } + if(!m_calculator_FCAL1.retrieve().isSuccess()) { + G4cout<<"Could not get ILArCalculatorSvc/FCAL1Calculator"<<G4endl; + return; + } + if(!m_calculator_FCAL2.retrieve().isSuccess()) { + G4cout<<"Could not get ILArCalculatorSvc/FCAL2Calculator"<<G4endl; + return; } + if(!m_calculator_FCAL3.retrieve().isSuccess()) { + G4cout<<"Could not get ILArCalculatorSvc/FCAL3Calculator"<<G4endl; + return; + } + if(!m_calculator_EMB.retrieve().isSuccess()) { + G4cout<<"Could not get ILArCalculatorSvc/BarrelCalculator"<<G4endl; + return; + } + + if (m_current_transform == 0) + m_current_transform = new G4AffineTransform (); + + return; +} + +void TestActionShowerLib::endOfRun(const G4Run*){ #ifdef _myDEBUG_ G4cout << "#########################################" << G4endl << "## TestActionShowerLib - EndOfRun ##" << G4endl << "#########################################" << G4endl; #endif - - return; - } + + return; +} + - void TestActionShowerLib::processStep(const G4Step* aStep){ +void TestActionShowerLib::processStep(const G4Step* aStep){ + bool hasCalc=true; bool emptydet = (m_eventSteps->detector[0] == '\0'); //empty string. man, i hate pure C! if (emptydet) { //give name to the detector, set calculator, transformation and G4Solid for the whole shower G4ThreeVector pos = aStep->GetPostStepPoint()->GetPosition(); @@ -214,11 +220,11 @@ namespace G4UA{ if (cur_log_volume->GetName() == "LArMgr::LAr::FCAL::Module1::Absorber") { // shower is inside FCAL1 - m_current_calculator = LArFCAL1Calculator::GetInstance(); + m_current_calculator = m_calculator_FCAL1; strcpy(m_eventSteps->detector,"FCAL1"); } else if (cur_log_volume->GetName() == "LArMgr::LAr::FCAL::Module2::Absorber") { // shower is inside FCAL2 - m_current_calculator = LArFCAL2Calculator::GetInstance(); + m_current_calculator = m_calculator_FCAL2; strcpy(m_eventSteps->detector,"FCAL2"); } else if ((cur_log_volume->GetName() == "LArMgr::LAr::EMEC::Pos::InnerWheel") || (cur_log_volume->GetName() == "LArMgr::LAr::EMEC::Neg::InnerWheel")) { @@ -232,17 +238,18 @@ namespace G4UA{ strcpy(m_eventSteps->detector,"EMEC"); } else if (cur_log_volume->GetName() == "LArMgr::LAr::EMB::STAC") { // shower is inside EMB positive - m_current_calculator = LArBarrelCalculator::GetCalculator(); + m_current_calculator = m_calculator_EMB; strcpy(m_eventSteps->detector,"EMB"); } else { // outside. - m_current_calculator = NULL; + //m_current_calculator = NULL; + hasCalc=false; } } if (aStep->GetTotalEnergyDeposit()>0) { //first, let's see if the shower is valid - if (m_current_calculator == NULL) { + if (!hasCalc) { m_eventSteps->invalid_energy += aStep->GetTotalEnergyDeposit(); return; } @@ -268,16 +275,19 @@ namespace G4UA{ } double et = 0; // Total collected charge - - if (m_current_calculator->Process(aStep)) { - int nlarh = m_current_calculator->getNumHits(); - for (int i=0; i<nlarh; ++i) { - et += (m_current_calculator->energy(i)); - } - } else { - G4cout << "Error: Hit not processed by calculator!" << G4endl; - return; - } + std::vector<LArHitData> results; + if (m_current_calculator->Process(aStep, results)) + { + for (auto larhit: results) + { + et += larhit.energy; + } + } + else + { + G4cout << "Error: Hit not processed by calculator!" << G4endl; + return; + } // drop hits with zero deposited energy (could still happen with negative corrections from calculator) if (et <= 0.) { @@ -308,4 +318,4 @@ namespace G4UA{ } -} // namespace G4UA +} // namespace G4UA \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLibTool.cxx b/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLibTool.cxx index 42518dde3e95..ccaac264e3ea 100644 --- a/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLibTool.cxx +++ b/LArCalorimeter/LArG4/LArG4GenShowerLib/src/TestActionShowerLibTool.cxx @@ -13,8 +13,7 @@ namespace G4UA{ } std::unique_ptr<TestActionShowerLib> TestActionShowerLibTool::makeAction(){ ATH_MSG_DEBUG("makeAction"); - auto action = CxxUtils::make_unique<TestActionShowerLib>(); - return std::move(action); + return CxxUtils::make_unique<TestActionShowerLib>(); } StatusCode TestActionShowerLibTool::queryInterface(const InterfaceID& riid, void** ppvIf){ diff --git a/LArCalorimeter/LArG4/LArG4H6SD/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4H6SD/CMakeLists.txt index 081f5bc4d2be..cc637bf48903 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4H6SD/CMakeLists.txt @@ -21,13 +21,11 @@ atlas_depends_on_subdirs( PUBLIC DetectorDescription/Identifier Generators/GeneratorObjects LArCalorimeter/LArG4/LArG4Code - LArCalorimeter/LArG4/LArG4EC - LArCalorimeter/LArG4/LArG4FCAL - LArCalorimeter/LArG4/LArG4HEC LArCalorimeter/LArG4/LArG4RunControl LArCalorimeter/LArG4TB/LArG4TBSimEvent LArCalorimeter/LArGeoModel/LArReadoutGeometry LArCalorimeter/LArSimEvent + Simulation/G4Atlas/G4AtlasInterfaces Simulation/G4Atlas/G4AtlasTools Simulation/G4Sim/SimHelpers Simulation/HitManagement @@ -48,7 +46,7 @@ atlas_add_component( LArG4H6SD src/*.cc src/components/*.cxx INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} ${HEPMC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} - LINK_LIBRARIES ${CORAL_LIBRARIES} ${Boost_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} ${GEANT4_LIBRARIES} GaudiKernel CaloG4SimLib CaloSimEvent AthenaBaseComps AthenaKernel CxxUtils StoreGateLib SGtests GeoModelUtilities Identifier GeneratorObjects LArG4Code LArG4EC LArG4FCAL LArG4HEC LArG4RunControl LArG4TBSimEvent LArReadoutGeometry LArSimEvent G4AtlasToolsLib SimHelpers HitManagement TBEvent PathResolver ) + LINK_LIBRARIES ${CORAL_LIBRARIES} ${Boost_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} ${HEPMC_LIBRARIES} ${GEANT4_LIBRARIES} GaudiKernel CaloG4SimLib CaloSimEvent AthenaBaseComps AthenaKernel CxxUtils StoreGateLib SGtests GeoModelUtilities Identifier GeneratorObjects LArG4Code LArG4RunControl LArG4TBSimEvent LArReadoutGeometry LArSimEvent G4AtlasInterfaces G4AtlasToolsLib SimHelpers HitManagement TBEvent PathResolver ) # Install files from the package: atlas_install_headers( LArG4H6SD ) diff --git a/LArCalorimeter/LArG4/LArG4H6SD/cmt/requirements b/LArCalorimeter/LArG4/LArG4H6SD/cmt/requirements index 6140e53077f4..54f5731c1d51 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4H6SD/cmt/requirements @@ -25,16 +25,17 @@ use AtlasBoost AtlasBoost-* External use CaloG4Sim CaloG4Sim-* Calorimeter #use CaloIdentifier CaloIdentifier-* Calorimeter use CaloSimEvent CaloSimEvent-* Calorimeter +use G4AtlasInterfaces G4AtlasInterfaces-* Simulation/G4Atlas use Geant4 Geant4-* External use GeneratorObjects GeneratorObjects-* Generators use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel use GeoModelUtilities GeoModelUtilities-* DetectorDescription/GeoModel -use HitManagement HitManagement-* Simulation +use HitManagement HitManagement-* Simulation use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use LArG4HEC LArG4HEC-* LArCalorimeter/LArG4 -use LArG4EC LArG4EC-* LArCalorimeter/LArG4 -use LArG4FCAL LArG4FCAL-* LArCalorimeter/LArG4 -#use LArG4SD LArG4SD-* LArCalorimeter/LArG4 +#use LArG4HEC LArG4HEC-* LArCalorimeter/LArG4 +#use LArG4EC LArG4EC-* LArCalorimeter/LArG4 +#use LArG4FCAL LArG4FCAL-* LArCalorimeter/LArG4 +#use LArG4SD LArG4SD-* LArCalorimeter/LArG4 use LArG4TBSimEvent LArG4TBSimEvent-* LArCalorimeter/LArG4TB use LArSimEvent LArSimEvent-* LArCalorimeter use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfig.py b/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfig.py index 710c472994f2..1a72b841683f 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfig.py +++ b/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfig.py @@ -1,8 +1,14 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration from AthenaCommon import CfgMgr +from AthenaCommon.SystemOfUnits import mm, deg,ns +import math def getLArG4TBECBeamChSDTool(name="LArG4TBECBeamChSensitiveDetector", **kwargs): - kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::TBEC::BeamChamber0","LArMgr::LAr::TBEC::BeamChamber1","LArMgr::LAr::TBEC::BeamChamber2","LArMgr::LAr::TBEC::BeamChamber3"]) + kwargs.setdefault("LogicalVolumeNames", [ + "LArMgr::LAr::TBEC::BeamChamber0", + "LArMgr::LAr::TBEC::BeamChamber1", + "LArMgr::LAr::TBEC::BeamChamber2", + "LArMgr::LAr::TBEC::BeamChamber3"]) return CfgMgr.LArG4TBECBeamChSDTool(name, **kwargs) def getFrontLArG4H6BeamSDTool(name="LArG4H6BeamSD::Front", **kwargs): @@ -10,46 +16,53 @@ def getFrontLArG4H6BeamSDTool(name="LArG4H6BeamSD::Front", **kwargs): return CfgMgr.LArG4H6BeamSDTool(name, **kwargs) def getMovableLArG4H6BeamSDTool(name="LArG4H6BeamSD::Movable", **kwargs): - kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::TBH62004::MovableTable::Scintillator","LArMgr::LAr::TB::BPCOLD::bpco_div","LArMgr::LAr::TB::BPC::bpc_xdiv","LArMgr::LAr::TB::BPC::bpc_ydiv","LArMgr::LAr::TB::MWPC::XDiv","LArMgr::LAr::TB::MWPC::YDiv"]) + kwargs.setdefault("LogicalVolumeNames", [ + "LArMgr::LAr::TBH62004::MovableTable::Scintillator", + "LArMgr::LAr::TB::BPCOLD::bpco_div", + "LArMgr::LAr::TB::BPC::bpc_xdiv", + "LArMgr::LAr::TB::BPC::bpc_ydiv", + "LArMgr::LAr::TB::MWPC::XDiv", + "LArMgr::LAr::TB::MWPC::YDiv"]) return CfgMgr.LArG4H6BeamSDTool(name, **kwargs) def getLArG4H6WarmTC_X(name="LArG4H6WarmTC::X", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::WarmTC::Sci::X"]) - return CfgMgr.getLArG4H6WarmTC(name, **kwargs) + return CfgMgr.LArG4H6WarmTCSDTool(name, **kwargs) def getLArG4H6WarmTC_Y(name="LArG4H6WarmTC::Y", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::WarmTC::Sci::Y"]) - return CfgMgr.getLArG4H6WarmTC(name, **kwargs) + return CfgMgr.LArG4H6WarmTCSDTool(name, **kwargs) def getLArG4H6WarmTC_Abs(name="LArG4H6WarmTC::Abs", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::WarmTC::Absorber"]) - return CfgMgr.getLArG4H6WarmTC(name, **kwargs) + return CfgMgr.LArG4H6WarmTCSDTool(name, **kwargs) def getTBECInnerModuleTool(name="TBECInnerModuleMult", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::EMEC::InnerModule"]) - return CfgMgr.getTBECInnerModuleTool(name,**kwargs) + return CfgMgr.TBECInnerModuleTool(name,**kwargs) def getTBECOuterModuleTool(name="TBECOuterModuleMult", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::EMEC::OuterModule"]) - return CfgMgr.getTBECOuterModuleTool(name,**kwargs) + return CfgMgr.TBECOuterModuleTool(name,**kwargs) def getTBECBackOuterBarretteTool(name="TBECBackOuterBarretteMult", **kwargs): - kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::EMEC::BackOuterBarrette::Module::Phidiv"]) - return CfgMgr.getTBECBackOuterBarretteTool(name,**kwargs) + kwargs.setdefault("LogicalVolumeNames", + ["LArMgr::LAr::EMEC::BackOuterBarrette::Module::Phidiv"]) + return CfgMgr.TBECBackOuterBarretteTool(name,**kwargs) def getLArG4H62004HECSDTool(name="LArG4H62004HECSDTool", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::HEC::Module::Depth::Slice"]) - return CfgMgr.getLArG4H62004HECSDTool(name,**kwargs) + return CfgMgr.LArG4__H62004HECSDTool(name,**kwargs) def getLArG4H62004EMECSDTool(name="LArG4H62004EMECSDTool", **kwargs): kwargs.setdefault("LogicalVolumeNames", ["LArMgr::LAr::EMEC::InnerWheel"]) - return CfgMgr.getLArG4H62004EMECSDTool(name,**kwargs) + return CfgMgr.LArG4__H62004EMECSDTool(name,**kwargs) def getLArG4H62004FCALSDTool(name="LArG4H62004FCALSDTool", **kwargs): kwargs.setdefault("FCAL1Volumes", ["LArMgr::LAr::FCAL::Module1::Gap"]) kwargs.setdefault("FCAL2Volumes", ["LArMgr::LAr::FCAL::Module2::Gap"]) kwargs.setdefault("FCALColdVolumes", ["LArMgr::LAr::FCAL::ColdTC::Gap"]) - return CfgMgr.getLArG4H62004FCALSDTool(name,**kwargs) + return CfgMgr.LArG4__H62004FCALSDTool(name,**kwargs) def getLArG4H62004ActiveSDTool(name="LArG4H62004ActiveSDTool", **kwargs): from G4AtlasApps.SimFlags import simFlags @@ -61,26 +74,233 @@ def getLArG4H62004ActiveSDTool(name="LArG4H62004ActiveSDTool", **kwargs): kwargs.setdefault("FCAL1Volumes", ["LArMgr::LAr::FCAL::Module1::Gap"]) kwargs.setdefault("FCAL2Volumes", ["LArMgr::LAr::FCAL::Module2::Gap"]) kwargs.setdefault("FCALColdVolumes", ["LArMgr::LAr::FCAL::ColdTC::Gap"]) - return CfgMgr.getLArG4H62004ActiveSDTool(name,**kwargs) + return CfgMgr.LArG4__H62004ActiveSDTool(name,**kwargs) def getLArG4H62004DeadSDTool(name="LArG4H62004DeadSDTool", **kwargs): theVolumes = [] if simFlags.LArTB_H6Hec.get_Value(): - theVolumes += [ "LArMgr::LAr::HEC::Module","LArMgr::LAr::HEC::Module::Depth","LArMgr::LAr::HEC::Module::Depth::Slice","LArMgr::LAr::HEC::Module::Depth::Slice::TieRod","LArMgr::LAr::HEC::Module::Depth::FirstAbsorber" ] + theVolumes += [ "LArMgr::LAr::HEC::Module", + "LArMgr::LAr::HEC::Module::Depth", + "LArMgr::LAr::HEC::Module::Depth::Slice", + "LArMgr::LAr::HEC::Module::Depth::Slice::TieRod", + "LArMgr::LAr::HEC::Module::Depth::FirstAbsorber" ] if simFlags.LArTB_H6Emec.get_Value(): - theVolumes += [ "LArMgr::LAr::EMEC::Mother*","LArMgr::LAr::EMEC::Front*","LArMgr::LAr::EMEC::BackSupport*","LArMgr::LAr::EMEC::Back*Barrettes","LArMgr::LAr::EMEC::Back*Barrette::Module","LArMgr::LAr::EMEC::BackInnerBarrette::Module::Phidiv","LArMgr::LAr::EMEC::Back*Abs","LArMgr::LAr::EMEC::Back*Ele","LArMgr::LAr::EMEC::Back*Ring","LArMgr::LAr::EMEC::Back*Bar","LArMgr::LAr::EMEC::Back*Hole","LArMgr::LAr::EMEC::Back*GTen","LArMgr::LAr::EMEC::Top*","LArMgr::LAr::EMEC::*Stretchers","LArMgr::LAr::EMEC::InnerAluCone*","LArMgr::LAr::EMEC::InnerTransversalBars" ] + theVolumes += [ "LArMgr::LAr::EMEC::Mother*", + "LArMgr::LAr::EMEC::Front*", + "LArMgr::LAr::EMEC::BackSupport*", + "LArMgr::LAr::EMEC::Back*Barrettes", + "LArMgr::LAr::EMEC::Back*Barrette::Module", + "LArMgr::LAr::EMEC::BackInnerBarrette::Module::Phidiv", + "LArMgr::LAr::EMEC::Back*Abs", + "LArMgr::LAr::EMEC::Back*Ele", + "LArMgr::LAr::EMEC::Back*Ring", + "LArMgr::LAr::EMEC::Back*Bar", + "LArMgr::LAr::EMEC::Back*Hole", + "LArMgr::LAr::EMEC::Back*GTen", + "LArMgr::LAr::EMEC::Top*", + "LArMgr::LAr::EMEC::*Stretchers", + "LArMgr::LAr::EMEC::InnerAluCone*", + "LArMgr::LAr::EMEC::InnerTransversalBars" ] if simFlags.LArTB_H6Fcal.get_Value(): - theVolumes += [ "LArMgr::LAr::FCAL::LiquidArgonC","LArMgr::LAr::FCAL::ColdTC::Absorber","LArMgr::LAr::FCAL::ColdTC::Active","LArMgr::LAr::FCAL::ColdTC::Electrode" ] - theVolumes += [ "LArMgr::LAr::WarmTC::Sci::X","LArMgr::LAr::WarmTC::Sci::Y","LArMgr::LAr::WarmTC::Absorber","LArMgr::LAr::TBH62004::FrontBeam::Scintillator","LArMgr::LAr::TBH62004::MovableTable::Scintillator","LArMgr::LAr::TB::BPCOLD::bpco_div","LArMgr::LAr::TB::BPC::bpc_xdiv","LArMgr::LAr::TB::BPC::bpc_ydiv","LArMgr::LAr::TB::MWPC::XDiv","LArMgr::LAr::TB::MWPC::YDiv","LARTBWORLD::LARTBWORLD","LArMgr::ExpHallLog","LArMgr::LArGeoTB::LeakageDet::ColdNose","LArMgr::LAr::H6::Cryostat::MotherVolume","LArMgr::LArTB::H6::Cryostat::WarmWall","LArMgr::LArTB::H6::Cryostat::Vacuum","LArMgr::LArTB::H6::Cryostat::ColdWall","LArMgr::LArTB::H6::Cryostat::LAr","LArMgr::LArGeoTB::LeakageDet::LAr","LArMgr::LArGeoTB::EMEC::Excluder","LArMgr::LArGeoTB::FCAL::Excluder","LArMgr::LArGeoTB::Front::Excluder","LArMgr::LArGeoTB::Back::Excluder","LArMgr::LAr::WarmTC::MuonWall","LArMgr::LAr::TBH62004::FrontBeam","LArMgr::LAr::TB::MWPC","LArMgr::LAr::TB::MWPC::Mylar","LArMgr::LAr::TB::MWPC::AlFoil","LArMgr::LAr::TB::MWPC::XPlane","LArMgr::LAr::TB::MWPC::YPlane","LArMgr::LAr::TB::MWPC::Wire","LArMgr::LAr::TB::BPC","LArMgr::LAr::TB::BPC::bpcalmylar","LArMgr::LAr::TB::BPC::bpc_mylar","LArMgr::LAr::TB::BPC::bpc_xplane","LArMgr::LAr::TB::BPC::bpc_wire","LArMgr::LAr::TB::BPC::bpc_cwire","LArMgr::LAr::TB::BPC::bpc_yplane","LArMgr::LAr::TBH62004::MiddleBeam","LArMgr::LAr::TB::BPCOLD","LArMgr::LAr::TB::BPCOLD::bpcalmylar","LArMgr::LAr::TB::BPCOLD::bpc_mylar","LArMgr::LAr::TB::BPCOLD::bpco_plane","LArMgr::LAr::TB::BPCOLD::bpco_wire","LArMgr::LAr::TB::BPCOLD::bpco_cwire","LArMgr::LAr::TBH62004::MovableTable","LArMgr::WarmTC_Mother" ] + theVolumes += [ "LArMgr::LAr::FCAL::LiquidArgonC", + "LArMgr::LAr::FCAL::ColdTC::Absorber", + "LArMgr::LAr::FCAL::ColdTC::Active", + "LArMgr::LAr::FCAL::ColdTC::Electrode" ] + theVolumes += [ "LArMgr::LAr::WarmTC::Sci::X", + "LArMgr::LAr::WarmTC::Sci::Y", + "LArMgr::LAr::WarmTC::Absorber", + "LArMgr::LAr::TBH62004::FrontBeam::Scintillator", + "LArMgr::LAr::TBH62004::MovableTable::Scintillator", + "LArMgr::LAr::TB::BPCOLD::bpco_div", + "LArMgr::LAr::TB::BPC::bpc_xdiv", + "LArMgr::LAr::TB::BPC::bpc_ydiv", + "LArMgr::LAr::TB::MWPC::XDiv", + "LArMgr::LAr::TB::MWPC::YDiv", + "LARTBWORLD::LARTBWORLD", + "LArMgr::ExpHallLog", + "LArMgr::LArGeoTB::LeakageDet::ColdNose", + "LArMgr::LAr::H6::Cryostat::MotherVolume", + "LArMgr::LArTB::H6::Cryostat::WarmWall", + "LArMgr::LArTB::H6::Cryostat::Vacuum", + "LArMgr::LArTB::H6::Cryostat::ColdWall", + "LArMgr::LArTB::H6::Cryostat::LAr", + "LArMgr::LArGeoTB::LeakageDet::LAr", + "LArMgr::LArGeoTB::EMEC::Excluder", + "LArMgr::LArGeoTB::FCAL::Excluder", + "LArMgr::LArGeoTB::Front::Excluder", + "LArMgr::LArGeoTB::Back::Excluder", + "LArMgr::LAr::WarmTC::MuonWall", + "LArMgr::LAr::TBH62004::FrontBeam", + "LArMgr::LAr::TB::MWPC", + "LArMgr::LAr::TB::MWPC::Mylar", + "LArMgr::LAr::TB::MWPC::AlFoil", + "LArMgr::LAr::TB::MWPC::XPlane", + "LArMgr::LAr::TB::MWPC::YPlane", + "LArMgr::LAr::TB::MWPC::Wire", + "LArMgr::LAr::TB::BPC", + "LArMgr::LAr::TB::BPC::bpcalmylar", + "LArMgr::LAr::TB::BPC::bpc_mylar", + "LArMgr::LAr::TB::BPC::bpc_xplane", + "LArMgr::LAr::TB::BPC::bpc_wire", + "LArMgr::LAr::TB::BPC::bpc_cwire", + "LArMgr::LAr::TB::BPC::bpc_yplane", + "LArMgr::LAr::TBH62004::MiddleBeam", + "LArMgr::LAr::TB::BPCOLD", + "LArMgr::LAr::TB::BPCOLD::bpcalmylar", + "LArMgr::LAr::TB::BPCOLD::bpc_mylar", + "LArMgr::LAr::TB::BPCOLD::bpco_plane", + "LArMgr::LAr::TB::BPCOLD::bpco_wire", + "LArMgr::LAr::TB::BPCOLD::bpco_cwire", + "LArMgr::LAr::TBH62004::MovableTable", + "LArMgr::WarmTC_Mother" ] kwargs.setdefault("LogicalVolumeNames",theVolumes) - return CfgMgr.getLArG4H62004DeadSDTool(name,**kwargs) + return CfgMgr.LArG4__H62004DeadSDTool(name,**kwargs) def getLArG4H62004InactiveSDTool(name="LArG4H62004InactiveSDTool", **kwargs): if simFlags.LArTB_H6Hec.get_Value(): - kwargs.setdefault("HECVolumes", ["LArMgr::LAr::HEC::Module::Depth::Absorber","LArMgr::LAr::HEC::Module::Depth::Slice::Electrode","LArMgr::LAr::HEC::Module::Depth::Slice::Electrode::Copper","LArMgr::LAr::HEC::Module::Depth::Slice::TieRod"]) + kwargs.setdefault("HECVolumes", [ + "LArMgr::LAr::HEC::Module::Depth::Absorber", + "LArMgr::LAr::HEC::Module::Depth::Slice::Electrode", + "LArMgr::LAr::HEC::Module::Depth::Slice::Electrode::Copper", + "LArMgr::LAr::HEC::Module::Depth::Slice::TieRod"]) if simFlags.LArTB_H6Emec.get_Value(): - kwargs.setdefault("EMECVolumes", ["LArMgr::LAr::EMEC::InnerWheel::Absorber","LArMgr::LAr::EMEC::InnerWheel::Electrode"]) + kwargs.setdefault("EMECVolumes", [ + "LArMgr::LAr::EMEC::InnerWheel::Absorber", + "LArMgr::LAr::EMEC::InnerWheel::Electrode"]) if simFlags.LArTB_H6Fcal.get_Value(): - kwargs.setdefault("FCAL1Volumes", ["LArMgr::LAr::FCAL::Module1::Absorber","LArMgr::LAr::FCAL::Module1::CableTrough"]) - kwargs.setdefault("FCAL2Volumes", ["LArMgr::LAr::FCAL::Module2::Rod","LArMgr::LAr::FCAL::Module2::Absorber","LArMgr::LAr::FCAL::Module2::CableTrough"]) - return CfgMgr.getLArG4H62004InactiveSDTool(name,**kwargs) + kwargs.setdefault("FCAL1Volumes", [ + "LArMgr::LAr::FCAL::Module1::Absorber", + "LArMgr::LAr::FCAL::Module1::CableTrough"]) + kwargs.setdefault("FCAL2Volumes", [ + "LArMgr::LAr::FCAL::Module2::Rod", + "LArMgr::LAr::FCAL::Module2::Absorber", + "LArMgr::LAr::FCAL::Module2::CableTrough"]) + return CfgMgr.LArG4__H62004InactiveSDTool(name,**kwargs) + +## Calculators + +#--------- +def getLArG4H6WarmTCCalculator(name="LArG4H6WarmTCCalculator", **kwargs): + kwargs.setdefault("OOTCut", 2.5*ns) + return CfgMgr.LArG4H6WarmTCCalculator(name, **kwargs) + +def getLArG4H6WarmTCCalculatorWTC_X(name="LArG4H6WarmTCCalculatorWTC_X", **kwargs): + kwargs.setdefault("isX", True) + kwargs.setdefault("isABS", False) + return getLArG4H6WarmTCCalculator(name, **kwargs) + +def getLArG4H6WarmTCCalculatorWTC_Y(name="LArG4H6WarmTCCalculatorWTC_Y", **kwargs): + kwargs.setdefault("isX", False) + kwargs.setdefault("isABS", False) + return getLArG4H6WarmTCCalculator(name, **kwargs) + +def getLArG4H6WarmTCCalculatorWTC_ABS(name="LArG4H6WarmTCCalculatorWTC_ABS", **kwargs): + kwargs.setdefault("isX", False) + kwargs.setdefault("isABS", True) + return getLArG4H6WarmTCCalculator(name, **kwargs) + +#---------- +def getLArG4H6COLDTCMod0Calculator(name="LArG4H6COLDTCMod0Calculator", **kwargs): + return CfgMgr.LArG4H6COLDTCMod0Calculator(name, **kwargs) + +def getFCALColdCalculator(name="FCALColdCalculator", **kwargs): + kwargs.setdefault("OOTCut", 10000.) #FIXME units of ns? + return getLArG4H6COLDTCMod0Calculator(name, **kwargs) + +#---------- +def getLArG4H6COLDTCMod0CalibCalculator(name="LArG4H6COLDTCMod0CalibCalculator", **kwargs): + return CfgMgr.LArG4H6COLDTCMod0CalibCalculator(name, **kwargs) + +def getLArG4H62004DeadCalibrationCalculator(name="LArG4H62004DeadCalibrationCalculator", **kwargs): + return CfgMgr.LArG4H62004DeadCalibrationCalculator(name, **kwargs) + +#---------- +def getLArFCALH62004CalibCalculatorBase(name="LArFCALH62004CalibCalculatorBase", **kwargs): + return CfgGetter.LArFCALH62004CalibCalculatorBase(name, **kwargs) + +def getLArFCAL1H62004CalibCalculator(name="LArFCAL1H62004CalibCalculator", **kwargs): + kwargs.setdefault("deltaX", 7.5*mm) + kwargs.setdefault("deltaY", 7.5*mm*math.sin(60*deg)) + kwargs.setdefault("FCalSampling", 1) + return getLArFCALH62004CalibCalculatorBase(name, **kwargs) + +def getLArFCAL2H62004CalibCalculator(name="LArFCAL2H62004CalibCalculator", **kwargs): + kwargs.setdefault("deltaX", 8.179*mm) + kwargs.setdefault("deltaY", 8.179*mm*math.sin(60*deg)) + kwargs.setdefault("FCalSampling", 2) + return getLArFCALH62004CalibCalculatorBase(name, **kwargs) + +#-------- +# Calculators from other packages +#-------- + +from LArG4EC.LArG4ECConfig import getEMECPosOuterWheelCalculator + +def getEMECPosOuterWheel_ECOR_GADJCalculator(name="EMECPosOuterWheel_ECOR_GADJCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 2) #LArG4::EMEC_ECOR_GADJ) + return getEMECPosOuterWheelCalculator(name, **kwargs) + +def getEMECPosOuterWheel_ECOR_GADJ_OLDCalculator(name="EMECPosOuterWheel_ECOR_GADJ_OLDCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 4) # LArG4::EMEC_ECOR_GADJ_OLD) + return getEMECPosOuterWheelCalculator(name, **kwargs) + +def getEMECPosOuterWheel_ECOR_GADJ_ECalculator(name="EMECPosOuterWheel_ECOR_GADJ_ECalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 5) # LArG4::EMEC_ECOR_GADJ_E) + return getEMECPosOuterWheelCalculator(name, **kwargs) + +def getEMECPosOuterWheel_ECOR_GADJ_SCalculator(name="EMECPosOuterWheel_ECOR_GADJ_SCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 6) # LArG4::EMEC_ECOR_GADJ_S) + return getEMECPosOuterWheelCalculator(name, **kwargs) + +def getEMECPosOuterWheel_ECOR_GADJ_SECalculator(name="EMECPosOuterWheel_ECOR_GADJ_SECalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 7) # LArG4::EMEC_ECOR_GADJ_SE) + return getEMECPosOuterWheelCalculator(name, **kwargs) + +def getEMECPosOuterWheel_ECOR_CHCLCalculator(name="EMECPosOuterWheel_ECOR_CHCLCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 3) # LArG4::::EMEC_ECOR_CHCL) + return getEMECPosOuterWheelCalculator(name, **kwargs) + +from LArG4EC.LArG4ECConfig import getEMECPosInnerWheelCalculator + +def getEMECPosInnerWheel_ECOR_GADJCalculator(name="EMECPosInnerWheel_ECOR_GADJCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 2) #LArG4::EMEC_ECOR_GADJ) + return getEMECPosInnerWheelCalculator(name, **kwargs) + +def getEMECPosInnerWheel_ECOR_GADJ_OLDCalculator(name="EMECPosInnerWheel_ECOR_GADJ_OLDCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 4) # LArG4::EMEC_ECOR_GADJ_OLD) + return getEMECPosInnerWheelCalculator(name, **kwargs) + +def getEMECPosInnerWheel_ECOR_GADJ_ECalculator(name="EMECPosInnerWheel_ECOR_GADJ_ECalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 5) # LArG4::EMEC_ECOR_GADJ_E) + return getEMECPosInnerWheelCalculator(name, **kwargs) + +def getEMECPosInnerWheel_ECOR_GADJ_SCalculator(name="EMECPosInnerWheel_ECOR_GADJ_SCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 6) # LArG4::EMEC_ECOR_GADJ_S) + return getEMECPosInnerWheelCalculator(name, **kwargs) + +def getEMECPosInnerWheel_ECOR_GADJ_SECalculator(name="EMECPosInnerWheel_ECOR_GADJ_SECalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 7) # LArG4::EMEC_ECOR_GADJ_SE) + return getEMECPosInnerWheelCalculator(name, **kwargs) + +def getEMECPosInnerWheel_ECOR_CHCLCalculator(name="EMECPosInnerWheel_ECOR_CHCLCalculator", **kwargs): + kwargs.setdefault("EnergyCorrection", 3) # LArG4::::EMEC_ECOR_CHCL) + return getEMECPosInnerWheelCalculator(name, **kwargs) + +from LArG4HEC.LArG4HECConfig import getLArHECLocalCalculator, getLocalCalibrationCalculator + +def getLArH62004HECLocalCalculator(name="LArH62004HECLocalCalculator", **kwargs): + kwargs.setdefaults("OOCut", 10000.)(name, **kwargs) + + kwargs.setdefaults("IsX", True) + return getLArHECLocalCalculator(name, **kwargs) + +def getLocalCalibrationInactiveCalculator(name="LocalCalibrationInactiveCalculator", **kwargs): + from LArG4HEC import HECGeometryType + kwargs.setdefault("GeometryType", HECGeometryType.kWheelInactive) + return getLocalCalibrationCalculator(name, **kwargs) + +def getLocalCalibrationActiveCalculator(name="LocalCalibrationActiveCalculator", **kwargs): + from LArG4HEC import HECGeometryType + kwargs.setdefault("GeometryType", HECGeometryType.kWheelActive) + return getLocalCalibrationCalculator(name, **kwargs) + diff --git a/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfigDb.py b/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfigDb.py index fb4f895f3d1a..976aee25cd65 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfigDb.py +++ b/LArCalorimeter/LArG4/LArG4H6SD/python/LArG4H6SDConfigDb.py @@ -33,3 +33,33 @@ addTool("LArG4H6SD.LArG4H6SDConfig.getLArG4H62004ActiveSDTool", "LArG4H62004Acti addTool("LArG4H6SD.LArG4H6SDConfig.getLArG4H62004DeadSDTool", "LArG4H62004DeadSDTool") addTool("LArG4H6SD.LArG4H6SDConfig.getLArG4H62004InactiveSDTool", "LArG4H62004InactiveSDTool") +# Calculators +addService("LArG4H6SD.LArG4H6SDConfig.getLArG4H6WarmTCCalculatorWTC_X", "LArG4H6WarmTCCalculatorWTC_X") +addService("LArG4H6SD.LArG4H6SDConfig.getLArG4H6WarmTCCalculatorWTC_Y", "LArG4H6WarmTCCalculatorWTC_Y") +addService("LArG4H6SD.LArG4H6SDConfig.getLArG4H6WarmTCCalculatorWTC_ABS", "LArG4H6WarmTCCalculatorWTC_ABS") +addService("LArG4H6SD.LArG4H6SDConfig.getLArG4H6COLDTCMod0Calculator", "LArG4H6COLDTCMod0Calculator") +addService("LArG4H6SD.LArG4H6SDConfig.getFCALColdCalculator", "FCALColdCalculator") + +addService("LArG4H6SD.LArG4H6SDConfig.getLArG4H6COLDTCMod0CalibCalculator", "LArG4H6COLDTCMod0CalibCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getLArG4H62004DeadCalibrationCalculator", "LArG4H62004DeadCalibrationCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getLArFCAL1H62004CalibCalculator", "LArFCAL1H62004CalibCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getLArFCAL2H62004CalibCalculator", "LArFCAL2H62004CalibCalculator") + +# Calculators from other packages +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosOuterWheel_ECOR_GADJCalculator", "EMECPosOuterWheel_ECOR_GADJCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosOuterWheel_ECOR_GADJ_OLDCalculator", "EMECPosOuterWheel_ECOR_GADJ_OLDCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosOuterWheel_ECOR_GADJ_ECalculator", "EMECPosOuterWheel_ECOR_GADJ_ECalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosOuterWheel_ECOR_GADJ_SCalculator", "EMECPosOuterWheel_ECOR_GADJ_SCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosOuterWheel_ECOR_GADJ_SECalculator", "EMECPosOuterWheel_ECOR_GADJ_SECalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosOuterWheel_ECOR_CHCLCalculator", "EMECPosOuterWheel_ECOR_CHCLCalculator") + +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosInnerWheel_ECOR_GADJCalculator", "EMECPosInnerWheel_ECOR_GADJCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosInnerWheel_ECOR_GADJ_OLDCalculator", "EMECPosInnerWheel_ECOR_GADJ_OLDCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosInnerWheel_ECOR_GADJ_ECalculator", "EMECPosInnerWheel_ECOR_GADJ_ECalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosInnerWheel_ECOR_GADJ_SCalculator", "EMECPosInnerWheel_ECOR_GADJ_SCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosInnerWheel_ECOR_GADJ_SECalculator", "EMECPosInnerWheel_ECOR_GADJ_SECalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getEMECPosInnerWheel_ECOR_CHCLCalculator", "EMECPosInnerWheel_ECOR_CHCLCalculator") + +addService("LArG4H6SD.LArG4H6SDConfig.getLArH62004HECLocalCalculator","LArH62004HECLocalCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getLocalCalibrationInactiveCalculator", "LocalCalibrationInactiveCalculator") +addService("LArG4H6SD.LArG4H6SDConfig.getLocalCalibrationActiveCalculator", "LocalCalibrationActiveCalculator") \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.cc new file mode 100644 index 000000000000..d189b6502ebc --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.cc @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004ActiveSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H62004ActiveSDTool::H62004ActiveSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : H62004CalibSDTool(type, name, parent) + , m_hitCollName("LArCalibrationHitActive") + , m_emepiwcalc("EMECPosInnerWheelCalibrationCalculator", name) + , m_heccalc("LocalCalibrationActiveCalculator", name) + , m_fcal1calc("LArFCAL1H62004CalibCalculator", name) + , m_fcal2calc("LArFCAL2H62004CalibCalculator", name) + , m_fcalcoldcalc("LArG4H6COLDTCMod0CalibCalculator", name) + { + declareProperty("EMECPosIWCalibrationCalculator", m_emepiwcalc); + declareProperty("HECWheelActiveCalculator", m_heccalc); + declareProperty("FCAL1CalibCalculator", m_fcal1calc); + declareProperty("FCAL2CalibCalculator", m_fcal2calc); + declareProperty("FCALCOLDMod0CalibCalculator", m_fcalcoldcalc); + declareProperty("EMECVolumes", m_emecVolumes); + declareProperty("HECVolumes", m_hecVolumes); + declareProperty("FCAL1Volumes", m_fcal1Volumes); + declareProperty("FCAL2Volumes", m_fcal2Volumes); + declareProperty("FCALColdVolumes", m_fcalColdVolumes); + } + + StatusCode H62004ActiveSDTool::initializeCalculators() + { + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcalcoldcalc.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H62004ActiveSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("LArH62004ActiveSDWrapper", m_hitCollName); + + // Add the SDs. + // Lots of singleton calculators !!! + + if (m_emecVolumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "EMEC::InnerModule::Calibration::H6", &*m_emepiwcalc, m_emecVolumes ) ); + } + if (m_hecVolumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "HEC::Module::Depth::Slice::Local::Calibration::H6", &*m_heccalc, m_hecVolumes ) ); + } + if (m_fcal1Volumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::FCAL::Module1::Gap::Calibration::H6", &*m_fcal1calc, m_fcal1Volumes ) ); + } + if (m_fcal2Volumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::FCAL::Module2::Gap::Calibration::H6", &*m_fcal2calc, m_fcal2Volumes ) ); + } + if (m_fcalColdVolumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::FCAL::ColdTC::Gap::Calibration::H6", &*m_fcalcoldcalc, m_fcalColdVolumes ) ); + } + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.h new file mode 100644 index 000000000000..c405c6c2d6b9 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004ActiveSDTool.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H62004SD_H62004ACTIVESDTOOL_H +#define LARG4H62004SD_H62004ACTIVESDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Local includes +#include "H62004CalibSDTool.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class H62004ActiveSDTool + /// @brief Tool for constructing H62004 calib SDs for active material. + /// + /// Based on the previous LArG4H62004ActiveSDTool implementation. + /// + /// This implementation uses the LAr SD wrapper design for managing multiple + /// SDs when running multi-threaded. See ATLASSIM-2606 for discussions. + /// + class H62004ActiveSDTool : public H62004CalibSDTool + { + + public: + + /// Constructor + H62004ActiveSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + ServiceHandle<ILArCalibCalculatorSvc> m_emepiwcalc; + ServiceHandle<ILArCalibCalculatorSvc> m_heccalc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal1calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal2calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcalcoldcalc; + + /// @name SD volumes + /// @{ + std::vector<std::string> m_emecVolumes; + std::vector<std::string> m_hecVolumes; + std::vector<std::string> m_fcal1Volumes; + std::vector<std::string> m_fcal2Volumes; + std::vector<std::string> m_fcalColdVolumes; + /// @} + + }; // class H62004ActiveSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.cc new file mode 100644 index 000000000000..1dc45118c8bb --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.cc @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004CalibSDTool.h" + +// Framework utilities +#include "CxxUtils/make_unique.h" + +// LArG4 includes +#include "LArG4Code/VolumeUtils.h" + +// Local includes +#include "LArG4H62004CalibSD.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Tool constructor + //--------------------------------------------------------------------------- + H62004CalibSDTool::H62004CalibSDTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : CalibSDTool(type, name, parent) + {} + + //--------------------------------------------------------------------------- + // Create one SD + //--------------------------------------------------------------------------- + std::unique_ptr<LArG4CalibSD> + H62004CalibSDTool::makeOneSD(const std::string& sdName, ILArCalibCalculatorSvc* calc, + const std::vector<std::string>& volumes) const + { + ATH_MSG_VERBOSE( name() << " makeOneSD" ); + + // Parse the wildcard patterns for existing volume names + auto parsedVolumes = findLogicalVolumes(volumes, msg()); + + // Create the simple SD + auto sd = CxxUtils::make_unique<LArG4H62004CalibSD>(sdName, calc, m_doPID); + sd->setupHelpers(m_larEmID, m_larFcalID, m_larHecID, m_larMiniFcalID, m_caloDmID); + + // Assign the volumes to the SD + if( assignSD( sd.get(), parsedVolumes ).isFailure() ) { + throw GaudiException("Failed to assign sd: " + sdName, + name(), StatusCode::FAILURE); + } + return std::move(sd); + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.h new file mode 100644 index 000000000000..97d62c5ddc78 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004CalibSDTool.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H6SD_H62004CALIBSDTOOL_H +#define LARG4H6SD_H62004CALIBSDTOOL_H + +// LAr G4 includes +#include "LArG4Code/CalibSDTool.h" + +namespace LArG4 +{ + + /// @class H62004CalibSDTool + /// @brief Tool base class for LAr H6 2004 calibration SD tools. + /// + /// This tool overrides the SD creation from CalibSDTool to create + /// the custom LArG4H62004CalibSD objects. + /// + /// See LArG4::CalibSDTool documentation for more details. + /// + /// @author Steve Farrell <Steven.Farrell@cern.ch> + /// + class H62004CalibSDTool : public CalibSDTool + { + public: + /// Constructor + H62004CalibSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + protected: + /// Override helper method to create one SD + std::unique_ptr<LArG4CalibSD> + makeOneSD(const std::string& name, ILArCalibCalculatorSvc* calc, + const std::vector<std::string>& volumes) const; + }; + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.cc new file mode 100644 index 000000000000..9f654e6e0be6 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.cc @@ -0,0 +1,74 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004DeadSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" +#include "CaloG4Sim/EscapedEnergyRegistry.h" +#include "LArG4Code/EscapedEnergyProcessing.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H62004DeadSDTool::H62004DeadSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : H62004CalibSDTool(type, name, parent) + , m_hitCollName("LArCalibrationHitDeadMaterial") + , m_calculator("LArG4H62004DeadCalibrationCalculator", name) + { + declareProperty("doEscapedEnergy", m_do_eep=false); + declareProperty("Calculator", m_calculator); + } + + StatusCode H62004DeadSDTool::initializeCalculators() + { + ATH_CHECK(m_calculator.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H62004DeadSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("LArH62004DeadSDWrapper", m_hitCollName); + + // Add the SDs + sdWrapper->addSD( makeOneSD( "LArDead::Dead::H6", &*m_calculator, m_volumeNames ) ); + + // Take care of the default material + if (m_do_eep) { + const std::vector<std::string> noVolumes; + auto uninstSD = makeOneSD("Default::Dead::Uninstrumented::Calibration::H6", &*m_calculator, noVolumes); + + // Initialize the escaped energy processing for LAr volumes. + // This is from initialize processing in the former LArG4CalibSD. + // I still think we can do better than this, though. + // FIXME: I don't think this is thread safe!! + ATH_MSG_DEBUG("Creating EscapedEnergyProcessing and adding to registry"); + CaloG4::VEscapedEnergyProcessing* eep = + new EscapedEnergyProcessing( uninstSD.get() ); + CaloG4::EscapedEnergyRegistry* registry = + CaloG4::EscapedEnergyRegistry::GetInstance(); + registry->AddAndAdoptProcessing( "LAr::", eep ); + CaloG4::VEscapedEnergyProcessing* eep1 = + new EscapedEnergyProcessing( uninstSD.get() ); + registry->AddAndAdoptProcessing( "LArMgr::", eep1 ); + CaloG4::VEscapedEnergyProcessing* eep2 = + new EscapedEnergyProcessing( uninstSD.get() ); + registry->AddAndAdoptProcessing( "LAr", eep2 ); + + sdWrapper->addSD( std::move(uninstSD) ); + } + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.h new file mode 100644 index 000000000000..fc821b65ae41 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004DeadSDTool.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H62004SD_H62004DEADSDTOOL_H +#define LARG4H62004SD_H62004DEADSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Local includes +#include "H62004CalibSDTool.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class H62004DeadSDTool + /// @brief Tool for constructing H62004 calib SDs for dead material. + /// + /// Based on the previous LArG4H62004DeadSDTool implementation. + /// + /// This implementation uses the LAr SD wrapper design for managing multiple + /// SDs when running multi-threaded. See ATLASSIM-2606 for discussions. + /// + class H62004DeadSDTool : public H62004CalibSDTool + { + + public: + + /// Constructor + H62004DeadSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + ServiceHandle<ILArCalibCalculatorSvc> m_calculator; + /// Do we add the escaped energy processing? + /// This is only in "mode 1" (Tile+LAr), not in "DeadLAr" mode + bool m_do_eep; + + }; // class H62004DeadSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.cc new file mode 100644 index 000000000000..e9fa25fa4548 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.cc @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004EMECSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H62004EMECSDTool::H62004EMECSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : H62004SimpleSDTool(type, name, parent) + , m_hitCollName("LArHitEMEC") + , m_calculator("EMECPosInnerWheel_ECOR_GADJCalculator", name) + { + declareProperty("Calculator", m_calculator); + } + + StatusCode H62004EMECSDTool::initializeCalculators() + { + ATH_CHECK(m_calculator.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H62004EMECSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArH62004EMECSDWrapper", m_hitCollName); + + // Add the SDs. In this case there is actually only one SD. + sdWrapper->addSD( + makeOneSD( "LAr::EMEC::InnerModule::H6", &*m_calculator, m_volumeNames ) + ); + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.h new file mode 100644 index 000000000000..a140470a86fb --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004EMECSDTool.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H62004SD_H62004EMECSDTOOL_H +#define LARG4H62004SD_H62004EMECSDTOOL_H + +// System includes +#include <string> + +// Local includes +#include "H62004SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class H62004EMECSDTool + /// @brief Tool for constructing H62004 SDs for EMEC. + /// + /// Based on the previous LArG4H62004EMECSDTool implementation. + /// + /// This implementation uses the LAr SD wrapper design for managing multiple + /// SDs when running multi-threaded. See ATLASSIM-2606 for discussions. + /// + class H62004EMECSDTool : public H62004SimpleSDTool + { + + public: + + /// Constructor + H62004EMECSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + ServiceHandle<ILArCalculatorSvc> m_calculator; + }; // class H62004EMECSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.cc new file mode 100644 index 000000000000..02f6915b8768 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.cc @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004FCALSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H62004FCALSDTool::H62004FCALSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : H62004SimpleSDTool(type, name, parent) + , m_hitCollName("LArHitFCAL") + , m_fcal1calc("FCAL1Calculator", name) + , m_fcal2calc("FCAL2Calculator", name) + , m_fcalcoldcalc("FCALColdCalculator", name) + { + declareProperty("FCAL1Calculator", m_fcal1calc); + declareProperty("FCAL2Calculator", m_fcal2calc); + declareProperty("FCALColdCalculator", m_fcalcoldcalc); + declareProperty("FCAL1Volumes", m_fcal1Volumes); + declareProperty("FCAL2Volumes", m_fcal2Volumes); + declareProperty("FCALColdVolumes", m_fcalColdVolumes); + } + + StatusCode H62004FCALSDTool::initializeCalculators() + { + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcalcoldcalc.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H62004FCALSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArH62004FCALSDWrapper", m_hitCollName); + + // Add the SDs + sdWrapper->addSD( makeOneSD( "LAr::FCAL::Module1::Gap::H6", &*m_fcal1calc, m_fcal1Volumes ) ); + sdWrapper->addSD( makeOneSD( "LAr::FCAL::Module2::Gap::H6", &*m_fcal2calc, m_fcal2Volumes ) ); + sdWrapper->addSD( makeOneSD("LAr::FCAL::ColdTC::H6", &*m_fcalcoldcalc, m_fcalColdVolumes) ); + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.h new file mode 100644 index 000000000000..794e31033a9c --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004FCALSDTool.h @@ -0,0 +1,60 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H62004SD_H62004FCALSDTOOL_H +#define LARG4H62004SD_H62004FCALSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Local includes +#include "H62004SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class H62004FCALSDTool + /// @brief Tool for constructing H62004 SDs for FCAL. + /// + /// Based on the previous LArG4H62004FCALSDTool implementation. + /// + /// This implementation uses the LAr SD wrapper design for managing multiple + /// SDs when running multi-threaded. See ATLASSIM-2606 for discussions. + /// + class H62004FCALSDTool : public H62004SimpleSDTool + { + + public: + + /// Constructor + H62004FCALSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + ServiceHandle<ILArCalculatorSvc> m_fcal1calc; + ServiceHandle<ILArCalculatorSvc> m_fcal2calc; + ServiceHandle<ILArCalculatorSvc> m_fcalcoldcalc; + /// @name SD volumes + /// @{ + std::vector<std::string> m_fcal1Volumes; + std::vector<std::string> m_fcal2Volumes; + std::vector<std::string> m_fcalColdVolumes; + /// @} + + }; // class H62004FCALSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.cc new file mode 100644 index 000000000000..02944de5c965 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.cc @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004HECSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H62004HECSDTool::H62004HECSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : H62004SimpleSDTool(type, name, parent) + , m_hitCollName("LArHitHEC") + , m_calculator("LArH62004HECLocalCalculator", name) + { + declareProperty("Calculator", m_calculator); + } + + StatusCode H62004HECSDTool::initializeCalculators() + { + ATH_CHECK(m_calculator.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H62004HECSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArH62004HECSDWrapper", m_hitCollName); + + // Add the SDs. In this case there is actually only one SD. + sdWrapper->addSD( makeOneSD( "LAr::HEC::Module::Depth::Slice::Local::H6", &*m_calculator, m_volumeNames ) ); + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.h new file mode 100644 index 000000000000..b2b71d772598 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004HECSDTool.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H62004SD_H62004HECSDTOOL_H +#define LARG4H62004SD_H62004HECSDTOOL_H + +// System includes +#include <string> + +// Local includes +#include "H62004SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" +namespace LArG4 +{ + + /// @class H62004HECSDTool + /// @brief Tool for constructing H62004 SDs for HEC. + /// + /// Based on the previous LArG4H62004HECSDTool implementation. + /// + /// This implementation uses the LAr SD wrapper design for managing multiple + /// SDs when running multi-threaded. See ATLASSIM-2606 for discussions. + /// + class H62004HECSDTool : public H62004SimpleSDTool + { + + public: + + /// Constructor + H62004HECSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + ServiceHandle<ILArCalculatorSvc> m_calculator; + }; // class H62004HECSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.cc new file mode 100644 index 000000000000..fe6c8eae3dd6 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.cc @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004InactiveSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H62004InactiveSDTool::H62004InactiveSDTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : H62004CalibSDTool(type, name, parent), + m_hitCollName("LArCalibrationHitInactive") + , m_emepiwcalc("EMECPosInnerWheelCalibrationCalculator", name) + , m_heccalc("LocalCalibrationInactiveCalculator", name) + , m_fcal1calc("LArFCAL1H62004CalibCalculator", name) + , m_fcal2calc("LArFCAL2H62004CalibCalculator", name) + { + declareProperty("EMECVolumes", m_emecVolumes); + declareProperty("HECVolumes", m_hecVolumes); + declareProperty("FCAL1Volumes", m_fcal1Volumes); + declareProperty("FCAL2Volumes", m_fcal2Volumes); + declareProperty("EMECPosIWCalibrationCalculator", m_emepiwcalc); + declareProperty("HECWheelInactiveCalculator", m_heccalc); + declareProperty("FCAL1CalibCalculator", m_fcal1calc); + declareProperty("FCAL2CalibCalculator", m_fcal2calc); + } + + StatusCode H62004InactiveSDTool::initializeCalculators() + { + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H62004InactiveSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("LArH62004InactiveSDWrapper", m_hitCollName); + + // Add the SDs. + // Lots of singleton calculators !!! + + if (m_emecVolumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::EMEC::InnerModule::Inactive::H6", &*m_emepiwcalc, m_emecVolumes ) ); + } + if (m_hecVolumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::HEC::Local::Inactive::H6", &*m_heccalc, m_hecVolumes ) ); + } + if (m_fcal1Volumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::FCAL::Inactive1::H6", &*m_fcal1calc, m_fcal1Volumes ) ); + } + if (m_fcal2Volumes.size() > 0) { + sdWrapper->addSD( makeOneSD( + "LAr::FCAL::Inactive2::H6", &*m_fcal2calc, m_fcal2Volumes ) ); + } + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.h new file mode 100644 index 000000000000..6389a0f16749 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004InactiveSDTool.h @@ -0,0 +1,63 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H62004SD_H62004INACTIVESDTOOL_H +#define LARG4H62004SD_H62004INACTIVESDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Local includes +#include "H62004CalibSDTool.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class H62004InactiveSDTool + /// @brief Tool for constructing H62004 calib SDs for inactive material. + /// + /// Based on the previous LArG4H62004InactiveSDTool implementation. + /// + /// This implementation uses the LAr SD wrapper design for managing multiple + /// SDs when running multi-threaded. See ATLASSIM-2606 for discussions. + /// + class H62004InactiveSDTool : public H62004CalibSDTool + { + + public: + + /// Constructor + H62004InactiveSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + ServiceHandle<ILArCalibCalculatorSvc>m_emepiwcalc; + ServiceHandle<ILArCalibCalculatorSvc>m_heccalc; + ServiceHandle<ILArCalibCalculatorSvc>m_fcal1calc; + ServiceHandle<ILArCalibCalculatorSvc>m_fcal2calc; + + /// @name SD volumes + /// @{ + std::vector<std::string> m_emecVolumes; + std::vector<std::string> m_hecVolumes; + std::vector<std::string> m_fcal1Volumes; + std::vector<std::string> m_fcal2Volumes; + /// @} + + }; // class H62004InactiveSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.cc new file mode 100644 index 000000000000..7fa84af66e0f --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.cc @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H62004SimpleSDTool.h" + +// Framework utilities +#include "CxxUtils/make_unique.h" + +// LArG4 includes +#include "LArG4Code/VolumeUtils.h" + +// Local includes +#include "LArG4H62004SD.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Tool constructor + //--------------------------------------------------------------------------- + H62004SimpleSDTool::H62004SimpleSDTool(const std::string& type, + const std::string& name, + const IInterface* parent) + : SimpleSDTool(type, name, parent) + {} + + //--------------------------------------------------------------------------- + // Create one SD + //--------------------------------------------------------------------------- + std::unique_ptr<LArG4SimpleSD> + H62004SimpleSDTool::makeOneSD(const std::string& sdName, ILArCalculatorSvc* calc, + const std::vector<std::string>& volumes) const + { + ATH_MSG_VERBOSE( name() << " makeOneSD" ); + + // Parse the wildcard patterns for existing volume names + auto parsedVolumes = findLogicalVolumes(volumes, msg()); + + // Create the simple SD + auto sd = CxxUtils::make_unique<LArG4H62004SD> + (sdName, calc, m_timeBinType, m_timeBinWidth); + sd->setupHelpers(m_larEmID, m_larFcalID, m_larHecID, m_larMiniFcalID); + + // Assign the volumes to the SD + if( assignSD( sd.get(), parsedVolumes ).isFailure() ) { + throw GaudiException("Failed to assign sd: " + sdName, + name(), StatusCode::FAILURE); + } + return std::move(sd); + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.h new file mode 100644 index 000000000000..b7b8e37a4d4a --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/H62004SimpleSDTool.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H6SD_H62004SIMPLESDTOOL_H +#define LARG4H6SD_H62004SIMPLESDTOOL_H + +// LAr G4 includes +#include "LArG4Code/SimpleSDTool.h" + +namespace LArG4 +{ + + /// @class H62004SimpleSDTool + /// @brief Tool base class for LAr H6 2004 simple SD tools. + /// + /// This tool overrides the SD creation from SimpleSDTool to create + /// the custom LArG4H62004SimpleSD objects. + /// + /// See LArG4::SimpleSDTool documentation for more details. + /// + /// @author Steve Farrell <Steven.Farrell@cern.ch> + /// + class H62004SimpleSDTool : public SimpleSDTool + { + public: + /// Constructor + H62004SimpleSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + protected: + /// Override helper method to create one SD + std::unique_ptr<LArG4SimpleSD> + makeOneSD(const std::string& name, ILArCalculatorSvc* calc, + const std::vector<std::string>& volumes) const; + }; + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.cc deleted file mode 100644 index 1b25bcd559c9..000000000000 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArFCAL1H62004CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" - -#include <algorithm> - -LArFCAL1H62004CalibCalculator* LArFCAL1H62004CalibCalculator::m_calculator = 0; - -LArFCAL1H62004CalibCalculator* LArFCAL1H62004CalibCalculator::GetCalculator() { - if (m_calculator == 0 ) - { - m_calculator = new LArFCAL1H62004CalibCalculator(); - } - return m_calculator; -} - -LArFCAL1H62004CalibCalculator::LArFCAL1H62004CalibCalculator() { - - m_deltaX = 7.5*CLHEP::mm; - m_deltaY = 7.5*CLHEP::mm*sin(60*CLHEP::deg); - - m_FCalSampling = 1; -} - -LArFCAL1H62004CalibCalculator::~LArFCAL1H62004CalibCalculator(){} diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.h deleted file mode 100644 index d9541bee9f8a..000000000000 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL1H62004CalibCalculator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArFCAL1H62004CalibCalculator_H -#define LArFCAL1H62004CalibCalculator_H - -#include "LArFCALH62004CalibCalculatorBase.h" - -#include "globals.hh" - - -class LArFCAL1H62004CalibCalculator : public LArFCALH62004CalibCalculatorBase { - - public: - - static LArFCAL1H62004CalibCalculator* GetCalculator(); - - virtual ~LArFCAL1H62004CalibCalculator(); - - protected: - - LArFCAL1H62004CalibCalculator(); - private: - - static LArFCAL1H62004CalibCalculator* m_calculator; - -}; -#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.cc deleted file mode 100644 index 72bed248c47a..000000000000 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArFCAL2H62004CalibCalculator.h" -#include "LArG4FCAL/LArFCALCalibCalculatorBase.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" - -#include <algorithm> - -LArFCAL2H62004CalibCalculator* LArFCAL2H62004CalibCalculator::m_calculator = 0; - -LArFCAL2H62004CalibCalculator* LArFCAL2H62004CalibCalculator::GetCalculator() { - if (m_calculator == 0 ) - { - m_calculator = new LArFCAL2H62004CalibCalculator(); - } - return m_calculator; -} - -LArFCAL2H62004CalibCalculator::LArFCAL2H62004CalibCalculator() { - - m_deltaX = 8.179*CLHEP::mm; - m_deltaY = 8.179*CLHEP::mm*sin(60*CLHEP::deg); - - m_FCalSampling = 2; -} - -LArFCAL2H62004CalibCalculator::~LArFCAL2H62004CalibCalculator(){} diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.h deleted file mode 100644 index 5e4341cba494..000000000000 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCAL2H62004CalibCalculator.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArFCAL2H62004CalibCalculator_H -#define LArFCAL2H62004CalibCalculator_H - -#include "LArFCALH62004CalibCalculatorBase.h" - -#include "globals.hh" - - -class LArFCAL2H62004CalibCalculator : public LArFCALH62004CalibCalculatorBase { - - public: - - static LArFCAL2H62004CalibCalculator* GetCalculator(); - - virtual ~LArFCAL2H62004CalibCalculator(); - - protected: - - LArFCAL2H62004CalibCalculator(); - private: - - static LArFCAL2H62004CalibCalculator* m_calculator; - - }; -#endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.cc index 7477fec3b6b2..e045b0d7fd5b 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.cc @@ -3,7 +3,7 @@ */ #include "LArFCALH62004CalibCalculatorBase.h" -#include "LArG4FCAL/LArFCALCalculatorBase.h" +//#include "LArG4FCAL/LArFCALCalculatorBase.h" #include "LArG4Code/LArG4Identifier.h" @@ -13,8 +13,10 @@ #include "PathResolver/PathResolver.h" #include "RDBAccessSvc/IRDBAccessSvc.h" #include "RDBAccessSvc/IRDBRecord.h" +#include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" #include "GeoModelUtilities/DecodeVersionKey.h" +#include "LArReadoutGeometry/FCAL_ChannelMap.h" // Geant4 includes #include "G4LogicalVolume.hh" @@ -47,18 +49,18 @@ namespace CaloG4 { namespace { -inline -G4int etaToBin1 (G4double eta, G4double eta0) -{ - return static_cast<G4int> ((eta - eta0) * (1./0.1)); -} + inline + G4int etaToBin1 (G4double eta, G4double eta0) + { + return static_cast<G4int> ((eta - eta0) * (1./0.1)); + } -inline -G4int etaToBin2 (G4double eta, G4double eta0) -{ - return static_cast<G4int> ((eta - eta0) * (1./0.2)); -} + inline + G4int etaToBin2 (G4double eta, G4double eta0) + { + return static_cast<G4int> ((eta - eta0) * (1./0.2)); + } } @@ -66,255 +68,263 @@ G4int etaToBin2 (G4double eta, G4double eta0) // constructor // -LArFCALH62004CalibCalculatorBase::LArFCALH62004CalibCalculatorBase() - : m_deltaX(0), - m_deltaY(0), - m_FCalSampling(0), - m_identifier(LArG4Identifier()), - m_OOTcut(0), - m_time(0), - m_isInTime(0) - { - - StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); - if (detStore->retrieve(m_ChannelMap)==StatusCode::FAILURE) { - - } - - ISvcLocator *svcLocator = Gaudi::svcLocator(); - IRDBAccessSvc* rdbAccess; - IGeoModelSvc * geoModel; - - if(svcLocator->service ("GeoModelSvc",geoModel) == StatusCode::FAILURE) - throw std::runtime_error("Error in FCALConstruction, cannot access GeoModelSvc"); - if(svcLocator->service ("RDBAccessSvc",rdbAccess) == StatusCode::FAILURE) - throw std::runtime_error("Error in FCALConstruction, cannot access RDBAccessSvc"); - DecodeVersionKey larVersionKey(geoModel, "LAr"); - - m_fcalMod = rdbAccess->getRecordset("FCalMod", larVersionKey.tag(),larVersionKey.node()); - if (m_fcalMod->size()==0) { - m_fcalMod=rdbAccess->getRecordset("FCalMod", "FCalMod-00"); - if (m_fcalMod->size()==0) { - throw std::runtime_error("Error getting FCAL Module parameters from database"); - } - } - double startZFCal1 = (*m_fcalMod)[0]->getDouble("STARTPOSITION"); //466.85 * cm; - double startZFCal3 = (*m_fcalMod)[2]->getDouble("STARTPOSITION"); //560.28 * cm; - double depthZFCal3 = (*m_fcalMod)[2]->getDouble("FULLMODULEDEPTH"); - double stopZFCal3 = startZFCal3 + depthZFCal3; - double halfDepth = (stopZFCal3 - startZFCal1)/2.; - m_Zshift = startZFCal1 + halfDepth; - +LArFCALH62004CalibCalculatorBase::LArFCALH62004CalibCalculatorBase(const std::string& name, ISvcLocator * pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_deltaX(0.0) + , m_deltaY(0.0) + , m_FCalSampling(0) + , m_ChannelMap(nullptr) + , m_fcalMod(nullptr) + , m_Zshift(0.0) +{ + declareProperty("deltaX" , m_deltaX); + declareProperty("deltaY" , m_deltaY); + declareProperty("FCalSampling" , m_FCalSampling); + //declareProperty("Zshift" , m_Zshift); +} +StatusCode LArFCALH62004CalibCalculatorBase::initialize() +{ + StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); + if (detStore->retrieve(m_ChannelMap)==StatusCode::FAILURE) { + + } + + ISvcLocator *svcLocator = Gaudi::svcLocator(); + IRDBAccessSvc* rdbAccess; + IGeoModelSvc * geoModel; + + if(svcLocator->service ("GeoModelSvc",geoModel) == StatusCode::FAILURE) + throw std::runtime_error("Error in FCALConstruction, cannot access GeoModelSvc"); + if(svcLocator->service ("RDBAccessSvc",rdbAccess) == StatusCode::FAILURE) + throw std::runtime_error("Error in FCALConstruction, cannot access RDBAccessSvc"); + DecodeVersionKey larVersionKey(geoModel, "LAr"); + + m_fcalMod = rdbAccess->getRecordset("FCalMod", larVersionKey.tag(),larVersionKey.node()); + if (m_fcalMod->size()==0) { + m_fcalMod=rdbAccess->getRecordset("FCalMod", "FCalMod-00"); + if (m_fcalMod->size()==0) { + throw std::runtime_error("Error getting FCAL Module parameters from database"); + } + } + double startZFCal1 = (*m_fcalMod)[0]->getDouble("STARTPOSITION"); //466.85 * cm; + double startZFCal3 = (*m_fcalMod)[2]->getDouble("STARTPOSITION"); //560.28 * cm; + double depthZFCal3 = (*m_fcalMod)[2]->getDouble("FULLMODULEDEPTH"); + double stopZFCal3 = startZFCal3 + depthZFCal3; + double halfDepth = (stopZFCal3 - startZFCal1)/2.; + m_Zshift = startZFCal1 + halfDepth; + + return StatusCode::SUCCESS; } LArFCALH62004CalibCalculatorBase::~LArFCALH62004CalibCalculatorBase() { } - - -G4bool LArFCALH62004CalibCalculatorBase::Process(const G4Step* a_step, - const eCalculatorProcessing a_process) { - // First, get the energy. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - // find the space point for this deposit - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - // S.M.: this does not work - there are some volumes inside the - // FCAL which have their own local coordinate system and - // just result in (~0,~0) local coordinates. I think they should - // be treated as absorbers ... so I take the original coordinates - // instead ... - - // P.S. We sould go to FCAL mother volume, and work there - - // S.M. // get LOCAL (u,v) coordinates! - // S.M. G4Navigator* theNavigator = - // S.M. G4TransportationManager::GetTransportationManager()-> - // S.M. GetNavigatorForTracking(); - // S.M. G4ThreeVector theLocalPoint = theNavigator-> - // S.M. GetGlobalToLocalTransform(). - // S.M. TransformPoint(p); - - // Find a transformation to a module coordinate system - G4TouchableHistory* theTouchable = - (G4TouchableHistory*) (pre_step_point->GetTouchable()); - - G4String volumeName = theTouchable->GetVolume()->GetName() ; - int modVol=theTouchable->GetHistoryDepth(); - // Assume Gap as a most often case - get it through copy number - if(volumeName[volumeName.size() - 3] == 'G') { - modVol -= 2; - } else if(volumeName[volumeName.size() - 8] == 'A') { // second most often volume - modVol -= 1; - } else if(volumeName[volumeName.size() - 11] == 'C') { - modVol -= 2; - } else if(volumeName[volumeName.size() - 3] == 'R') { - modVol -= 3; - } else { - std::cout<<"Unknown volume ?? "<< volumeName << std::endl; - } - const G4AffineTransform moduleTransform= theTouchable->GetHistory()->GetTransform(modVol); - G4ThreeVector theLocalPoint = moduleTransform.TransformPoint(p); - - - // we've shifted the endcap, we have to project the geometry to a - // different point). - G4double pointZ = p.z(); - - int etaIndex,phiIndex; - float x = theLocalPoint.x(),y=theLocalPoint.y(); - int sampling = m_FCalSampling; - bool ok = m_ChannelMap->getTileID(sampling, - x, - y, - etaIndex, - phiIndex); - - - G4ThreeVector pointShift(x, y, theLocalPoint.z() + m_Zshift); - // zSide is negative if z<0. - G4int zSide = 2; - if (pointZ < 0.) zSide = -zSide; - - m_identifier.clear(); - if (ok) { - // we have a active or non-active hit inside the FCal - G4int sampling = m_FCalSampling; - - - // Append the values to the empty identifier. - m_identifier << 4 // LArCalorimeter - << 3 // LArFCAL - << zSide // EndCap - << sampling // FCal Module # - << etaIndex - << phiIndex; - -// std::cout << "LArG4FCAL/LArFCALH62004CalibCalculatorBase: 4/3/" -// <<zSide<<"/" -// <<sampling<<"/" -// <<etaIndex<<"/" -// <<phiIndex<<": " -// << m_energies[0] << ", " -// << m_energies[1] << ", " -// << m_energies[2] << ", " -// << m_energies[3] -// << ", i=" << i -// << ", j=" << j -// << ", l.x=" << theLocalPoint.x() -// << ", l.y=" << theLocalPoint.y() -// << ", p.x=" << p.x() -// << ", p.y=" << p.y() -// << ", deltaX=" << m_deltaX -// << ", deltaY=" << m_deltaY -// << std::endl; + +G4bool LArFCALH62004CalibCalculatorBase::Process(const G4Step* a_step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing a_process) const { + // First, get the energy. + + energies.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyEnergy ) + { + m_energyCalculator.Energies( a_step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + // find the space point for this deposit + G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + G4StepPoint* post_step_point = a_step->GetPostStepPoint(); + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + // S.M.: this does not work - there are some volumes inside the + // FCAL which have their own local coordinate system and + // just result in (~0,~0) local coordinates. I think they should + // be treated as absorbers ... so I take the original coordinates + // instead ... + + // P.S. We sould go to FCAL mother volume, and work there + + // S.M. // get LOCAL (u,v) coordinates! + // S.M. G4Navigator* theNavigator = + // S.M. G4TransportationManager::GetTransportationManager()-> + // S.M. GetNavigatorForTracking(); + // S.M. G4ThreeVector theLocalPoint = theNavigator-> + // S.M. GetGlobalToLocalTransform(). + // S.M. TransformPoint(p); + + // Find a transformation to a module coordinate system + G4TouchableHistory* theTouchable = + (G4TouchableHistory*) (pre_step_point->GetTouchable()); + + G4String volumeName = theTouchable->GetVolume()->GetName() ; + int modVol=theTouchable->GetHistoryDepth(); + // Assume Gap as a most often case - get it through copy number + if(volumeName[volumeName.size() - 3] == 'G') { + modVol -= 2; + } else if(volumeName[volumeName.size() - 8] == 'A') { // second most often volume + modVol -= 1; + } else if(volumeName[volumeName.size() - 11] == 'C') { + modVol -= 2; + } else if(volumeName[volumeName.size() - 3] == 'R') { + modVol -= 3; + } else { + std::cout<<"Unknown volume ?? "<< volumeName << std::endl; + } + + const G4AffineTransform moduleTransform= theTouchable->GetHistory()->GetTransform(modVol); + G4ThreeVector theLocalPoint = moduleTransform.TransformPoint(p); + + + // we've shifted the endcap, we have to project the geometry to a + // different point). + G4double pointZ = p.z(); + + int etaIndex,phiIndex; + float x = theLocalPoint.x(),y=theLocalPoint.y(); + int sampling = m_FCalSampling; + bool ok = m_ChannelMap->getTileID(sampling, + x, + y, + etaIndex, + phiIndex); + + + G4ThreeVector pointShift(x, y, theLocalPoint.z() + m_Zshift); + // zSide is negative if z<0. + G4int zSide = 2; + if (pointZ < 0.) zSide = -zSide; + + identifier.clear(); + if (ok) { + // we have a active or non-active hit inside the FCal + G4int sampling = m_FCalSampling; + + + // Append the values to the empty identifier. + identifier << 4 // LArCalorimeter + << 3 // LArFCAL + << zSide // EndCap + << sampling // FCal Module # + << etaIndex + << phiIndex; + + // std::cout << "LArG4FCAL/LArFCALH62004CalibCalculatorBase: 4/3/" + // <<zSide<<"/" + // <<sampling<<"/" + // <<etaIndex<<"/" + // <<phiIndex<<": " + // << energies[0] << ", " + // << energies[1] << ", " + // << energies[2] << ", " + // << energies[3] + // << ", i=" << i + // << ", j=" << j + // << ", l.x=" << theLocalPoint.x() + // << ", l.y=" << theLocalPoint.y() + // << ", p.x=" << p.x() + // << ", p.y=" << p.y() + // << ", deltaX=" << m_deltaX + // << ", deltaY=" << m_deltaY + // << std::endl; + } + else { + // S.M.: we have a hit which fails the electrode identifier + // calculation. It's likely just a the border of the FCAL + // (outer or inner) and not really dead material ... Lacking a + // better method of assigning it to a correct cell I make a + // dead material identifier for it ... + + /* + int dubina=theTouchable->GetHistoryDepth(); + std::cout<<"----------------------"<<std::endl; + for( int kk=0; kk<=dubina; ++kk ) { + std::cout<<theTouchable->GetHistory()->GetVolume(kk)->GetName()<<" "<<theTouchable->GetHistory()->GetVolume(kk)->GetCopyNo()<<std::endl; } - else { - // S.M.: we have a hit which fails the electrode identifier - // calculation. It's likely just a the border of the FCAL - // (outer or inner) and not really dead material ... Lacking a - // better method of assigning it to a correct cell I make a - // dead material identifier for it ... - - /* - int dubina=theTouchable->GetHistoryDepth(); - std::cout<<"----------------------"<<std::endl; - for( int kk=0; kk<=dubina; ++kk ) { - std::cout<<theTouchable->GetHistory()->GetVolume(kk)->GetName()<<" "<<theTouchable->GetHistory()->GetVolume(kk)->GetCopyNo()<<std::endl; - } - */ - G4int sampling(3); // FCAL leakage - G4int type(1); // FCAL leakage - G4double eta = fabs( pointShift.pseudoRapidity() ); - G4double phi = pointShift.phi(); - G4double rho = theLocalPoint.perp(); - // since the outer edge of the FCal has a irregular shape we - // take the innermost position of the outermost tubes as min - // radius - this is about 3 cm from the outermost tube - // position ... - const G4double fcal_edge_approx = 415.0*CLHEP::mm; - G4int subdet; // LAr - if ( pointZ < 0. ) - subdet = -4; - else - subdet = 4; - if (phi < 0) phi += 2*M_PI; - G4int etaIndex; - G4int phiIndex; - G4int region; - if ( eta < 5 ) { - if(rho > fcal_edge_approx) { - type = 2; - sampling = m_FCalSampling; - region = 4; - etaIndex = 0; - phiIndex = G4int(phi*(32/M_PI)); - } else { - region = 0; - etaIndex = etaToBin1 (eta, 1.7); - phiIndex = G4int(phi*(32/M_PI)); - } - } - else if ( eta < 8 ) { - region = 1; - etaIndex = etaToBin2 (eta, 5.0); - phiIndex = G4int(phi*(32/M_PI)); - } - else { - region = 2; - etaIndex = 0; - phiIndex = 0; - } - - // Append the values to the empty identifier. - m_identifier << 10 // Calorimeter Dead Material - << subdet // LAr - << type - << sampling - << region - << etaIndex - << phiIndex; - /* - std::cout << "LArG4FCAL/LArFCALH62004CalibCalculatorBase: 10/4/" - <<type<<"/" - <<sampling<<"/" - <<region<<"/" - <<etaIndex<<"/" - <<phiIndex<<": " -// << m_energies[0] << ", " -// << m_energies[1] << ", " -// << m_energies[2] << ", " -// << m_energies[3] -// << ", i=" << i -// << ", j=" << j - << std::fixed - << ", l.r=" << rho - << ", l.x=" << theLocalPoint.x() - << ", l.y=" << theLocalPoint.y() - << ", l.z=" << theLocalPoint.z()<< std::endl; - - std::cout << ", p.x=" << p.x() - << ", p.y=" << p.y() - << ", p.z=" << p.z() - << ", l.zshift "<< theLocalPoint.z() + m_Zshift - << ", deltaX=" << m_deltaX - << ", deltaY=" << m_deltaY - << std::endl; - */ + */ + G4int sampling(3); // FCAL leakage + G4int type(1); // FCAL leakage + G4double eta = fabs( pointShift.pseudoRapidity() ); + G4double phi = pointShift.phi(); + G4double rho = theLocalPoint.perp(); + // since the outer edge of the FCal has a irregular shape we + // take the innermost position of the outermost tubes as min + // radius - this is about 3 cm from the outermost tube + // position ... + const G4double fcal_edge_approx = 415.0*CLHEP::mm; + G4int subdet; // LAr + if ( pointZ < 0. ) + subdet = -4; + else + subdet = 4; + if (phi < 0) phi += 2*M_PI; + G4int etaIndex; + G4int phiIndex; + G4int region; + if ( eta < 5 ) { + if(rho > fcal_edge_approx) { + type = 2; + sampling = m_FCalSampling; + region = 4; + etaIndex = 0; + phiIndex = G4int(phi*(32/M_PI)); + } else { + region = 0; + etaIndex = etaToBin1 (eta, 1.7); + phiIndex = G4int(phi*(32/M_PI)); } - - return true; + } + else if ( eta < 8 ) { + region = 1; + etaIndex = etaToBin2 (eta, 5.0); + phiIndex = G4int(phi*(32/M_PI)); + } + else { + region = 2; + etaIndex = 0; + phiIndex = 0; + } + + // Append the values to the empty identifier. + identifier << 10 // Calorimeter Dead Material + << subdet // LAr + << type + << sampling + << region + << etaIndex + << phiIndex; + /* + std::cout << "LArG4FCAL/LArFCALH62004CalibCalculatorBase: 10/4/" + <<type<<"/" + <<sampling<<"/" + <<region<<"/" + <<etaIndex<<"/" + <<phiIndex<<": " + // << energies[0] << ", " + // << energies[1] << ", " + // << energies[2] << ", " + // << energies[3] + // << ", i=" << i + // << ", j=" << j + << std::fixed + << ", l.r=" << rho + << ", l.x=" << theLocalPoint.x() + << ", l.y=" << theLocalPoint.y() + << ", l.z=" << theLocalPoint.z()<< std::endl; + + std::cout << ", p.x=" << p.x() + << ", p.y=" << p.y() + << ", p.z=" << p.z() + << ", l.zshift "<< theLocalPoint.z() + m_Zshift + << ", deltaX=" << m_deltaX + << ", deltaY=" << m_deltaY + << std::endl; + */ + } + + return true; } diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.h index adb1dc98b2eb..274e9802f1c4 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArFCALH62004CalibCalculatorBase.h @@ -5,71 +5,44 @@ #ifndef LArFCALH62004CalibCalculatorBase_H #define LArFCALH62004CalibCalculatorBase_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" - -#include "LArReadoutGeometry/FCAL_ChannelMap.h" -#include "RDBAccessSvc/IRDBRecordset.h" - -#include "LArG4Code/LArVCalculator.h" #include "CaloG4Sim/SimulationEnergies.h" - #include "globals.hh" #include <vector> + // Forward declaration for namespace CaloG4. class G4Step; +class FCAL_ChannelMap; +class IRDBRecordset; -class LArFCALH62004CalibCalculatorBase : public LArG4::VCalibrationCalculator { - - public: - LArFCALH62004CalibCalculatorBase(); - virtual ~LArFCALH62004CalibCalculatorBase(); - - virtual G4bool Process (const G4Step* step, - const LArG4::VCalibrationCalculator::eCalculatorProcessing p = LArG4::VCalibrationCalculator::kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } +class LArFCALH62004CalibCalculatorBase : public LArCalibCalculatorSvcImp { +public: + LArFCALH62004CalibCalculatorBase(const std::string& name, ISvcLocator * pSvcLocator); + virtual StatusCode initialize() override final; + virtual ~LArFCALH62004CalibCalculatorBase(); - virtual G4float OOTcut() const { return m_OOTcut; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing p = LArG4::kEnergyAndID) const override final; - virtual G4double time() const { return m_time; } - virtual const std::vector<G4double>& energies() const { return m_energies; } - virtual G4bool isInTime() const { return m_isInTime; } - virtual G4bool isOutOfTime() const { return ( ! m_isInTime ); } - ///////////////////////////////////////////// +protected: - virtual G4double GetdeltaX(){return m_deltaX;} - virtual G4double GetdeltaY(){return m_deltaY;} + G4double m_deltaX; + G4double m_deltaY; - protected: - - G4double m_deltaX; - G4double m_deltaY; - - G4int m_FCalSampling; - - private: - - // The values calculated by Process() - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; + G4int m_FCalSampling; +private: // Energy calculator - CaloG4::SimulationEnergies m_energyCalculator; - - G4float m_OOTcut; - - // The results of the Process calculation: - G4double m_time; - G4bool m_isInTime; + CaloG4::SimulationEnergies m_energyCalculator; - FCAL_ChannelMap *m_ChannelMap; + FCAL_ChannelMap *m_ChannelMap; - const IRDBRecordset* m_fcalMod; - float m_Zshift; + const IRDBRecordset* m_fcalMod; + float m_Zshift; }; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.cc index 27ed180d1d80..e331caeb2f2c 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.cc @@ -4,26 +4,30 @@ #include "LArG4H62004ActiveSDTool.h" -// For the SDs (including all their calculators) +// For the SDs #include "LArG4H62004CalibSD.h" -#include "LArG4EC/CalibrationCalculator.h" -#include "LArG4HEC/LocalCalibrationCalculator.h" -#include "LArFCAL1H62004CalibCalculator.h" -#include "LArFCAL2H62004CalibCalculator.h" -#include "LArG4H6COLDTCMod0CalibCalculator.h" - // For the hit collections #include "CxxUtils/make_unique.h" LArG4H62004ActiveSDTool::LArG4H62004ActiveSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArCalibrationHitActive") + , m_emepiwcalc("EMECPosInnerWheelCalibrationCalculator", name) + , m_heccalc("LocalCalibrationActiveCalculator", name) + , m_fcal1calc("LArFCAL1H62004CalibCalculator", name) + , m_fcal2calc("LArFCAL2H62004CalibCalculator", name) + , m_fcalcoldcalc("LArG4H6COLDTCMod0CalibCalculator", name) , m_emecSD(nullptr) , m_hecSD(nullptr) , m_fcal1SD(nullptr) , m_fcal2SD(nullptr) , m_fcalColdSD(nullptr) { + declareProperty("EMECPosIWCalibrationCalculator", m_emepiwcalc); + declareProperty("HECWheelActiveCalculator", m_heccalc); + declareProperty("FCAL1CalibCalculator", m_fcal1calc); + declareProperty("FCAL2CalibCalculator", m_fcal2calc); + declareProperty("FCALCOLDMod0CalibCalculator", m_fcalcoldcalc); declareProperty("EMECVolumes",m_emecVolumes); declareProperty("HECVolumes",m_hecVolumes); declareProperty("FCAL1Volumes",m_fcal1Volumes); @@ -32,14 +36,24 @@ LArG4H62004ActiveSDTool::LArG4H62004ActiveSDTool(const std::string& type, const declareInterface<ISensitiveDetector>(this); } +StatusCode LArG4H62004ActiveSDTool::initializeCalculators() +{ + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcalcoldcalc.retrieve()); + return StatusCode::SUCCESS; +} + StatusCode LArG4H62004ActiveSDTool::initializeSD() { // Lots of singleton calculators !!! - if (m_emecVolumes.size()>0) m_emecSD = new LArG4H62004CalibSD( "EMEC::InnerModule::Calibration::H6" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, 1) , m_doPID ); - if (m_hecVolumes.size()>0) m_hecSD = new LArG4H62004CalibSD( "HEC::Module::Depth::Slice::Local::Calibration::H6", new LArG4::HEC::LocalCalibrationCalculator(LArG4::HEC::kLocActive) , m_doPID ); - if (m_fcal1Volumes.size()>0) m_fcal1SD = new LArG4H62004CalibSD( "LAr::FCAL::Module1::Gap::Calibration::H6" , LArFCAL1H62004CalibCalculator::GetCalculator() , m_doPID ); - if (m_fcal2Volumes.size()>0) m_fcal2SD = new LArG4H62004CalibSD( "LAr::FCAL::Module2::Gap::Calibration::H6" , LArFCAL2H62004CalibCalculator::GetCalculator() , m_doPID ); - if (m_fcalColdVolumes.size()>0) m_fcalColdSD = new LArG4H62004CalibSD( "LAr::FCAL::ColdTC::Gap::Calibration::H6" , new LArG4H6COLDTCMod0CalibCalculator() , m_doPID ); + if (m_emecVolumes.size()>0) m_emecSD = new LArG4H62004CalibSD( "EMEC::InnerModule::Calibration::H6" , &*m_emepiwcalc , m_doPID ); + if (m_hecVolumes.size()>0) m_hecSD = new LArG4H62004CalibSD( "HEC::Module::Depth::Slice::Local::Calibration::H6", &*m_heccalc , m_doPID ); + if (m_fcal1Volumes.size()>0) m_fcal1SD = new LArG4H62004CalibSD( "LAr::FCAL::Module1::Gap::Calibration::H6" , &*m_fcal1calc , m_doPID ); + if (m_fcal2Volumes.size()>0) m_fcal2SD = new LArG4H62004CalibSD( "LAr::FCAL::Module2::Gap::Calibration::H6" , &*m_fcal2calc , m_doPID ); + if (m_fcalColdVolumes.size()>0) m_fcalColdSD = new LArG4H62004CalibSD( "LAr::FCAL::ColdTC::Gap::Calibration::H6" , &*m_fcalcoldcalc , m_doPID ); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; if (m_emecVolumes.size()>0) configuration[m_emecSD] = &m_emecVolumes; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.h index cc0d265d11c5..f278b7982bf9 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004ActiveSDTool.h @@ -11,15 +11,19 @@ #include "StoreGate/WriteHandle.h" #include "CaloSimEvent/CaloCalibrationHitContainer.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" class LArG4H62004CalibSD; +/// DEPRECATED AND WILL BE REMOVED. +/// Please see LArG4::H62004ActiveSDTool instead. +/// class LArG4H62004ActiveSDTool : public LArG4SDTool { public: // Constructor LArG4H62004ActiveSDTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~LArG4H62004ActiveSDTool() {} @@ -30,8 +34,15 @@ class LArG4H62004ActiveSDTool : public LArG4SDTool StatusCode Gather() override final; private: + StatusCode initializeCalculators() override final; + // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; + ServiceHandle<ILArCalibCalculatorSvc> m_emepiwcalc; + ServiceHandle<ILArCalibCalculatorSvc> m_heccalc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal1calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal2calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcalcoldcalc; LArG4H62004CalibSD* m_emecSD; LArG4H62004CalibSD* m_hecSD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.cc index 7d2215bb51e0..d7aac6723f19 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.cc @@ -3,11 +3,11 @@ */ #include "LArG4H62004CalibSD.h" -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" #undef DEBUG_SD -LArG4H62004CalibSD::LArG4H62004CalibSD(G4String a_name, LArG4::VCalibrationCalculator* calc,bool doPID): +LArG4H62004CalibSD::LArG4H62004CalibSD(G4String a_name, ILArCalibCalculatorSvc* calc,bool doPID): LArG4CalibSD(a_name,calc,doPID) { #ifdef DEBUG_SD @@ -20,8 +20,10 @@ G4bool LArG4H62004CalibSD::ProcessHits(G4Step* a_step,G4TouchableHistory* /*ROhi #ifdef DEBUG_SD std::cout << "my name: "<<this->GetName()<<", calc: "<<LArG4::m_calculator<<std::endl; #endif + LArG4Identifier ident; + std::vector<G4double> energies; // Convert the G4Step into identifier and energy. - G4bool valid = m_calculator->Process(a_step, LArG4::VCalibrationCalculator::kEnergyAndID); + G4bool valid = m_calculator->Process(a_step, ident, energies, LArG4::kEnergyAndID); // Check that hit was valid. (It might be invalid if, for example, // it occurred outside the sensitive region. If such a thing @@ -35,9 +37,6 @@ G4bool LArG4H62004CalibSD::ProcessHits(G4Step* a_step,G4TouchableHistory* /*ROhi return false; } - // Fetch the values from the calculator. - LArG4Identifier ident = m_calculator->identifier(); - std::vector<G4double> energies = m_calculator->energies(); // Changing the ident to comply with H6 dictionary if(ident[1] == 1) { // EMEC module ident[6] += 8; // change phi id @@ -64,13 +63,13 @@ G4bool LArG4H62004CalibSD::SpecialHit(G4Step* a_step, std::cout<<"LArG4H62004CalibSD::SpecialHit called, calling calculator..."<<std::endl; #endif // Convert the G4Step into an identifier. - G4bool valid = m_calculator->Process( a_step, LArG4::VCalibrationCalculator::kOnlyID ); + LArG4Identifier ident; + std::vector<double> energies; + G4bool valid = m_calculator->Process( a_step, ident, energies, LArG4::kOnlyID ); // If we can't calculate the identifier, something is wrong. if ( ! valid ) return false; - // Fetch the identifier from the calculator. - LArG4Identifier ident = m_calculator->identifier(); // Changing the ident to comply with H6 dictionary if(ident[1] == 1) { // EMEC module ident[6] += 8; // change phi id diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.h index c36f93e31d87..7d0afa541d47 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004CalibSD.h @@ -19,7 +19,7 @@ class G4TouchableHistory; class LArG4H62004CalibSD : public LArG4CalibSD { public: - LArG4H62004CalibSD(G4String name,LArG4::VCalibrationCalculator* calc,bool doPID=false); + LArG4H62004CalibSD(G4String name,ILArCalibCalculatorSvc* calc,bool doPID=false); virtual ~LArG4H62004CalibSD() {} // The required functions for all sensitive detectors: diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.cc index 4825f0505c30..1f7d7c736327 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.cc @@ -15,7 +15,7 @@ //#include <algo.h> -#include "LArG4Code/CalibrationDefaultCalculator.h" +//#include "LArG4Code/CalibrationDefaultCalculator.h" #undef DEBUG_DMXYZ @@ -31,7 +31,7 @@ static double yrot = 45.*CLHEP::degree; static Hep3Vector shift; static HepRotation m13,my3; -static const double zSamplings[10] = { +static const double zSamplings[10] = { 3691.*CLHEP::mm, // z-start of EMEC active part (3691. + 536.)*CLHEP::mm, // z-end of EMEC active part (4317. + 12.5)*CLHEP::mm, // z-start of HEC-1 active part @@ -52,11 +52,11 @@ static const double dHec22 = 2*234.*CLHEP::mm; // depth of fourth sampling in HE //static const double shiftTB = 7339*CLHEP::mm; // Z_TB -> Z_ATLAS static const double EMrouter = 698.6*CLHEP::mm; // Outer part of the EMEC inner wheel static const double HECrouter = 1159.0*CLHEP::mm; // Outer part of our HEC module -//static const double EMrinner = 301.4*CLHEP::mm; // Inner r of the EMEC -static const double HECrinner1 = 372.0*CLHEP::mm; // Inner part of the HEC -static const double HECrinner2 = 475.0*CLHEP::mm; // Inner part of the HEC -static const double FCALrinner = 71.8*CLHEP::mm; // Inner part of the FCAL -static const double FCALrouter = 450.*CLHEP::mm; // Outer part of the FCAL +//static const double EMrinner = 301.4*CLHEP::mm; // Inner r of the EMEC +static const double HECrinner1 = 372.0*CLHEP::mm; // Inner part of the HEC +static const double HECrinner2 = 475.0*CLHEP::mm; // Inner part of the HEC +static const double FCALrinner = 71.8*CLHEP::mm; // Inner part of the FCAL +static const double FCALrouter = 450.*CLHEP::mm; // Outer part of the FCAL static const double TBzStart = 11067.*CLHEP::mm; //static const double TBzEnd = 12500.*CLHEP::mm; static const double offset = 20.*CLHEP::mm; // safety offset while calculated edges of different zones @@ -80,11 +80,10 @@ int etaToBin2 (G4double eta, G4double eta0) } -LArG4H62004DeadCalibrationCalculator::LArG4H62004DeadCalibrationCalculator() +LArG4H62004DeadCalibrationCalculator::LArG4H62004DeadCalibrationCalculator(const std::string& name, ISvcLocator * pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) { // Make sure there are no uninitialized variables. - //m_identifier = LArG4Identifier(); - m_identifier.clear(); Hep3Vector sh(0., yshift, zshift); const Hep3Vector colX(cos(yrot),sin(yrot),0); @@ -96,25 +95,25 @@ LArG4H62004DeadCalibrationCalculator::LArG4H62004DeadCalibrationCalculator() const Hep3Vector colZZ(0,0,1); my3 = HepRotation(colXX, colYY, colZZ); - shift = my3*sh; + shift = my3*sh; } -LArG4H62004DeadCalibrationCalculator::~LArG4H62004DeadCalibrationCalculator() +LArG4H62004DeadCalibrationCalculator::~LArG4H62004DeadCalibrationCalculator() { } -G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) +G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing a_process ) const { // Some hard-coded numbers. // Think how to put it more correctly !!!! // Still not finished !!!!!! - // Make first transformation to ATLAS, and then use the data from DB - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) { + // Make first transformation to ATLAS, and then use the data from DB + energies.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyEnergy ) { /* CaloG4::SimulationEnergies::ClassifyResult_t category = m_energyCalculator->Classify( a_step ); @@ -127,18 +126,18 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, m_energies.push_back( category.energy[CaloG4::SimulationEnergies::kInvisible0] ); m_energies.push_back( category.energy[CaloG4::SimulationEnergies::kEscaped] ); */ - m_energyCalculator.Energies( a_step, m_energies ); + m_energyCalculator.Energies( a_step, energies ); } else { - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); } - if ( a_process == kEnergyAndID || a_process == kOnlyID ) { - // m_identifier = LArG4Identifier(); - m_identifier.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyID ) { + // identifier = LArG4Identifier(); + identifier.clear(); // Calculate the identifier. G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); G4TouchableHistory* theTouchable = (G4TouchableHistory*) (pre_step_point->GetTouchable()); - // Volume name + // Volume name G4String hitVolume = theTouchable->GetVolume(0)->GetName(); // if(hitVolume.contains("::") ) { // int last = hitVolume.last(':'); @@ -151,13 +150,13 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, G4ThreeVector tbPoint = pre_step_point->GetPosition(); G4ThreeVector gPoint; - // Move all points before calorimeter to one plane + // Move all points before calorimeter to one plane if(tbPoint.z() < TBzStart) { tbPoint -= G4ThreeVector(0.,0.,tbPoint.z()-TBzStart); } gPoint = m13*tbPoint + shift; - double gz = gPoint.z(); + double gz = gPoint.z(); type = INT_MIN; sampling = INT_MIN; @@ -182,12 +181,12 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, // First the type, sampling and region if( gz < zSamplings[zStartEMEC]) { // before the EMEC - type = 1; sampling = 1; - if(eta < 3.2) { - region = 6; + type = 1; sampling = 1; + if(eta < 3.2) { + region = 6; etaBin = etaToBin1 (eta, 1.3); } else { - region = 7; + region = 7; etaBin = etaToBin1 (eta, 3.2); } } else if( gz < zSamplings[zEndEMEC]) { // in EMEC @@ -208,13 +207,13 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, type = 2; sampling = 1; region = 1; etaBin = 0; }else if(eta<3.2) { - type = 1; sampling = 1; region = 6; + type = 1; sampling = 1; region = 6; etaBin = etaToBin1 (eta, 1.3); }else if(eta<5.0) { - type = 1; sampling = 1; region = 7; + type = 1; sampling = 1; region = 7; etaBin = etaToBin1 (eta, 3.2); }else if(eta < 8.0) { - type = 1; sampling = 3; region = 1; + type = 1; sampling = 3; region = 1; etaBin = etaToBin2 (eta, 5.0); }else{ type = 1; sampling = 3; region = 2; @@ -226,10 +225,10 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, type = 1; sampling = 2; region = 3; etaBin = etaToBin1 (eta, 1.5); }else if (eta<5.0) { // before FCAL - type = 1; sampling = 1; region = 7; + type = 1; sampling = 1; region = 7; etaBin = etaToBin1 (eta, 3.2); }else if (eta<8.0) { - type = 1; sampling = 3; region = 1; + type = 1; sampling = 3; region = 1; etaBin = etaToBin2 (eta, 5.0); }else{ type = 1; sampling = 3; region = 2; @@ -313,53 +312,53 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, type = 1; sampling = 3; region = 2; etaBin = 0; }else if(eta>=5.0){ - type = 1; sampling = 3; region = 1; + type = 1; sampling = 3; region = 1; etaBin = etaToBin2 (eta, 5.0); if(etaBin < 0) etaBin = 0; }else{ if(gz < zSamplings[zEndEMEC]){ // 4117 - type = 1; sampling = 1; region = 7; + type = 1; sampling = 1; region = 7; etaBin = etaToBin1 (eta, 3.2); if(etaBin < 0) etaBin = 0; }else if(gz < (zSamplings[zEndEMEC] + 280.5)){ // 4205 - type = 2; sampling = 0; region = 5; + type = 2; sampling = 0; region = 5; etaBin = etaToBin1 (eta, 3.0); if(etaBin < 0) etaBin = 0; }else{ // 4215 - type = 2; sampling = 1; region = 5; + type = 2; sampling = 1; region = 5; etaBin = etaToBin1 (eta, 3.0); if(etaBin < 0) etaBin = 0; } } - - + + // if(eta<3.2){ // crack emec-hec // // LeakageDet::ColdNose it's a small corner between HEC0 and FCAL1 -// type = 1; sampling = 1; region = 7; +// type = 1; sampling = 1; region = 7; // etaBin = 0; // }else if (eta<5.0) { // before FCAL // if(gz < zSamplings[zEndEMEC]){ // 4117 -// type = 1; sampling = 1; region = 7; +// type = 1; sampling = 1; region = 7; // etaBin = int((eta - 3.2)/0.1); // }else if(gz < zSamplings[zStartHEC1]){ // 4105 -// type = 2; sampling = 0; region = 5; +// type = 2; sampling = 0; region = 5; // etaBin = int((eta - 3.0)/0.1); // }else{ // 4215 -// type = 2; sampling = 1; region = 5; +// type = 2; sampling = 1; region = 5; // etaBin = int((eta - 3.0)/0.1); // } // }else if (eta<8.0) { -// type = 1; sampling = 3; region = 1; +// type = 1; sampling = 3; region = 1; // etaBin = int((eta - 5.0)/0.2); // }else{ // type = 1; sampling = 3; region = 2; // etaBin = 0; // } - - - - - } else if(gz > zSamplings[zEndFCAL3]) { //after the FCAL + + + + + } else if(gz > zSamplings[zEndFCAL3]) { //after the FCAL if(eta < 3.2) { }else if(eta < 5) { type = 1; sampling = 3; region = 0; @@ -371,7 +370,7 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, type = 1; sampling = 3; region = 2; etaBin = 0; } }else if(gr>FCALrouter - offset) { // FCAL - HEC crack - type = 2; region = 4; etaBin = 0; + type = 2; region = 4; etaBin = 0; if(gz < zSamplings[zEndHEC1]-dHec12) sampling = 0; else if(gz < zSamplings[zEndHEC1]) sampling = 1; else if(gz < zSamplings[zEndHEC2] - dHec22) sampling = 2; @@ -381,7 +380,7 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, } else if(gr> FCALrinner) { // between FCAL modules (and before/after fcal for safety) if( eta < 5.0) { if(gz < zSamplings[zStartFCAL1] + offset*2.0) { - type = 2; sampling = 1; region = 5; + type = 2; sampling = 1; region = 5; etaBin = etaToBin1 (eta, 3.0); if(etaBin < 0) etaBin = 0; // type = 1; sampling = 1; region = 7; // 4117 @@ -405,7 +404,7 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, // God knows what could be here if(eta<5.0){ if(gz < zSamplings[zStartFCAL1]+offset*2.0 ) { - type = 2; sampling = 1; region = 5; + type = 2; sampling = 1; region = 5; etaBin = etaToBin1 (eta, 3.0); if(etaBin < 0) etaBin = 0; // type = 1; sampling = 1; region = 7; // 4117 @@ -440,16 +439,16 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, << std::endl; #ifdef DEBUG_DMXYZ // std::cout<<"DMXYZ task: "<< a_process <<std::endl; -// std::cout<<"UNEXP LArG4H62004DeadCalibrationCalculator "<<std::string(m_identifier)<<std::endl; - +// std::cout<<"UNEXP LArG4H62004DeadCalibrationCalculator "<<std::string(identifier)<<std::endl; + char str[1024]; sprintf(str,"UNEXP LArG4H6SD/LArG4H62004DeadCalibrationCalculator_%d",(int)a_process); - LArG4::CalibrationDefaultCalculator::Print(str,m_identifier,a_step,m_energies); + LArG4::CalibrationDefaultCalculator::Print(str,identifier,a_step,energies); #endif } else{ if(phiBin == 64) phiBin = 63; - m_identifier << 10 // Calorimeter + identifier << 10 // Calorimeter << 4 // Sub-det << type << sampling @@ -458,25 +457,24 @@ G4bool LArG4H62004DeadCalibrationCalculator::Process( const G4Step* a_step, << phiBin; #ifdef DEBUG_DMXYZ // std::cout<<"DMXYZ task: "<< a_process <<std::endl; -// std::cout<<"DMXYZ LArG4H62004DeadCalibrationCalculator: "<<std::string(m_identifier)<<std::endl; +// std::cout<<"DMXYZ LArG4H62004DeadCalibrationCalculator: "<<std::string(identifier)<<std::endl; char str[1024]; sprintf(str,"DMXYZ LArG4H6SD/LArG4H62004DeadCalibrationCalculator_%d",(int)a_process); - LArG4::CalibrationDefaultCalculator::Print(str,m_identifier,a_step,m_energies); - -// LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4H62004DeadCalibrationCalculator",m_identifier,a_step,m_energies); + LArG4::CalibrationDefaultCalculator::Print(str,identifier,a_step,energies); + +// LArG4::CalibrationDefaultCalculator::Print("DMXYZ LArG4H62004DeadCalibrationCalculator",identifier,a_step,energies); #endif } } else -// m_identifier = LArG4Identifier(); - m_identifier.clear(); +// identifier = LArG4Identifier(); + identifier.clear(); // Check for bad result. - if ( m_identifier == LArG4Identifier() ){ + if ( identifier == LArG4Identifier() ){ std::cout<<"LArG4H62004DeadCalibrationCalculator bad identifier, return false...."<<std::endl; return false; } return true; } - diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.h index dc27abcb9b3b..a065e173420f 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadCalibrationCalculator.h @@ -5,7 +5,7 @@ #ifndef LArG4H62004DeadCalibrationCalculator_H #define LArG4H62004DeadCalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -13,28 +13,20 @@ #include <vector> +class G4Step; -class LArG4H62004DeadCalibrationCalculator : public LArG4::VCalibrationCalculator { +class LArG4H62004DeadCalibrationCalculator : public LArCalibCalculatorSvcImp { public: - LArG4H62004DeadCalibrationCalculator(); + LArG4H62004DeadCalibrationCalculator(const std::string& name, ISvcLocator * pSvcLocator); virtual ~LArG4H62004DeadCalibrationCalculator(); - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing p = LArG4::kEnergyAndID) const override final; private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - // Energy calculator CaloG4::SimulationEnergies m_energyCalculator; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.cc index 3af7ee7524cd..0f956720b85a 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.cc @@ -8,10 +8,6 @@ #include "CxxUtils/make_unique.h" -// The calculators that I need... -#include "LArG4HEC/LArHECCalibrationWheelCalculator.h" -#include "LArG4H62004DeadCalibrationCalculator.h" - // For escaped energy #include "CaloG4Sim/EscapedEnergyRegistry.h" #include "LArG4Code/EscapedEnergyProcessing.h" @@ -19,19 +15,27 @@ LArG4H62004DeadSDTool::LArG4H62004DeadSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArCalibrationHitDeadMaterial") + , m_calculator("LArG4H62004DeadCalibrationCalculator", name) , m_deadSD(nullptr) , m_uninstSD(nullptr) { declareProperty("doEscapedEnergy",m_do_eep=false); + declareProperty("Calculator", m_calculator); declareInterface<ISensitiveDetector>(this); } +StatusCode LArG4H62004DeadSDTool::initializeCalculators() +{ + ATH_CHECK(m_calculator.retrieve()); + return StatusCode::SUCCESS; +} + StatusCode LArG4H62004DeadSDTool::initializeSD() { // Lots of singleton calculators !!! - m_deadSD = new LArG4H62004CalibSD( "LArDead::Dead::H6" , new LArG4H62004DeadCalibrationCalculator() , m_doPID); + m_deadSD = new LArG4H62004CalibSD( "LArDead::Dead::H6" , &*m_calculator, m_doPID); // Take care of the default material - if (m_do_eep) m_uninstSD = new LArG4H62004CalibSD( "Default::Dead::Uninstrumented::Calibration::H6" , new LArG4H62004DeadCalibrationCalculator() , m_doPID ); + if (m_do_eep) m_uninstSD = new LArG4H62004CalibSD( "Default::Dead::Uninstrumented::Calibration::H6" , &*m_calculator, m_doPID ); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_deadSD] = &m_volumeNames; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.h index 3ff3b5c4bf17..4aba4280119b 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004DeadSDTool.h @@ -11,15 +11,19 @@ #include "StoreGate/WriteHandle.h" #include "CaloSimEvent/CaloCalibrationHitContainer.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" class LArG4H62004CalibSD; +/// DEPRECATED AND WILL BE REMOVED. +/// Please see LArG4::H62004DeadSDTool instead. +/// class LArG4H62004DeadSDTool : public LArG4SDTool { public: // Constructor LArG4H62004DeadSDTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~LArG4H62004DeadSDTool() {} @@ -32,14 +36,18 @@ class LArG4H62004DeadSDTool : public LArG4SDTool /** Beginning of an athena event. This is where collection initialization should happen. If we are using a WriteHandle, then this could be empty. */ // StatusCode SetupEvent() override final; - + private: + StatusCode initializeCalculators() override final; + // Do we add the escaped energy processing? This is only in "mode 1" (Tile+LAr), not in "DeadLAr" mode bool m_do_eep; // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; + ServiceHandle<ILArCalibCalculatorSvc> m_calculator; + // The volumes per SD, and the corresponding SDs LArG4H62004CalibSD* m_deadSD; LArG4H62004CalibSD* m_uninstSD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.cc index 6ee7358ef5df..d69b82e2e2c2 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.cc @@ -7,21 +7,27 @@ #include "LArG4Code/LArG4Hit.h" -#include "LArG4EC/EnergyCalculator.h" - #include "CxxUtils/make_unique.h" LArG4H62004EMECSDTool::LArG4H62004EMECSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArHitEMEC") + , m_calculator("EMECPosInnerWheel_ECOR_GADJCalculator", name) , m_emecSD(nullptr) { declareInterface<ISensitiveDetector>(this); + declareProperty("Calculator", m_calculator); +} + +StatusCode LArG4H62004EMECSDTool::initializeCalculators() +{ + ATH_CHECK(m_calculator.retrieve()); + return StatusCode::SUCCESS; } StatusCode LArG4H62004EMECSDTool::initializeSD() { - m_emecSD = new LArG4H62004SD( "LAr::EMEC::InnerModule::H6" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule,LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ) , m_timeBinType , m_timeBinWidth ); + m_emecSD = new LArG4H62004SD( "LAr::EMEC::InnerModule::H6" , &*m_calculator , m_timeBinType , m_timeBinWidth ); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_emecSD] = &m_volumeNames; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.h index 4e4687136818..d9984a0607fe 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004EMECSDTool.h @@ -6,6 +6,8 @@ #define LARG4H62004EMECSDTOOL_H #include "LArG4Code/LArG4SDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + #include <string> #include <vector> @@ -14,12 +16,15 @@ class LArG4SimpleSD; +/// DEPRECATED AND WILL BE REMOVED. +/// Please see LArG4::H62004EMECSDTool instead. +/// class LArG4H62004EMECSDTool : public LArG4SDTool { - public: +public: // Constructor LArG4H62004EMECSDTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~LArG4H62004EMECSDTool() {} @@ -28,14 +33,17 @@ class LArG4H62004EMECSDTool : public LArG4SDTool // Calls down to all the SDs to get them to pack their hits into a central collection StatusCode Gather() override final; - + /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ -// StatusCode SetupEvent() override final; + If we are using a WriteHandle, then this could be empty. */ + // StatusCode SetupEvent() override final; + +private: + StatusCode initializeCalculators() override final; - private: // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<LArHitContainer> m_HitColl; + ServiceHandle<ILArCalculatorSvc> m_calculator; LArG4SimpleSD* m_emecSD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.cc index dc1df99757ea..acfe76ba13fc 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.cc @@ -5,32 +5,40 @@ #include "LArG4H62004FCALSDTool.h" #include "LArG4H62004SD.h" -#include "LArG4FCAL/LArFCAL1Calculator.h" -#include "LArG4FCAL/LArFCAL2Calculator.h" -#include "LArG4H6COLDTCMod0Calculator.h" - #include "CxxUtils/make_unique.h" LArG4H62004FCALSDTool::LArG4H62004FCALSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArHitFCAL") + , m_fcal1calc("FCAL1Calculator", name) + , m_fcal2calc("FCAL2Calculator", name) + , m_fcalcoldcalc("FCALColdCalculator", name) , m_fcal1SD(nullptr) , m_fcal2SD(nullptr) , m_fcalColdSD(nullptr) { + declareProperty("FCAL1Calculator", m_fcal1calc); + declareProperty("FCAL2Calculator", m_fcal2calc); + declareProperty("FCALColdCalculator", m_fcalcoldcalc); declareProperty( "FCAL1Volumes" , m_fcal1Volumes ); declareProperty( "FCAL2Volumes" , m_fcal2Volumes ); declareProperty( "FCALColdVolumes" , m_fcalColdVolumes ); declareInterface<ISensitiveDetector>(this); } +StatusCode LArG4H62004FCALSDTool::initializeCalculators() +{ + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcalcoldcalc.retrieve()); + return StatusCode::SUCCESS; +} + StatusCode LArG4H62004FCALSDTool::initializeSD() { - m_fcal1SD = new LArG4H62004SD( "LAr::FCAL::Module1::Gap::H6" , LArFCAL1Calculator::GetInstance() , m_timeBinType , m_timeBinWidth ); - m_fcal2SD = new LArG4H62004SD( "LAr::FCAL::Module2::Gap::H6" , LArFCAL2Calculator::GetInstance() , m_timeBinType , m_timeBinWidth ); - LArG4H6COLDTCMod0Calculator* aCalc = LArG4H6COLDTCMod0Calculator::GetInstance(); - aCalc->SetOutOfTimeCut(10000.); - m_fcalColdSD = new LArG4H62004SD( "LAr::FCAL::ColdTC::H6" , aCalc , m_timeBinType , m_timeBinWidth ); + m_fcal1SD = new LArG4H62004SD( "LAr::FCAL::Module1::Gap::H6" , &*m_fcal1calc , m_timeBinType , m_timeBinWidth ); + m_fcal2SD = new LArG4H62004SD( "LAr::FCAL::Module2::Gap::H6" , &*m_fcal2calc , m_timeBinType , m_timeBinWidth ); + m_fcalColdSD = new LArG4H62004SD( "LAr::FCAL::ColdTC::H6" , &*m_fcalcoldcalc , m_timeBinType , m_timeBinWidth ); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_fcal1SD] = &m_fcal1Volumes; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.h index c86ff7da3798..274a2ff0bfed 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004FCALSDTool.h @@ -11,15 +11,19 @@ #include "StoreGate/WriteHandle.h" #include "LArSimEvent/LArHitContainer.h" +#include "LArG4Code/ILArCalculatorSvc.h" class LArG4SimpleSD; +/// DEPRECATED AND WILL BE REMOVED. +/// Please see LArG4::H62004FCALSDTool instead. +/// class LArG4H62004FCALSDTool : public LArG4SDTool { public: // Constructor LArG4H62004FCALSDTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~LArG4H62004FCALSDTool() {} @@ -30,9 +34,14 @@ class LArG4H62004FCALSDTool : public LArG4SDTool StatusCode Gather() override final; private: + StatusCode initializeCalculators() override final; + // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<LArHitContainer> m_HitColl; + ServiceHandle<ILArCalculatorSvc> m_fcal1calc; + ServiceHandle<ILArCalculatorSvc> m_fcal2calc; + ServiceHandle<ILArCalculatorSvc> m_fcalcoldcalc; // Sensitive detectors and their corresponding volumes LArG4SimpleSD* m_fcal1SD; LArG4SimpleSD* m_fcal2SD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.cc index a9dc20e0b04f..1ba8dc151160 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.cc @@ -7,24 +7,27 @@ #include "LArG4Code/LArG4Hit.h" -#include "LArG4HEC/LArHECLocalCalculator.h" - #include "CxxUtils/make_unique.h" LArG4H62004HECSDTool::LArG4H62004HECSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArHitHEC") + , m_calculator("LArH62004HECLocalCalculator", name) , m_wheelSD(nullptr) { declareInterface<ISensitiveDetector>(this); + declareProperty("Calculator", m_calculator); +} + +StatusCode LArG4H62004HECSDTool::initializeCalculators() +{ + ATH_CHECK(m_calculator.retrieve()); + return StatusCode::SUCCESS; } StatusCode LArG4H62004HECSDTool::initializeSD() { - LArHECLocalCalculator* aCalc = LArHECLocalCalculator::GetCalculator(); - aCalc->SetOutOfTimeCut(10000.); - aCalc->SetX(true); - m_wheelSD = new LArG4H62004SD( "LAr::HEC::Module::Depth::Slice::Local::H6" , aCalc , m_timeBinType , m_timeBinWidth ); + m_wheelSD = new LArG4H62004SD( "LAr::HEC::Module::Depth::Slice::Local::H6" , &*m_calculator , m_timeBinType , m_timeBinWidth ); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_wheelSD] = &m_volumeNames; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.h index 05770d568531..d1b0d7be1f75 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004HECSDTool.h @@ -11,18 +11,24 @@ #include "StoreGate/WriteHandle.h" #include "LArSimEvent/LArHitContainer.h" +#include "LArG4Code/ILArCalculatorSvc.h" class LArG4SimpleSD; +/// DEPRECATED AND WILL BE REMOVED. +/// Please see LArG4::H62004HECSDTool instead. +/// class LArG4H62004HECSDTool : public LArG4SDTool { public: // Constructor LArG4H62004HECSDTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~LArG4H62004HECSDTool() {} + virtual StatusCode initializeCalculators() override final; + // Method in which all the SDs are created and assigned to the relevant volumes StatusCode initializeSD() override final; @@ -32,7 +38,7 @@ class LArG4H62004HECSDTool : public LArG4SDTool private: // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<LArHitContainer> m_HitColl; - + ServiceHandle<ILArCalculatorSvc> m_calculator; LArG4SimpleSD* m_wheelSD; }; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.cc index c067a6aee88d..7adee5eaccd3 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.cc @@ -8,15 +8,13 @@ #include "CxxUtils/make_unique.h" -// All the calculators that I need -#include "LArG4EC/CalibrationCalculator.h" -#include "LArG4HEC/LocalCalibrationCalculator.h" -#include "LArFCAL1H62004CalibCalculator.h" -#include "LArFCAL2H62004CalibCalculator.h" - LArG4H62004InactiveSDTool::LArG4H62004InactiveSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArCalibrationHitInactive") + , m_emepiwcalc("EMECPosInnerWheelCalibrationCalculator", name) + , m_heccalc("LocalCalibrationInactiveCalculator", name) + , m_fcal1calc("LArFCAL1H62004CalibCalculator", name) + , m_fcal2calc("LArFCAL2H62004CalibCalculator", name) , m_emecSD(nullptr) , m_hecSD(nullptr) , m_fcal1SD(nullptr) @@ -26,16 +24,29 @@ LArG4H62004InactiveSDTool::LArG4H62004InactiveSDTool(const std::string& type, co declareProperty("HECVolumes",m_hecVolumes); declareProperty("FCAL1Volumes",m_fcal1Volumes); declareProperty("FCAL2Volumes",m_fcal2Volumes); + declareProperty("EMECPosIWCalibrationCalculator", m_emepiwcalc); + declareProperty("HECWheelInactiveCalculator", m_heccalc); + declareProperty("FCAL1CalibCalculator", m_fcal1calc); + declareProperty("FCAL2CalibCalculator", m_fcal2calc); declareInterface<ISensitiveDetector>(this); } +StatusCode LArG4H62004InactiveSDTool::initializeCalculators() +{ + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + return StatusCode::SUCCESS; +} + StatusCode LArG4H62004InactiveSDTool::initializeSD() { // Setup calculator and collection - if (m_emecVolumes.size()>0) m_emecSD = new LArG4H62004CalibSD( "LAr::EMEC::InnerModule::Inactive::H6" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel,1) , m_doPID ); - if (m_hecVolumes.size()>0) m_hecSD = new LArG4H62004CalibSD( "LAr::HEC::Local::Inactive::H6" , new LArG4::HEC::LocalCalibrationCalculator(LArG4::HEC::kLocInactive) , m_doPID ); - if (m_fcal1Volumes.size()>0) m_fcal1SD = new LArG4H62004CalibSD( "LAr::FCAL::Inactive1::H6" , LArFCAL1H62004CalibCalculator::GetCalculator() , m_doPID ); - if (m_fcal2Volumes.size()>0) m_fcal2SD = new LArG4H62004CalibSD( "LAr::FCAL::Inactive2::H6" , LArFCAL2H62004CalibCalculator::GetCalculator() , m_doPID ); + if (m_emecVolumes.size()>0) m_emecSD = new LArG4H62004CalibSD( "LAr::EMEC::InnerModule::Inactive::H6" , &*m_emepiwcalc , m_doPID ); + if (m_hecVolumes.size()>0) m_hecSD = new LArG4H62004CalibSD( "LAr::HEC::Local::Inactive::H6" , &*m_heccalc , m_doPID ); + if (m_fcal1Volumes.size()>0) m_fcal1SD = new LArG4H62004CalibSD( "LAr::FCAL::Inactive1::H6" , &*m_fcal1calc , m_doPID ); + if (m_fcal2Volumes.size()>0) m_fcal2SD = new LArG4H62004CalibSD( "LAr::FCAL::Inactive2::H6" , &*m_fcal2calc , m_doPID ); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; if (m_emecVolumes.size()>0) configuration[m_emecSD] = &m_emecVolumes; @@ -43,7 +54,7 @@ StatusCode LArG4H62004InactiveSDTool::initializeSD() if (m_fcal1Volumes.size()>0) configuration[m_fcal1SD] = &m_fcal1Volumes; if (m_fcal2Volumes.size()>0) configuration[m_fcal2SD] = &m_fcal2Volumes; setupAllSDs(configuration); - + // make sure they have the identifiers they need if (m_emecVolumes.size()>0) setupHelpers(m_emecSD); if (m_hecVolumes.size()>0) setupHelpers(m_hecSD); diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.h index 786b1bee895e..9984c4d6d8d1 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004InactiveSDTool.h @@ -11,18 +11,24 @@ #include "StoreGate/WriteHandle.h" #include "CaloSimEvent/CaloCalibrationHitContainer.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" class LArG4CalibSD; +/// DEPRECATED AND WILL BE REMOVED. +/// Please see LArG4::H62004InactiveSDTool instead. +/// class LArG4H62004InactiveSDTool : public LArG4SDTool { public: // Constructor LArG4H62004InactiveSDTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~LArG4H62004InactiveSDTool() {} + virtual StatusCode initializeCalculators() override final; + // Method in which all the SDs are created and assigned to the relevant volumes StatusCode initializeSD() override final; @@ -33,6 +39,11 @@ class LArG4H62004InactiveSDTool : public LArG4SDTool // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; + ServiceHandle<ILArCalibCalculatorSvc>m_emepiwcalc; + ServiceHandle<ILArCalibCalculatorSvc>m_heccalc; + ServiceHandle<ILArCalibCalculatorSvc>m_fcal1calc; + ServiceHandle<ILArCalibCalculatorSvc>m_fcal2calc; + // The list of volumes and the corresponding SDs LArG4CalibSD* m_emecSD; LArG4CalibSD* m_hecSD; @@ -45,7 +56,7 @@ class LArG4H62004InactiveSDTool : public LArG4SDTool /// Am I running with particle ID calibration hits? //bool m_particleId; - + }; #endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.cc index 15ce89774988..0959901878e6 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.cc @@ -4,7 +4,7 @@ #include "LArG4H62004SD.h" -#include "LArG4Code/LArVCalculator.h" +#include "LArG4Code/ILArCalculatorSvc.h" #include "G4Step.hh" #include "G4ios.hh" @@ -13,7 +13,7 @@ #undef DEBUG_ME -LArG4H62004SD::LArG4H62004SD(G4String a_name, LArVCalculator* calc, const std::string& type, const float width) +LArG4H62004SD::LArG4H62004SD(G4String a_name, ILArCalculatorSvc* calc, const std::string& type, const float width) : LArG4SimpleSD(a_name,calc,type,width) { @@ -42,7 +42,8 @@ G4bool LArG4H62004SD::ProcessHits(G4Step* a_step,G4TouchableHistory* /*ROhist*/) if (edep == 0.) return false; // Convert the G4Step into (eta,phi,sampling). - G4bool valid = m_calculator->Process(a_step); + std::vector<LArHitData> hdata; + G4bool valid = m_calculator->Process(a_step, hdata); // Check that hit was valid. (It might be invalid if, for example, // it occurred outside the sensitive region. If such a thing @@ -58,15 +59,15 @@ G4bool LArG4H62004SD::ProcessHits(G4Step* a_step,G4TouchableHistory* /*ROhist*/) // A calculator can determine that a given energy deposit results // in more than one hit in the simulation. FOr each such hit... bool result = true; - for(int ihit=0;ihit<m_calculator->getNumHits();ihit++) + for(auto larhit : hdata) { - LArG4Identifier ident = m_calculator->identifier(ihit); + LArG4Identifier ident = larhit.id; if(ident[0] == 10) { // dead hit, where to put it ? // probably skip in the regular container continue; } - G4double time = m_calculator->time(ihit); - G4double energy = m_calculator->energy(ihit); + G4double time = larhit.time; + G4double energy = larhit.energy; // Changing the ident to comply with H6 dictionary if(ident[1] == 1) { // EMEC module ident[6] += 20; // change phi id @@ -80,11 +81,10 @@ G4bool LArG4H62004SD::ProcessHits(G4Step* a_step,G4TouchableHistory* /*ROhist*/) if(ident[3]==1 && ident[5] > 2) ident[5]=2; } } - + result = result && SimpleHit( ident, time, energy ); - + }// for each hit return by the calculator. return result; } - diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.h index d9a16eaddc28..2f497465aa4d 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H62004SD.h @@ -9,7 +9,7 @@ #include "LArG4Code/LArG4SimpleSD.h" // Forward declarations. -class LArVCalculator; +class ILArCalculatorSvc; class G4Step; class G4TouchableHistory; @@ -17,7 +17,7 @@ class G4TouchableHistory; class LArG4H62004SD : public LArG4SimpleSD { public: - LArG4H62004SD(G4String name, LArVCalculator* calc, const std::string& type, const float width); + LArG4H62004SD(G4String name, ILArCalculatorSvc* calc, const std::string& type, const float width); virtual ~LArG4H62004SD() {} // The required functions for all sensitive detectors: diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.cc index 7594d5e54c5a..1fc6a31c4f61 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.cc @@ -16,6 +16,8 @@ LArG4H6BeamSDTool::LArG4H6BeamSDTool(const std::string& type, const std::string& G4VSensitiveDetector* LArG4H6BeamSDTool::makeSD() { ATH_MSG_DEBUG( "Initializing SD" ); + //FIXME better to use a configurable property here? + // be smart, and take only last part of the name G4String colname = G4String(name()).strip(G4String::both,':'); if ( colname.contains(':') ) diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.h index b4738cab69d4..3d54cc1a30de 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6BeamSDTool.h @@ -12,7 +12,7 @@ class LArG4H6BeamSDTool : public SensitiveDetectorBase public: LArG4H6BeamSDTool(const std::string& type, const std::string& name, const IInterface *parent); virtual ~LArG4H6BeamSDTool() {} - + G4VSensitiveDetector* makeSD() override final; }; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.cc index f3e9665c98d9..7ae9c3e52083 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.cc @@ -7,20 +7,15 @@ // ATLAS LAr includes #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVG4DetectorParameters.h" - // Geant4 includes +#include "G4NavigationHistory.hh" #include "G4LogicalVolume.hh" #include "G4VPhysicalVolume.hh" #include "G4ThreeVector.hh" #include "G4StepPoint.hh" #include "G4Step.hh" #include "globals.hh" - -#include "G4TransportationManager.hh" -#include "G4Navigator.hh" -#include "G4ios.hh" #include "AthenaKernel/Units.h" #include <cstdlib> @@ -34,86 +29,79 @@ namespace Units = Athena::Units; -LArG4H6COLDTCMod0Calculator* LArG4H6COLDTCMod0Calculator::m_instance = 0; -LArG4H6COLDTCMod0Calculator* LArG4H6COLDTCMod0Calculator::GetInstance() { - if (m_instance == 0) { - m_instance = new LArG4H6COLDTCMod0Calculator(); - } - return m_instance; -} - - // constructor -LArG4H6COLDTCMod0Calculator::LArG4H6COLDTCMod0Calculator() - : m_OOTcut(0) - , m_identifier() +LArG4H6COLDTCMod0Calculator::LArG4H6COLDTCMod0Calculator(const std::string& name, ISvcLocator* pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) , m_FCalSampling(3) - , m_phiModuleStart(90.*CLHEP::deg) - , m_phiModuleEnd(180.*CLHEP::deg) - , m_fullModuleDepth(3.5*8*CLHEP::cm) - , m_fullActiveDepth(0.2*CLHEP::cm) - , m_innerActiveRadius(8.6*CLHEP::cm) - , m_outerActiveRadius(45.05*CLHEP::cm) - , m_areaActive(95.994*CLHEP::cm2) + , m_phiModuleStart(90.*Units::deg) + , m_phiModuleEnd(180.*Units::deg) + , m_fullModuleDepth(3.5*8*Units::cm) + , m_fullActiveDepth(0.2*Units::cm) + , m_innerActiveRadius(8.6*Units::cm) + , m_outerActiveRadius(45.05*Units::cm) + , m_areaActive(95.994*Units::cm2) { - // explicitely do the same stuff as in LArFCALMod0CalculatorBase here + declareProperty("FCalSampling" , m_FCalSampling); + declareProperty("phiModuleStart" , m_phiModuleStart); + declareProperty("phiModuleEnd" , m_phiModuleEnd); + declareProperty("fullModuleDepth" , m_fullModuleDepth); + declareProperty("fullActiveDepth" , m_fullActiveDepth); + declareProperty("innerActiveRadius" , m_innerActiveRadius); + declareProperty("outerActiveRadius" , m_outerActiveRadius); + declareProperty("areaActive" , m_areaActive); +} +StatusCode LArG4H6COLDTCMod0Calculator::initialize() +{ // get channel map - LArG4H6COLDTCMod0ChannelMap theMap(m_innerActiveRadius, - m_outerActiveRadius, - m_areaActive, - m_phiModuleStart, - m_phiModuleEnd, - 8); - m_channelMap = theMap; - - m_time = 0.; - m_energy = 0.; - m_isInTime = false; - + m_channelMap = LArG4H6COLDTCMod0ChannelMap(m_innerActiveRadius, + m_outerActiveRadius, + m_areaActive, + m_phiModuleStart, + m_phiModuleEnd, + 8); + + return StatusCode::SUCCESS; } // hit processing -G4bool LArG4H6COLDTCMod0Calculator::Process(const G4Step* a_step) +G4bool LArG4H6COLDTCMod0Calculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const { - + hdata.clear(); + LArHitData larhit; // Given a G4Step, determine the cell identifier. - + // 29-Mar-2002 WGS: this method now returns a boolean. If it's // true, the hit is valid; if it's false, there was some problem // with the hit and it should be ignored. // First, get the energy. - m_energy = a_step->GetTotalEnergyDeposit(); + larhit.energy = a_step->GetTotalEnergyDeposit(); // Find out how long it took the energy to get here. G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4double timeOfFlight = (pre_step_point->GetGlobalTime() + + G4double timeOfFlight = (pre_step_point->GetGlobalTime() + post_step_point->GetGlobalTime()) * 0.5; G4ThreeVector startPoint = pre_step_point->GetPosition(); G4ThreeVector endPoint = post_step_point->GetPosition(); G4ThreeVector p = (startPoint + endPoint) * 0.5; - + // Determine if the hit was in-time. - m_time = timeOfFlight/Units::ns - p.mag()/Units::c_light/Units::ns; - if (m_time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; - + larhit.time = timeOfFlight/Units::ns - p.mag()/Units::c_light/Units::ns; + // get local coordinates - /* - G4Navigator* theNavigator = + /* + G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()-> GetNavigatorForTracking(); - + G4ThreeVector theLocalPoint = theNavigator-> GetGlobalToLocalTransform(). TransformPoint(p); */ G4ThreeVector theLocalPoint = pre_step_point->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(p); - + ///////////////////////////////////// // // For the cold tailcatcher: @@ -125,13 +113,13 @@ G4bool LArG4H6COLDTCMod0Calculator::Process(const G4Step* a_step) // 8 radial bins (range [0,7]) (consult with Seligman on coordinate // system transformation!) // - ///////////////////////////////////// + ///////////////////////////////////// // Strip the name of the volume: G4String hitVolume = pre_step_point->GetTouchable()->GetVolume(0)->GetName(); if(hitVolume.contains("::") ) { int last = hitVolume.last(':'); hitVolume.remove(0,last+1); - } + } int volnum = 0; if( hitVolume == "Gap") { volnum = pre_step_point->GetTouchable()->GetVolume(0)->GetCopyNo()-1; @@ -152,7 +140,7 @@ G4bool LArG4H6COLDTCMod0Calculator::Process(const G4Step* a_step) } else { etaIndex = int(etaIndex/4) + 8; } -// std::cout<<" etaIndex: "<<etaIndex<<" phiIndex: "<<phiIndex<<std::endl; +// std::cout<<" etaIndex: "<<etaIndex<<" phiIndex: "<<phiIndex<<std::endl; // zSide is negative if z<0. G4int zSide = p.z() < 0 ? -2 : 2; G4int sampling = m_FCalSampling; @@ -161,40 +149,32 @@ G4bool LArG4H6COLDTCMod0Calculator::Process(const G4Step* a_step) // // Cold TailCatcher: // - // sampling = 3 // fake FCal3 + // sampling = 3 // fake FCal3 // etaIndex = (radial bin #) // phiIndex = (azimuthal bin #) // ///////////////////////////////////////////////// - m_identifier.clear(); + larhit.id.clear(); if((etaIndex > 7 && phiIndex > 7) || (etaIndex <=7 && phiIndex <= 7)) { - std::cout<<"LArCOLDTCMod0Calculator::Process: Bad identifier !!!"<<std::endl; + std::cout<<"LArCOLDTCMod0Calculator::Process: Bad identifier !!!"<<std::endl; return false; } else { // Append the values to the empty identifier. // if(hitVolume == "Active") { - m_identifier << 4 // LArCalorimeter (same for cold TC) - << 3 // LArFCAL (same for cold TC) - << zSide // EndCap (same for cold TC) - << sampling // FCal Module # (3 for cold TC) - << etaIndex // (see above) - << phiIndex; // (see above) + larhit.id << 4 // LArCalorimeter (same for cold TC) + << 3 // LArFCAL (same for cold TC) + << zSide // EndCap (same for cold TC) + << sampling // FCal Module # (3 for cold TC) + << etaIndex // (see above) + << phiIndex; // (see above) // } else { // DeadM id. -// m_identifier << 10 -// << ; +// larhit.id << 10 +// << ; // } - + hdata.push_back(larhit); return true; } } - -G4bool LArG4H6COLDTCMod0Calculator::Process(const G4Step*, std::vector<LArHitData>&) -{ - std::cout << "Not implemented!" << std::endl; - throw; - return false; -} - diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.h index 888d5875d630..8d57dfcb63c9 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0Calculator.h @@ -12,89 +12,50 @@ #define LArG4H6COLDTCMod0Calculator_H #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" - - -#include "G4TransportationManager.hh" -#include "G4Navigator.hh" -#include "G4ios.hh" +#include "LArG4Code/LArCalculatorSvcImp.h" #include "globals.hh" #include "LArG4H6COLDTCMod0ChannelMap.h" -#include <stdexcept> +//#include <stdexcept> -class LArG4H6COLDTCMod0Calculator: public LArVCalculator +class LArG4H6COLDTCMod0Calculator : public LArCalculatorSvcImp { public: - static LArG4H6COLDTCMod0Calculator* GetInstance(); - + LArG4H6COLDTCMod0Calculator(const std::string& name, ISvcLocator* pSvcLocator); + virtual StatusCode initialize() override final; // destructor virtual ~LArG4H6COLDTCMod0Calculator() { }; // - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } - - virtual G4bool Process(const G4Step*); - virtual G4bool Process(const G4Step*, std::vector<LArHitData>&); - virtual const LArG4Identifier& identifier() const {return m_identifier;} - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_identifier; - } + virtual G4float OOTcut() const override final { return m_OOTcut; } + // virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } //FIXME public, but not part of interface - virtual G4double time() const {return m_time;} - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_time; - } - virtual G4double energy() const {return m_energy;} - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_energy; - } - virtual G4bool isInTime() const {return m_isInTime;} - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime() const { return ( ! m_isInTime );} - virtual G4bool isOutOfTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - - // access module parameters ---> bulk absorber = Cu - virtual G4double GetModulePhiStart() const - { return m_phiModuleStart; } - virtual G4double GetModulePhiEnd() const - { return m_phiModuleEnd; } + virtual G4bool Process(const G4Step*, std::vector<LArHitData>&) const override final; - // access active medium ---> readout gap = LAr - virtual G4double GetActiveDepth() const - { return m_fullActiveDepth; } - virtual G4double GetActiveInnerRadius() const - { return m_innerActiveRadius; } - virtual G4double GetActiveOuterRadius() const - { return m_outerActiveRadius; } + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); + } -protected: + // // access module parameters ---> bulk absorber = Cu + // virtual G4double GetModulePhiStart() const //FIXME public, but not part of interface + // { return m_phiModuleStart; } + // virtual G4double GetModulePhiEnd() const //FIXME public, but not part of interface + // { return m_phiModuleEnd; } - LArG4H6COLDTCMod0Calculator(); + // // access active medium ---> readout gap = LAr + // virtual G4double GetActiveDepth() const //FIXME public, but not part of interface + // { return m_fullActiveDepth; } + // virtual G4double GetActiveInnerRadius() const //FIXME public, but not part of interface + // { return m_innerActiveRadius; } + // virtual G4double GetActiveOuterRadius() const //FIXME public, but not part of interface + // { return m_outerActiveRadius; } private: - static LArG4H6COLDTCMod0Calculator* m_instance; // private datamember handling the hit - G4float m_OOTcut; - - G4double m_time; - G4double m_energy; - G4bool m_isInTime; - LArG4Identifier m_identifier; G4int m_FCalSampling; // geometry of ColdTC: overall diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.cc index 5e3eb15ea85b..636c6142a8cc 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.cc @@ -3,48 +3,55 @@ */ #include "LArG4H6COLDTCMod0CalibCalculator.h" - +#include "LArG4Code/ILArCalculatorSvc.h" #include "G4Step.hh" -LArG4H6COLDTCMod0CalibCalculator::LArG4H6COLDTCMod0CalibCalculator() { - - // Initialize the geometry calculator. - m_Calculator = LArG4H6COLDTCMod0Calculator::GetInstance(); +LArG4H6COLDTCMod0CalibCalculator::LArG4H6COLDTCMod0CalibCalculator(const std::string& name, ISvcLocator* pSvcLocator) +: LArCalibCalculatorSvcImp(name, pSvcLocator) +, m_Calculator("LArG4H6COLDTCMod0Calculator", name) +{ + declareProperty("Calculator", m_Calculator); +} +StatusCode LArG4H6COLDTCMod0CalibCalculator::initialize() +{ + // Initialize the geometry calculator. + ATH_CHECK(m_Calculator.retrieve()); + return StatusCode::SUCCESS; } - -LArG4H6COLDTCMod0CalibCalculator::~LArG4H6COLDTCMod0CalibCalculator(){} + +LArG4H6COLDTCMod0CalibCalculator::~LArG4H6COLDTCMod0CalibCalculator(){} -G4bool LArG4H6COLDTCMod0CalibCalculator::Process( const G4Step* a_step, const eCalculatorProcessing a_process ) +G4bool LArG4H6COLDTCMod0CalibCalculator::Process( const G4Step* a_step, LArG4Identifier & identifier, + std::vector<G4double> & energies, const LArG4::eCalculatorProcessing a_process ) const { - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - m_identifier = LArG4Identifier(); - // Calculate the identifier. - if(m_Calculator->Process(a_step)) m_identifier = m_Calculator->identifier(0); - else m_identifier = LArG4Identifier(); - } - else - m_identifier = LArG4Identifier(); - - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) { - std::cout<<"LArG4H6COLDTCMod0CalibCalculator::Process return false !!!"<<std::endl; - return false; - } - - return true; + energies.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyEnergy ) + { + m_energyCalculator.Energies( a_step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + identifier = LArG4Identifier(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyID ) + { + // Calculate the identifier. + std::vector<LArHitData> hdata; + if(m_Calculator->Process(a_step, hdata)) + { + if(hdata.size()>0) identifier = hdata[0].id; + } + } + + // Check for bad result. + if ( identifier == LArG4Identifier() ) { + std::cout<<"LArG4H6COLDTCMod0CalibCalculator::Process return false !!!"<<std::endl; + return false; + } + + return true; } - diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.h index 09cf15027312..c28873c8b996 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0CalibCalculator.h @@ -2,42 +2,35 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef LArG4H6COLDTCMod0CalibCalculator_H -#define LArG4H6COLDTCMod0CalibCalculator_H +#ifndef LARG4H6SD_LArG4H6COLDTCMod0CalibCalculator_H +#define LARG4H6SD_LArG4H6COLDTCMod0CalibCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4H6COLDTCMod0Calculator.h" - +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" - #include "globals.hh" - #include <vector> -class LArG4H6COLDTCMod0CalibCalculator : public LArG4::VCalibrationCalculator { +class ILArCalculatorSvc; +class G4Step; -public: +class LArG4H6COLDTCMod0CalibCalculator : public LArCalibCalculatorSvcImp { - LArG4H6COLDTCMod0CalibCalculator(); - virtual ~LArG4H6COLDTCMod0CalibCalculator(); +public: - virtual G4bool Process(const G4Step*, const eCalculatorProcessing p = kEnergyAndID); - virtual const LArG4Identifier& identifier() const {return m_identifier;} - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_identifier; - } - virtual const std::vector<G4double>& energies() const { return m_energies; } + LArG4H6COLDTCMod0CalibCalculator(const std::string& name, ISvcLocator* pSvcLocator); + virtual StatusCode initialize() override final; + virtual ~LArG4H6COLDTCMod0CalibCalculator(); - private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; + virtual G4bool Process(const G4Step*, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing p = LArG4::kEnergyAndID) const override final; - LArG4H6COLDTCMod0Calculator* m_Calculator; +private: + ServiceHandle<ILArCalculatorSvc> m_Calculator; //LArG4H6COLDTCMod0Calculator - CaloG4::SimulationEnergies m_energyCalculator; + CaloG4::SimulationEnergies m_energyCalculator; }; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.cc index 3723eea85213..3e54c7db3c76 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.cc @@ -13,15 +13,15 @@ #undef DEBUG_ME LArG4H6COLDTCMod0ChannelMap::LArG4H6COLDTCMod0ChannelMap() -: m_phiMax(0), m_phiMin(0), - m_nPhiBins(0) { } + : m_phiMax(0), m_phiMin(0), + m_nPhiBins(0) { } LArG4H6COLDTCMod0ChannelMap::LArG4H6COLDTCMod0ChannelMap(G4double rMin, - G4double rMax, - G4double area, - G4double phiMin, - G4double phiMax, - G4int nPhis) + G4double rMax, + G4double area, + G4double phiMin, + G4double phiMax, + G4int nPhis) : m_phiMax(phiMax) , m_phiMin(phiMin) , m_nPhiBins(nPhis) @@ -35,22 +35,22 @@ LArG4H6COLDTCMod0ChannelMap::LArG4H6COLDTCMod0ChannelMap(G4double rMin, std::cout<<phiMax<<"/"<<phiMin<<"/"<<nPhis<<"/"<<m_nPhiBins<<std::endl; #endif // calculate radial bins - G4double r = deltaPhi > 0 + G4double r = deltaPhi > 0 ? rMin : rMax; const G4double delta = 2 * area / deltaPhi; for ( ; r < rMax ; r = sqrt( delta + r * r ) ) { -// std::cout<<r<<std::endl; + // std::cout<<r<<std::endl; m_rBins.push_back(r); } -// std::cout<<rMax<<std::endl; + // std::cout<<rMax<<std::endl; m_rBins.push_back(rMax); } LArG4H6COLDTCMod0ChannelMap::~LArG4H6COLDTCMod0ChannelMap() { } -G4int LArG4H6COLDTCMod0ChannelMap::getRBin(const G4ThreeVector& aPoint) +G4int LArG4H6COLDTCMod0ChannelMap::getRBin(const G4ThreeVector& aPoint) const { size_t index = 0; @@ -67,17 +67,17 @@ G4int LArG4H6COLDTCMod0ChannelMap::getRBin(const G4ThreeVector& aPoint) : -1; } -G4int LArG4H6COLDTCMod0ChannelMap::getPhiBin(const G4ThreeVector& aPoint) +G4int LArG4H6COLDTCMod0ChannelMap::getPhiBin(const G4ThreeVector& aPoint) const { - if ( aPoint.phi() < m_phiMax ) + if ( aPoint.phi() < m_phiMax ) { G4int index = static_cast<int> (floor((aPoint.phi()-m_phiMin)*m_nPhiBins/(m_phiMax-m_phiMin))); #ifdef DEBUG_ME std::cout<<"LArG4H6COLDTCMod0ChannelMap::getPhiBin: "<<aPoint.phi()<<" / "<<index<<std::endl; #endif return index >= 0 - ? index - : -1; + ? index + : -1; } else { diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.h index 0e161fa1d598..8fa08fa7c17f 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6COLDTCMod0ChannelMap.h @@ -18,10 +18,10 @@ class LArG4H6COLDTCMod0ChannelMap G4double phiMin, G4double phiMax, G4int nPhis); ~LArG4H6COLDTCMod0ChannelMap(); - G4int getRBin(const G4ThreeVector& aPoint); + G4int getRBin(const G4ThreeVector& aPoint) const; G4int getNoRBins() const { return m_rBins.size(); } const std::vector<G4double>& getRBinning() { return m_rBins; } - G4int getPhiBin(const G4ThreeVector& aPoint); + G4int getPhiBin(const G4ThreeVector& aPoint) const; G4int getNoPhiBins() const { return m_nPhiBins; } private: diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.cc index 4c6d30cdf6f5..2deaf5f9dac6 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.cc @@ -4,7 +4,7 @@ #include "LArG4H6WarmTCCalculator.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVG4DetectorParameters.h" +// #include "LArG4Code/LArVG4DetectorParameters.h" #include "G4ThreeVector.hh" #include "G4StepPoint.hh" @@ -16,145 +16,122 @@ #include "AthenaKernel/Units.h" #include "globals.hh" -// 03-Jan-2002 WGS: For 'copysign'. -// #include "LArG4Code/ansi-compliance.h" #include <cmath> namespace Units = Athena::Units; -LArG4H6WarmTCCalculator::LArG4H6WarmTCCalculator(WTCComp icomp) - :m_identifier(),m_addr(0),m_time(0),m_energy(0),m_isInTime(false) +LArG4H6WarmTCCalculator::LArG4H6WarmTCCalculator(const std::string& name, ISvcLocator* pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + //, m_addr(0) { - // Constructor initializes the geometry. - - m_OOTcut = LArVG4DetectorParameters::GetInstance()->GetValue("LArExpHallOutOfTimeCut"); - - switch(icomp) { - case WTC_X: { m_isX = true; m_isABS = false; break;} - case WTC_Y: { m_isX = false; m_isABS = false; break;} - case WTC_ABS: { m_isX = false; m_isABS = true; break;} - } + declareProperty("isX", m_isX); + declareProperty("isABS", m_isABS); } - -G4bool LArG4H6WarmTCCalculator::Process(const G4Step* a_step) +G4bool LArG4H6WarmTCCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const { - - // First, get the energy. - m_energy = a_step->GetTotalEnergyDeposit(); + hdata.clear(); + LArHitData larhit; + larhit.energy = a_step->GetTotalEnergyDeposit(); // Find out how long it took the energy to get here. G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4double timeOfFlight = (pre_step_point->GetGlobalTime() + + G4double timeOfFlight = (pre_step_point->GetGlobalTime() + post_step_point->GetGlobalTime()) * 0.5; G4ThreeVector startPoint = pre_step_point->GetPosition(); G4ThreeVector endPoint = post_step_point->GetPosition(); G4ThreeVector p = (startPoint + endPoint) * 0.5; -// G4cout<<"LArG4H6WarmTCCalculator::Global point: "<<p.x()<<" "<<p.y()<<" "<<p.z()<<std::endl; - - //m_time = timeOfFlight/ns - p.mag()/c_light/ns; - m_time = timeOfFlight/Units::ns; - if (m_time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; - -// Get local coordinates of the step, independently of how it was positioned in World + // G4cout<<"LArG4H6WarmTCCalculator::Global point: "<<p.x()<<" "<<p.y()<<" "<<p.z()<<std::endl; + //larhit.time = timeOfFlight/ns - p.mag()/c_light/ns; + larhit.time = timeOfFlight/Units::ns; + + // Get local coordinates of the step, independently of how it was positioned in World const G4AffineTransform transformation = - pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); + pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint); G4ThreeVector pinLocal =(startPointinLocal+endPointinLocal)*0.5; // -// G4cout<<"LArG4H6WarmTCCalculator::Local point: "<<pinLocal.x()<<" "<<pinLocal.y()<<" "<<pinLocal.z()<<std::endl; + // G4cout<<"LArG4H6WarmTCCalculator::Local point: "<<pinLocal.x()<<" "<<pinLocal.y()<<" "<<pinLocal.z()<<std::endl; G4int zSide; G4int sampling; G4int region; - G4int etaBin; - G4int phiBin; - - zSide = 4; - if( p.z()<0.) zSide =-4; - region = 0; + G4int etaBin; + G4int phiBin; + + zSide = 4; + if( p.z()<0.) zSide =-4; + region = 0; // We can extract our position from the copy number of depth and module // First have touchable // G4TouchableHistory* theTouchable = (G4TouchableHistory*) (pre_step_point->GetTouchable()); - // Volume name + // Volume name G4String hitVolume = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); // And copy number G4int copyModule = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); G4int gran; -// Sampling Identifier + // Sampling Identifier if(m_isABS) { sampling = copyModule; gran = 1; } else { - switch(copyModule) { - case 1: { - gran = 1; - if(m_isX) sampling = copyModule; else sampling = copyModule + 1; - break; - } - case 2: case 3: { - gran = 2; - if(m_isX) sampling = 2*copyModule; else sampling = 2*copyModule - 1; - break; - } - default: { sampling = -1; gran = 0; break; } - } + switch(copyModule) { + case 1: { + gran = 1; + if(m_isX) sampling = copyModule; else sampling = copyModule + 1; + break; + } + case 2: case 3: { + gran = 2; + if(m_isX) sampling = 2*copyModule; else sampling = 2*copyModule - 1; + break; + } + default: { sampling = -1; gran = 0; break; } + } } - -//#include "LArG4TBEndcap/LArTBEndcapWTC.icc" + //#include "LArG4TBEndcap/LArTBEndcapWTC.icc" // This should go int Db: double WTC_sci_x = 190.0*CLHEP::mm; double WTC_sci_y = 1160.0*CLHEP::mm; double x_x = 6 * WTC_sci_x / 2; - double x_y = WTC_sci_y / 2; - + double x_y = WTC_sci_y / 2; + if(m_isX) { - etaBin = int((x_y - pinLocal.y()) / (5*gran*WTC_sci_x)); - phiBin = int((x_x - pinLocal.x()) / (gran*WTC_sci_x)); + etaBin = int((x_y - pinLocal.y()) / (5*gran*WTC_sci_x)); + phiBin = int((x_x - pinLocal.x()) / (gran*WTC_sci_x)); } else { - phiBin = int((x_y - pinLocal.y()) / (5*gran*WTC_sci_x)); - etaBin = int((x_x - pinLocal.x()) / (gran*WTC_sci_x)); + phiBin = int((x_y - pinLocal.y()) / (5*gran*WTC_sci_x)); + etaBin = int((x_x - pinLocal.x()) / (gran*WTC_sci_x)); } region = 0; - - /* - if(!m_isABS) { + + /* + if(!m_isABS) { std::cout<<"LArG4H6WarmTCCalculator: "<<hitVolume<<" "<<copyModule<<" : "<<pinLocal.x()<<" "<<pinLocal.y()<<std::endl; std::cout <<"zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << - " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; + " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; std::cout<<m_energy<<" "<<m_time<<std::endl; std::cout<<m_isInTime<<" "<<m_isX<<" "<<m_isABS<<" "<<this<<std::endl; - } + } */ - - m_identifier.clear(); - m_identifier << 10 // LArCalorimeter - << zSide - << 1 - << sampling - << region - << etaBin - << phiBin; - - m_addr = 100*sampling+10*etaBin+phiBin; - if(m_isABS) m_addr *= -1; - return true; -} -G4bool LArG4H6WarmTCCalculator::Process(const G4Step*, std::vector<LArHitData>&) -{ - std::cout << "Not implemented!" << std::endl; - throw; + larhit.id.clear(); + larhit.id << 10 // LArCalorimeter + << zSide + << 1 + << sampling + << region + << etaBin + << phiBin; + hdata.push_back(larhit); + // m_addr = 100*sampling+10*etaBin+phiBin; + // if(m_isABS) m_addr *= -1; + return true; } - - diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.h index 3d80efc006bd..2bf4393f4112 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCCalculator.h @@ -5,73 +5,33 @@ #ifndef __LArG4H6WarmTCCalculator_H__ #define __LArG4H6WarmTCCalculator_H__ -#include "globals.hh" -#include "G4ThreeVector.hh" -#include "LArG4Code/LArVCalculator.h" +#include "LArG4Code/LArCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include <stdexcept> -enum WTCComp { - WTC_X, // X - coordinate scintilator - WTC_Y, // Y - coordinate scintilator - WTC_ABS // Absorbers -}; // Forward declarations. class G4Step; -class LArG4H6WarmTCCalculator : public LArVCalculator { +class LArG4H6WarmTCCalculator : public LArCalculatorSvcImp +{ public: - LArG4H6WarmTCCalculator(WTCComp icomp = WTC_ABS); - - + LArG4H6WarmTCCalculator(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~LArG4H6WarmTCCalculator() {}; ///////////////////////////////////////////// - // The interface for LArVCalculator. + // The interface for ILArCalculatorSvc. - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } + virtual G4float OOTcut() const override final { return m_OOTcut; } - virtual G4bool Process(const G4Step* a_step); - virtual G4bool Process(const G4Step*, std::vector<LArHitData>&); - G4int address() const { return m_addr;} - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_identifier; - } + virtual G4bool Process(const G4Step*, std::vector<LArHitData>&) const override final; - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_energy; - }; - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); } - virtual G4bool isOutOfTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - bool isX() const { return m_isX; } - bool isABS() const { return m_isABS; } - private: - - float m_OOTcut; - LArG4Identifier m_identifier; - int m_addr; - - double m_time; - double m_energy; - bool m_isInTime; bool m_isX; bool m_isABS; - }; #endif diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.cc index cb10ad39219f..0ec3b1e361ec 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.cc @@ -15,8 +15,9 @@ LArG4H6WarmTCSDTool::LArG4H6WarmTCSDTool(const std::string& type, const std::str G4VSensitiveDetector* LArG4H6WarmTCSDTool::makeSD() { - ATH_MSG_DEBUG( "Initializing SD" ); - + ATH_MSG_DEBUG( "Initializing SD" ); + //FIXME use configurable properties here + // be smart, and take only last part of the name G4String colname = ""; if(name().find("::Abs")!=std::string::npos){ diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.h index fbd0cb27778a..a2c5dc7dcb07 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4H6WarmTCSDTool.h @@ -12,7 +12,7 @@ class LArG4H6WarmTCSDTool : public SensitiveDetectorBase public: LArG4H6WarmTCSDTool(const std::string& type, const std::string& name, const IInterface *parent); ~LArG4H6WarmTCSDTool() {} - + G4VSensitiveDetector* makeSD() override final; // Calls down to all the SDs to get them to pack their hits into a central collection diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChCalculator.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChCalculator.cc index f446ec65b249..a30ac65cb485 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChCalculator.cc @@ -13,36 +13,36 @@ LArG4TBECBeamChCalculator::LArG4TBECBeamChCalculator(void) { - m_number = -1; - m_x = 0.; - m_y = 0.; - G4cout << "LArG4TBECBeamChCalculator ready" << G4endl; + m_number = -1; + m_x = 0.; + m_y = 0.; + G4cout << "LArG4TBECBeamChCalculator ready" << G4endl; } G4bool LArG4TBECBeamChCalculator::Process(const G4Step* step) { - G4StepPoint* pre_step_point = step->GetPreStepPoint(); - G4StepPoint* post_step_point = step->GetPostStepPoint(); - - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - G4VPhysicalVolume *prev = pre_step_point->GetPhysicalVolume(); - G4String volume = prev->GetName(); - const char *name = volume.c_str(); - - m_number = int(name[strlen(name) - 1]) - 0x30; - m_x = p.getX(); - m_y = p.getY(); - if(fabs(m_x) > 50.*CLHEP::mm || fabs(m_y) > 50.*CLHEP::mm){ - G4cout << "BeamCh(" << m_number - << ") hit is out of 100x100 region" << G4endl; - return false; - } - -// G4cout << "Identifier(" << m_number << ") -> (" -// << m_x << ", " << m_y << ")" << G4endl; - - return true; + G4StepPoint* pre_step_point = step->GetPreStepPoint(); + G4StepPoint* post_step_point = step->GetPostStepPoint(); + + G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4ThreeVector endPoint = post_step_point->GetPosition(); + G4ThreeVector p = (startPoint + endPoint) * 0.5; + + G4VPhysicalVolume *prev = pre_step_point->GetPhysicalVolume(); + G4String volume = prev->GetName(); + const char *name = volume.c_str(); + + m_number = int(name[strlen(name) - 1]) - 0x30; + m_x = p.getX(); + m_y = p.getY(); + if(fabs(m_x) > 50.*CLHEP::mm || fabs(m_y) > 50.*CLHEP::mm){ + G4cout << "BeamCh(" << m_number + << ") hit is out of 100x100 region" << G4endl; + return false; + } + + //G4cout << "Identifier(" << m_number << ") -> (" + // << m_x << ", " << m_y << ")" << G4endl; + + return true; } diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChSDTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChSDTool.h index 556f4c9071f9..551855284d33 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArG4TBECBeamChSDTool.h @@ -14,7 +14,7 @@ class LArG4TBECBeamChSDTool : public SensitiveDetectorBase public: LArG4TBECBeamChSDTool(const std::string& type, const std::string& name, const IInterface *parent); ~LArG4TBECBeamChSDTool() {} - + G4VSensitiveDetector* makeSD() override final; }; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004EventActionTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004EventActionTool.cc index 583c08f47ec8..e0e923c2995e 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004EventActionTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004EventActionTool.cc @@ -61,4 +61,4 @@ namespace G4UA return ActionToolBase<LArGeoH62004EventAction>::queryInterface(riid, ppvIf); } -} +} \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingAction.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingAction.cc index 5a8803beb094..5e0c74209dad 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingAction.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingAction.cc @@ -3,6 +3,7 @@ */ #include "LArGeoH62004SteppingAction.h" +#include "LArG4Code/ILArCalculatorSvc.h" #include "LArG4Code/LArG4SimpleSD.h" #include "LArG4Code/LArG4Identifier.h" #include "G4Track.hh" @@ -146,4 +147,4 @@ namespace G4UA return; } -} // namespace G4UA +} // namespace G4UA \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingActionTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingActionTool.cc index 5228de2537a9..4596a9d32f41 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingActionTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/LArGeoH62004SteppingActionTool.cc @@ -61,4 +61,4 @@ namespace G4UA return ActionToolBase<LArGeoH62004SteppingAction>::queryInterface(riid, ppvIf); } -} +} \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/RadLenNtupleTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/RadLenNtupleTool.cc index cc944d647a72..3eea1861603a 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/RadLenNtupleTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/RadLenNtupleTool.cc @@ -66,4 +66,4 @@ namespace G4UA return ActionToolBase<RadLenNtuple>::queryInterface(riid, ppvIf); } -} +} \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.cc index b46f1f64cc1b..1e8f7d0cec75 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.cc @@ -5,8 +5,6 @@ #include "TBECBackOuterBarretteTool.h" #include "LArG4Code/LArG4SimpleSD.h" -#include "LArG4EC/EnergyCalculator.h" - #include "CxxUtils/make_unique.h" TBECBackOuterBarretteTool::TBECBackOuterBarretteTool(const std::string& type, const std::string& name, const IInterface *parent) @@ -18,6 +16,13 @@ TBECBackOuterBarretteTool::TBECBackOuterBarretteTool(const std::string& type, co , m_HitColl_gap_se("LArHitEMEC_gap_se") , m_HitColl_chcoll("LArHitEMEC_chcoll") , m_HitColl_ropt("LArHitEMEC_ropt") + , m_emecbobgadjcalc("EMECPosBOBWheel_ECOR_GADJCalculator", name) + , m_emecbobgadjoldcalc("EMECPosBOBWheel_ECOR_GADJ_OLDCalculator", name) + , m_emecbobgadjecalc("EMECPosBOBWheel_ECOR_GADJ_ECalculator", name) + , m_emecbobgadjscalc("EMECPosBOBWheel_ECOR_GADJ_SCalculator", name) + , m_emecbobgadjsecalc("EMECPosBOBWheel_ECOR_GADJ_SECalculator", name) + , m_emecbobchclcalc("EMECPosBOBWheel_ECOR_CHCLCalculator", name) + , m_emecbobcalc("EMECPosBOBWheelCalculator", name) , m_gapadjSD(nullptr) , m_gapoldSD(nullptr) , m_gap_eSD(nullptr) @@ -27,18 +32,44 @@ TBECBackOuterBarretteTool::TBECBackOuterBarretteTool(const std::string& type, co , m_roptSD(nullptr) { declareInterface<ISensitiveDetector>(this); + declareProperty("EMECPosBOBWheel_ECOR_GADJCalculator", m_emecbobgadjcalc); + declareProperty("EMECPosBOBWheel_ECOR_GADJ_OLDCalculator", m_emecbobgadjoldcalc); + declareProperty("EMECPosBOBWheel_ECOR_GADJ_ECalculator", m_emecbobgadjecalc); + declareProperty("EMECPosBOBWheel_ECOR_GADJ_SCalculator", m_emecbobgadjscalc); + declareProperty("EMECPosBOBWheel_ECOR_GADJ_SECalculator", m_emecbobgadjsecalc); + declareProperty("EMECPosBOBWheel_ECOR_CHCLCalculator", m_emecbobchclcalc); + declareProperty("EMECPosBOBWheelCalculator", m_emecbobcalc); } +StatusCode TBECBackOuterBarretteTool::initializeCalculators() +{ + ATH_CHECK(m_emecbobgadjcalc.retrieve()); + ATH_CHECK(m_emecbobgadjoldcalc.retrieve()); + ATH_CHECK(m_emecbobgadjecalc.retrieve()); + ATH_CHECK(m_emecbobgadjscalc.retrieve()); + ATH_CHECK(m_emecbobgadjsecalc.retrieve()); + ATH_CHECK(m_emecbobchclcalc.retrieve()); + ATH_CHECK(m_emecbobcalc.retrieve()); + + return StatusCode::SUCCESS; +} StatusCode TBECBackOuterBarretteTool::initializeSD() { - m_gapadjSD = new LArG4SimpleSD( "LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gapadj" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ) , m_timeBinType , m_timeBinWidth ); - m_gapoldSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gapold", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_OLD) , m_timeBinType , m_timeBinWidth); - m_gap_eSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gap_e", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_E) , m_timeBinType , m_timeBinWidth); - m_gap_sSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gap_s", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_S) , m_timeBinType , m_timeBinWidth); - m_gap_seSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gap_se", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_SE) , m_timeBinType , m_timeBinWidth); - m_chcollSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_chcoll", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_CHCL) , m_timeBinType , m_timeBinWidth); - m_roptSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_ropt", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT) , m_timeBinType , m_timeBinWidth); + // Multi-threading not yet supported + if(m_gapadjSD) { + ATH_MSG_ERROR("TBECBackOuterBarretteTool::initializeSD - SDs already exist. " << + "Are you running an MT job? Not yet supported!"); + return StatusCode::FAILURE; + } + + m_gapadjSD = new LArG4SimpleSD( "LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gapadj" , &*m_emecbobgadjcalc, m_timeBinType , m_timeBinWidth ); + m_gapoldSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gapold", &*m_emecbobgadjoldcalc, m_timeBinType , m_timeBinWidth); + m_gap_eSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gap_e", &*m_emecbobgadjecalc, m_timeBinType , m_timeBinWidth); + m_gap_sSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gap_s", &*m_emecbobgadjscalc, m_timeBinType , m_timeBinWidth); + m_gap_seSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_gap_se", &*m_emecbobgadjsecalc, m_timeBinType , m_timeBinWidth); + m_chcollSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_chcoll", &*m_emecbobchclcalc, m_timeBinType , m_timeBinWidth); + m_roptSD = new LArG4SimpleSD("LAr::EMEC::BackOuterBarrette::Module::Phidiv::SDout_ropt", &*m_emecbobcalc, m_timeBinType , m_timeBinWidth); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_gapadjSD] = &m_volumeNames; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.h index 672c75fdd220..9f9ce0467ae3 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECBackOuterBarretteTool.h @@ -11,18 +11,26 @@ #include "StoreGate/WriteHandle.h" #include "LArSimEvent/LArHitContainer.h" +#include "LArG4Code/ILArCalculatorSvc.h" class LArG4SimpleSD; +/// @class TBECBackOuterBarretteTool +/// +/// This implementation has issues in multi-threading and so cannot +/// be used in an MT job. Migration discussion ongoing in ATLASSIM-2606. +/// class TBECBackOuterBarretteTool : public LArG4SDTool { public: // Constructor TBECBackOuterBarretteTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~TBECBackOuterBarretteTool() {} + virtual StatusCode initializeCalculators() override final; + // Method in which all the SDs are created and assigned to the relevant volumes StatusCode initializeSD() override final; @@ -32,7 +40,7 @@ class TBECBackOuterBarretteTool : public LArG4SDTool /** Beginning of an athena event. This is where collection initialization should happen. If we are using a WriteHandle, then this could be empty. */ // StatusCode SetupEvent() override final; - + private: // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<LArHitContainer> m_HitColl_gapadj; @@ -43,6 +51,14 @@ class TBECBackOuterBarretteTool : public LArG4SDTool SG::WriteHandle<LArHitContainer> m_HitColl_chcoll; SG::WriteHandle<LArHitContainer> m_HitColl_ropt; + ServiceHandle<ILArCalculatorSvc> m_emecbobgadjcalc;// LArG4::EMEC_ECOR_GADJ + ServiceHandle<ILArCalculatorSvc> m_emecbobgadjoldcalc;// LArG4::EMEC_ECOR_GADJ_OLD + ServiceHandle<ILArCalculatorSvc> m_emecbobgadjecalc;// LArG4::EMEC_ECOR_GADJ_E + ServiceHandle<ILArCalculatorSvc> m_emecbobgadjscalc;// LArG4::EMEC_ECOR_GADJ_S + ServiceHandle<ILArCalculatorSvc> m_emecbobgadjsecalc;// LArG4::EMEC_ECOR_GADJ_SE + ServiceHandle<ILArCalculatorSvc> m_emecbobchclcalc;// LArG4::EMEC_ECOR_CHCL + ServiceHandle<ILArCalculatorSvc> m_emecbobcalc;// LArG4::EMEC_ECOR_ROPT + // List of volumes for each SD and the corresponding SDs LArG4SimpleSD* m_gapadjSD; LArG4SimpleSD* m_gapoldSD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.cc index a89048c053ec..f2d18e84ef33 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.cc @@ -5,8 +5,6 @@ #include "TBECInnerModuleTool.h" #include "LArG4Code/LArG4SimpleSD.h" -#include "LArG4EC/EnergyCalculator.h" - #include "CxxUtils/make_unique.h" TBECInnerModuleTool::TBECInnerModuleTool(const std::string& type, const std::string& name, const IInterface *parent) @@ -18,6 +16,13 @@ TBECInnerModuleTool::TBECInnerModuleTool(const std::string& type, const std::str , m_HitColl_gap_se("LArHitEMEC_gap_se") , m_HitColl_chcoll("LArHitEMEC_chcoll") , m_HitColl_ropt("LArHitEMEC_ropt") + , m_emecinnergadjcalc("EMECPosInnerWheel_ECOR_GADJCalculator", name) + , m_emecinnergadjoldcalc("EMECPosInnerWheel_ECOR_GADJ_OLDCalculator", name) + , m_emecinnergadjecalc("EMECPosInnerWheel_ECOR_GADJ_ECalculator", name) + , m_emecinnergadjscalc("EMECPosInnerWheel_ECOR_GADJ_SCalculator", name) + , m_emecinnergadjsecalc("EMECPosInnerWheel_ECOR_GADJ_SECalculator", name) + , m_emecinnerchclcalc("EMECPosInnerWheel_ECOR_CHCLCalculator", name) + , m_emecinnercalc("EMECPosInnerWheelCalculator", name) , m_gapadjSD(nullptr) , m_gapoldSD(nullptr) , m_gap_eSD(nullptr) @@ -27,18 +32,43 @@ TBECInnerModuleTool::TBECInnerModuleTool(const std::string& type, const std::str , m_roptSD(nullptr) { declareInterface<ISensitiveDetector>(this); + declareProperty("EMECPosInnerWheel_ECOR_GADJCalculator", m_emecinnergadjcalc); + declareProperty("EMECPosInnerWheel_ECOR_GADJ_OLDCalculator", m_emecinnergadjoldcalc); + declareProperty("EMECPosInnerWheel_ECOR_GADJ_ECalculator", m_emecinnergadjecalc); + declareProperty("EMECPosInnerWheel_ECOR_GADJ_SCalculator", m_emecinnergadjscalc); + declareProperty("EMECPosInnerWheel_ECOR_GADJ_SECalculator", m_emecinnergadjsecalc); + declareProperty("EMECPosInnerWheel_ECOR_CHCLCalculator", m_emecinnerchclcalc); + declareProperty("EMECPosInnerWheelCalculator", m_emecinnercalc); } +StatusCode TBECInnerModuleTool::initializeCalculators() +{ + ATH_CHECK(m_emecinnergadjcalc.retrieve()); + ATH_CHECK(m_emecinnergadjoldcalc.retrieve()); + ATH_CHECK(m_emecinnergadjecalc.retrieve()); + ATH_CHECK(m_emecinnergadjscalc.retrieve()); + ATH_CHECK(m_emecinnergadjsecalc.retrieve()); + ATH_CHECK(m_emecinnerchclcalc.retrieve()); + ATH_CHECK(m_emecinnercalc.retrieve()); + return StatusCode::SUCCESS; +} StatusCode TBECInnerModuleTool::initializeSD() { - m_gapadjSD = new LArG4SimpleSD( "LAr::EMEC::InnerModule::SDin_gapadj" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ) , m_timeBinType , m_timeBinWidth ); - m_gapoldSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gapold", new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_OLD) , m_timeBinType , m_timeBinWidth); - m_gap_eSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gap_e", new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_E) , m_timeBinType , m_timeBinWidth); - m_gap_sSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gap_s", new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_S) , m_timeBinType , m_timeBinWidth); - m_gap_seSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gap_se", new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_SE) , m_timeBinType , m_timeBinWidth); - m_chcollSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_chcoll", new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_CHCL) , m_timeBinType , m_timeBinWidth); - m_roptSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_ropt", new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT) , m_timeBinType , m_timeBinWidth); + // Multi-threading not yet supported + if(m_gapadjSD) { + ATH_MSG_ERROR("TBECInnerModuleTool::initializeSD - SDs already exist. " << + "Are you running an MT job? Not yet supported!"); + return StatusCode::FAILURE; + } + + m_gapadjSD = new LArG4SimpleSD( "LAr::EMEC::InnerModule::SDin_gapadj" , &*m_emecinnergadjcalc, m_timeBinType , m_timeBinWidth ); + m_gapoldSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gapold", &*m_emecinnergadjoldcalc, m_timeBinType , m_timeBinWidth); + m_gap_eSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gap_e", &*m_emecinnergadjecalc, m_timeBinType , m_timeBinWidth); + m_gap_sSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gap_s", &*m_emecinnergadjscalc, m_timeBinType , m_timeBinWidth); + m_gap_seSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_gap_se", &*m_emecinnergadjsecalc, m_timeBinType , m_timeBinWidth); + m_chcollSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_chcoll", &*m_emecinnerchclcalc, m_timeBinType , m_timeBinWidth); + m_roptSD = new LArG4SimpleSD("LAr::EMEC::InnerModule::SDin_ropt", &*m_emecinnercalc, m_timeBinType , m_timeBinWidth); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_gapadjSD] = &m_volumeNames; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.h index 06150bb25f4a..000a9b149ba3 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECInnerModuleTool.h @@ -11,18 +11,26 @@ #include "StoreGate/WriteHandle.h" #include "LArSimEvent/LArHitContainer.h" +#include "LArG4Code/ILArCalculatorSvc.h" class LArG4SimpleSD; +/// @class TBECInnerModuleTool +/// +/// This implementation has issues in multi-threading and so cannot +/// be used in an MT job. Migration discussion ongoing in ATLASSIM-2606. +/// class TBECInnerModuleTool : public LArG4SDTool { public: // Constructor TBECInnerModuleTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~TBECInnerModuleTool() {} + virtual StatusCode initializeCalculators() override final; + // Method in which all the SDs are created and assigned to the relevant volumes StatusCode initializeSD() override final; @@ -32,7 +40,7 @@ class TBECInnerModuleTool : public LArG4SDTool /** Beginning of an athena event. This is where collection initialization should happen. If we are using a WriteHandle, then this could be empty. */ // StatusCode SetupEvent() override final; - + private: // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<LArHitContainer> m_HitColl_gapadj; @@ -43,6 +51,14 @@ class TBECInnerModuleTool : public LArG4SDTool SG::WriteHandle<LArHitContainer> m_HitColl_chcoll; SG::WriteHandle<LArHitContainer> m_HitColl_ropt; + ServiceHandle<ILArCalculatorSvc> m_emecinnergadjcalc;// LArG4::EMEC_ECOR_GADJ + ServiceHandle<ILArCalculatorSvc> m_emecinnergadjoldcalc;// LArG4::EMEC_ECOR_GADJ_OLD + ServiceHandle<ILArCalculatorSvc> m_emecinnergadjecalc;// LArG4::EMEC_ECOR_GADJ_E + ServiceHandle<ILArCalculatorSvc> m_emecinnergadjscalc;// LArG4::EMEC_ECOR_GADJ_S + ServiceHandle<ILArCalculatorSvc> m_emecinnergadjsecalc;// LArG4::EMEC_ECOR_GADJ_SE + ServiceHandle<ILArCalculatorSvc> m_emecinnerchclcalc;// LArG4::EMEC_ECOR_CHCL + ServiceHandle<ILArCalculatorSvc> m_emecinnercalc;// LArG4::EMEC_ECOR_ROPT + // List of volumes for each SD and the corresponding SDs LArG4SimpleSD* m_gapadjSD; LArG4SimpleSD* m_gapoldSD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.cc b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.cc index b28faeba4a13..584da048fef9 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.cc +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.cc @@ -5,8 +5,6 @@ #include "TBECOuterModuleTool.h" #include "LArG4Code/LArG4SimpleSD.h" -#include "LArG4EC/EnergyCalculator.h" - #include "CxxUtils/make_unique.h" TBECOuterModuleTool::TBECOuterModuleTool(const std::string& type, const std::string& name, const IInterface *parent) @@ -18,6 +16,13 @@ TBECOuterModuleTool::TBECOuterModuleTool(const std::string& type, const std::str , m_HitColl_gap_se("LArHitEMEC_gap_se") , m_HitColl_chcoll("LArHitEMEC_chcoll") , m_HitColl_ropt("LArHitEMEC_ropt") + , m_emecoutergadjcalc("EMECPosOuterWheel_ECOR_GADJCalculator", name) + , m_emecoutergadjoldcalc("EMECPosOuterWheel_ECOR_GADJ_OLDCalculator", name) + , m_emecoutergadjecalc("EMECPosOuterWheel_ECOR_GADJ_ECalculator", name) + , m_emecoutergadjscalc("EMECPosOuterWheel_ECOR_GADJ_SCalculator", name) + , m_emecoutergadjsecalc("EMECPosOuterWheel_ECOR_GADJ_SECalculator", name) + , m_emecouterchclcalc("EMECPosOuterWheel_ECOR_CHCLCalculator", name) + , m_emecoutercalc("EMECPosOuterWheelCalculator", name) , m_gapadjSD(nullptr) , m_gapoldSD(nullptr) , m_gap_eSD(nullptr) @@ -27,18 +32,44 @@ TBECOuterModuleTool::TBECOuterModuleTool(const std::string& type, const std::str , m_roptSD(nullptr) { declareInterface<ISensitiveDetector>(this); + declareProperty("EMECPosOuterWheel_ECOR_GADJCalculator", m_emecoutergadjcalc); + declareProperty("EMECPosOuterWheel_ECOR_GADJ_OLDCalculator", m_emecoutergadjoldcalc); + declareProperty("EMECPosOuterWheel_ECOR_GADJ_ECalculator", m_emecoutergadjecalc); + declareProperty("EMECPosOuterWheel_ECOR_GADJ_SCalculator", m_emecoutergadjscalc); + declareProperty("EMECPosOuterWheel_ECOR_GADJ_SECalculator", m_emecoutergadjsecalc); + declareProperty("EMECPosOuterWheel_ECOR_CHCLCalculator", m_emecouterchclcalc); + declareProperty("EMECPosOuterWheelCalculator", m_emecoutercalc); } +StatusCode TBECOuterModuleTool::initializeCalculators() +{ + ATH_CHECK(m_emecoutergadjcalc.retrieve()); + ATH_CHECK(m_emecoutergadjoldcalc.retrieve()); + ATH_CHECK(m_emecoutergadjecalc.retrieve()); + ATH_CHECK(m_emecoutergadjscalc.retrieve()); + ATH_CHECK(m_emecoutergadjsecalc.retrieve()); + ATH_CHECK(m_emecouterchclcalc.retrieve()); + ATH_CHECK(m_emecoutercalc.retrieve()); + + return StatusCode::SUCCESS; +} StatusCode TBECOuterModuleTool::initializeSD() { - m_gapadjSD = new LArG4SimpleSD( "LAr::EMEC::OuterModule::SDout_gapadj" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ) , m_timeBinType , m_timeBinWidth ); - m_gapoldSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gapold", new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_OLD) , m_timeBinType , m_timeBinWidth); - m_gap_eSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gap_e", new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_E) , m_timeBinType , m_timeBinWidth); - m_gap_sSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gap_s", new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_S) , m_timeBinType , m_timeBinWidth); - m_gap_seSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gap_se", new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_GADJ_SE) , m_timeBinType , m_timeBinWidth); - m_chcollSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_chcoll", new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_CHCL) , m_timeBinType , m_timeBinWidth); - m_roptSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_ropt", new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberModule, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT) , m_timeBinType , m_timeBinWidth); + // Multi-threading not yet supported + if(m_gapadjSD) { + ATH_MSG_ERROR("TBECOuterModuleTool::initializeSD - SDs already exist. " << + "Are you running an MT job? Not yet supported!"); + return StatusCode::FAILURE; + } + + m_gapadjSD = new LArG4SimpleSD( "LAr::EMEC::OuterModule::SDout_gapadj" , &*m_emecoutergadjcalc, m_timeBinType , m_timeBinWidth ); + m_gapoldSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gapold", &*m_emecoutergadjoldcalc, m_timeBinType , m_timeBinWidth); + m_gap_eSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gap_e", &*m_emecoutergadjecalc, m_timeBinType , m_timeBinWidth); + m_gap_sSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gap_s", &*m_emecoutergadjscalc, m_timeBinType , m_timeBinWidth); + m_gap_seSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_gap_se", &*m_emecoutergadjsecalc, m_timeBinType , m_timeBinWidth); + m_chcollSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_chcoll", &*m_emecouterchclcalc, m_timeBinType , m_timeBinWidth); + m_roptSD = new LArG4SimpleSD("LAr::EMEC::OuterModule::SDout_ropt", &*m_emecoutercalc, m_timeBinType , m_timeBinWidth); std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; configuration[m_gapadjSD] = &m_volumeNames; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.h b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.h index 43255220916c..464b8427d235 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.h +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/TBECOuterModuleTool.h @@ -11,18 +11,26 @@ #include "StoreGate/WriteHandle.h" #include "LArSimEvent/LArHitContainer.h" +#include "LArG4Code/ILArCalculatorSvc.h" class LArG4SimpleSD; +/// @class TBECOuterModuleTool +/// +/// This implementation has issues in multi-threading and so cannot +/// be used in an MT job. Migration discussion ongoing in ATLASSIM-2606. +/// class TBECOuterModuleTool : public LArG4SDTool { public: // Constructor TBECOuterModuleTool(const std::string& type, const std::string& name, const IInterface *parent); - + // Destructor virtual ~TBECOuterModuleTool() {} + StatusCode initializeCalculators() override final; + // Method in which all the SDs are created and assigned to the relevant volumes StatusCode initializeSD() override final; @@ -39,6 +47,14 @@ class TBECOuterModuleTool : public LArG4SDTool SG::WriteHandle<LArHitContainer> m_HitColl_chcoll; SG::WriteHandle<LArHitContainer> m_HitColl_ropt; + ServiceHandle<ILArCalculatorSvc> m_emecoutergadjcalc;// LArG4::EMEC_ECOR_GADJ + ServiceHandle<ILArCalculatorSvc> m_emecoutergadjoldcalc;// LArG4::EMEC_ECOR_GADJ_OLD + ServiceHandle<ILArCalculatorSvc> m_emecoutergadjecalc;// LArG4::EMEC_ECOR_GADJ_E + ServiceHandle<ILArCalculatorSvc> m_emecoutergadjscalc;// LArG4::EMEC_ECOR_GADJ_S + ServiceHandle<ILArCalculatorSvc> m_emecoutergadjsecalc;// LArG4::EMEC_ECOR_GADJ_SE + ServiceHandle<ILArCalculatorSvc> m_emecouterchclcalc;// LArG4::EMEC_ECOR_CHCL + ServiceHandle<ILArCalculatorSvc> m_emecoutercalc;// LArG4::EMEC_ECOR_ROPT + // List of volumes for each SD and the corresponding SDs LArG4SimpleSD* m_gapadjSD; LArG4SimpleSD* m_gapoldSD; diff --git a/LArCalorimeter/LArG4/LArG4H6SD/src/components/LArG4H6SDTools_entries.cxx b/LArCalorimeter/LArG4/LArG4H6SD/src/components/LArG4H6SDTools_entries.cxx index 011348527ec4..3d7c31415b89 100644 --- a/LArCalorimeter/LArG4/LArG4H6SD/src/components/LArG4H6SDTools_entries.cxx +++ b/LArCalorimeter/LArG4/LArG4H6SD/src/components/LArG4H6SDTools_entries.cxx @@ -6,6 +6,14 @@ #include "../LArGeoH62004SteppingActionTool.h" #include "../RadLenNtupleTool.h" +// New SDs +#include "../H62004EMECSDTool.h" +#include "../H62004FCALSDTool.h" +#include "../H62004HECSDTool.h" +#include "../H62004ActiveSDTool.h" +#include "../H62004DeadSDTool.h" +#include "../H62004InactiveSDTool.h" + // SDs #include "../LArG4H62004ActiveSDTool.h" #include "../LArG4H62004DeadSDTool.h" @@ -20,6 +28,14 @@ #include "../TBECInnerModuleTool.h" #include "../TBECOuterModuleTool.h" +// Calculator Services +#include "../LArFCALH62004CalibCalculatorBase.h" +#include "../LArG4H6COLDTCMod0Calculator.h" +#include "../LArG4H6WarmTCCalculator.h" +#include "../LArG4H62004DeadCalibrationCalculator.h" +#include "../LArG4H6COLDTCMod0CalibCalculator.h" + + // UA tools DECLARE_TOOL_FACTORY( LArTBH6TriggerTimeTool ) DECLARE_TOOL_FACTORY( G4UA::LArGeoH62004EventActionTool ) @@ -27,6 +43,13 @@ DECLARE_TOOL_FACTORY( G4UA::LArGeoH62004SteppingActionTool ) DECLARE_TOOL_FACTORY( G4UA::RadLenNtupleTool ) // SD tools +DECLARE_TOOL_FACTORY( LArG4::H62004EMECSDTool ) +DECLARE_TOOL_FACTORY( LArG4::H62004FCALSDTool ) +DECLARE_TOOL_FACTORY( LArG4::H62004HECSDTool ) +DECLARE_TOOL_FACTORY( LArG4::H62004ActiveSDTool ) +DECLARE_TOOL_FACTORY( LArG4::H62004DeadSDTool ) +DECLARE_TOOL_FACTORY( LArG4::H62004InactiveSDTool ) + DECLARE_TOOL_FACTORY( LArG4H62004ActiveSDTool ) DECLARE_TOOL_FACTORY( LArG4H62004DeadSDTool ) DECLARE_TOOL_FACTORY( LArG4H62004EMECSDTool ) @@ -42,23 +65,10 @@ DECLARE_TOOL_FACTORY( TBECOuterModuleTool ) DECLARE_ALGORITHM_FACTORY(LArTBH6BeamInfo) -DECLARE_FACTORY_ENTRIES(LArG4TBH6Tools) { - DECLARE_ALGORITHM(LArTBH6BeamInfo) - DECLARE_TOOL( LArTBH6TriggerTimeTool ) - DECLARE_TOOL( LArGeoH62004EventAction ) - DECLARE_TOOL( LArGeoH62004SteppingAction ) - DECLARE_TOOL( RadLenNtuple ) - DECLARE_TOOL( LArG4H62004ActiveSDTool ) - DECLARE_TOOL( LArG4H62004DeadSDTool ) - DECLARE_TOOL( LArG4H62004EMECSDTool ) - DECLARE_TOOL( LArG4H62004FCALSDTool ) - DECLARE_TOOL( LArG4H62004HECSDTool ) - DECLARE_TOOL( LArG4H62004InactiveSDTool ) - DECLARE_TOOL( LArG4H6BeamSDTool ) - DECLARE_TOOL( LArG4H6WarmTCSDTool ) - DECLARE_TOOL( LArG4TBECBeamChSDTool ) - DECLARE_TOOL( TBECBackOuterBarretteTool ) - DECLARE_TOOL( TBECInnerModuleTool ) - DECLARE_TOOL( TBECOuterModuleTool ) -} +//Calculators +DECLARE_SERVICE_FACTORY(LArFCALH62004CalibCalculatorBase) +DECLARE_SERVICE_FACTORY(LArG4H6COLDTCMod0Calculator) +DECLARE_SERVICE_FACTORY(LArG4H6WarmTCCalculator) +DECLARE_SERVICE_FACTORY(LArG4H62004DeadCalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4H6COLDTCMod0CalibCalculator) \ No newline at end of file diff --git a/LArCalorimeter/LArG4/LArG4H8SD/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4H8SD/CMakeLists.txt index 6e4e8141433e..5bead0dd6b7e 100644 --- a/LArCalorimeter/LArG4/LArG4H8SD/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4H8SD/CMakeLists.txt @@ -9,9 +9,10 @@ atlas_subdir( LArG4H8SD ) atlas_depends_on_subdirs( PRIVATE Calorimeter/CaloG4Sim Calorimeter/CaloSimEvent + Control/AthenaKernel Control/CxxUtils Control/StoreGate - LArCalorimeter/LArG4/LArG4Barrel + GaudiKernel LArCalorimeter/LArG4/LArG4Code ) # External dependencies: @@ -20,11 +21,12 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_library( LArG4H8SD +atlas_add_component( LArG4H8SD src/*.cc + src/components/*.cxx PUBLIC_HEADERS LArG4H8SD PRIVATE_INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_DEFINITIONS ${CLHEP_DEFINITIONS} LINK_LIBRARIES CaloG4SimLib StoreGateLib SGtests - PRIVATE_LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} CaloSimEvent CxxUtils LArG4Barrel LArG4Code ) + PRIVATE_LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} AthenaKernel CaloSimEvent CxxUtils GaudiKernel LArG4Code ) diff --git a/LArCalorimeter/LArG4/LArG4H8SD/cmt/requirements b/LArCalorimeter/LArG4/LArG4H8SD/cmt/requirements old mode 100755 new mode 100644 index 2ace648e1afa..7481e66d0fad --- a/LArCalorimeter/LArG4/LArG4H8SD/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4H8SD/cmt/requirements @@ -5,8 +5,9 @@ author Guillaume Unal use AtlasPolicy AtlasPolicy-* # Build the library (and export the headers) -library LArG4H8SD *.cc -apply_pattern linked_library +library LArG4H8SD *.cc components/*.cxx +apply_pattern component_library +apply_pattern declare_python_modules files="*.py" #======================================================= private @@ -16,8 +17,8 @@ private # only used in the stand-alone version of this application. macro_append LArG4H8SD_cppflags " -DLARG4NOROOT -O -Wno-unused" +use GaudiInterface GaudiInterface-* External use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use LArG4Barrel LArG4Barrel-* LArCalorimeter/LArG4 use CaloG4Sim CaloG4Sim-* Calorimeter diff --git a/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfig.py b/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfig.py index 01304f0abbb6..b64047919cec 100644 --- a/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfig.py +++ b/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfig.py @@ -3,12 +3,46 @@ from AthenaCommon import CfgMgr def getLArH8CalibSensitiveDetector(name="LArH8CalibSensitiveDetector", **kwargs): - kwargs.setdefault("BarrelCryDeadVolumes",["LArMgr::LAr::TBBarrel::Cryostat::*"]) - kwargs.setdefault("BarrelPreInactiveVolumes",["LArMgr::LAr::Barrel::Presampler::Prep*","LArMgr::LAr::Barrel::Presampler::Anode*","LArMgr::LAr::Barrel::Presampler::Cathode*"]) - kwargs.setdefault("BarrelPreDeadVolumes",["LArMgr::LAr::Barrel::Presampler","LArMgr::LAr::Barrel::Presampler::Sector","LArMgr::LAr::Barrel::Presampler::MotherBoard","LArMgr::LAr::Barrel::Presampler::ProtectionShell","LArMgr::LAr::Barrel::Presampler::MotherBoard","LArMgr::LAr::Barrel::Presampler::Connectics","LArMgr::LAr::Barrel::Presampler::Rail","LArMgr::LAr::Barrel::Presampler::ProtectionPlate"]) - kwargs.setdefault("BarrelPreCalibVolumes",m_bpCalibVolumes={"TBBarrel::Presampler::Module::Calibration"}); - kwargs.setdefault("BarrelInVolumes",["LArMgr::LAr::EMB::*Abs::*","LArMgr::LAr::EMB::Electrode::*"]) - kwargs.setdefault("BarrelDeadVolumes",["LArMgr::LAr::EMB::ECAM","LArMgr::LAr::EMB::TELF","LArMgr::LAr::EMB::TELFB","LArMgr::LAr::EMB::MOAC","LArMgr::LAr::EMB::CAAC","LArMgr::LAr::EMB::SUMB","LArMgr::LAr::EMB::GTENF","LArMgr::LAr::EMB::GTENB","LArMgr::LAr::EMB::FrontBack::Electrode","LArMgr::LAr::EMB::FrontBack::G10","LArMgr::LAr::EMB::FrontBack::Steel","LArMgr::LAr::EMB::FrontBack::Absorber2","LArMgr::LAr::EMB::FrontBack::Absorber"]) + kwargs.setdefault("BarrelCryDeadVolumes", + ["LArMgr::LAr::TBBarrel::Cryostat::*"]) + kwargs.setdefault("BarrelPreInactiveVolumes", + ["LArMgr::LAr::Barrel::Presampler::Prep*", + "LArMgr::LAr::Barrel::Presampler::Anode*", + "LArMgr::LAr::Barrel::Presampler::Cathode*"]) + kwargs.setdefault("BarrelPreDeadVolumes", + ["LArMgr::LAr::Barrel::Presampler", + "LArMgr::LAr::Barrel::Presampler::Sector", + "LArMgr::LAr::Barrel::Presampler::MotherBoard", + "LArMgr::LAr::Barrel::Presampler::ProtectionShell", + "LArMgr::LAr::Barrel::Presampler::MotherBoard", + "LArMgr::LAr::Barrel::Presampler::Connectics", + "LArMgr::LAr::Barrel::Presampler::Rail", + "LArMgr::LAr::Barrel::Presampler::ProtectionPlate"]) + kwargs.setdefault("BarrelPreCalibVolumes", + ["TBBarrel::Presampler::Module::Calibration"]); + kwargs.setdefault("BarrelInVolumes", + ["LArMgr::LAr::EMB::*Abs::*", + "LArMgr::LAr::EMB::Electrode::*"]) + kwargs.setdefault("BarrelDeadVolumes", + ["LArMgr::LAr::EMB::ECAM", + "LArMgr::LAr::EMB::TELF", + "LArMgr::LAr::EMB::TELFB", + "LArMgr::LAr::EMB::MOAC", + "LArMgr::LAr::EMB::CAAC", + "LArMgr::LAr::EMB::SUMB", + "LArMgr::LAr::EMB::GTENF", + "LArMgr::LAr::EMB::GTENB", + "LArMgr::LAr::EMB::FrontBack::Electrode", + "LArMgr::LAr::EMB::FrontBack::G10", + "LArMgr::LAr::EMB::FrontBack::Steel", + "LArMgr::LAr::EMB::FrontBack::Absorber2", + "LArMgr::LAr::EMB::FrontBack::Absorber"]) # No effect currently kwargs.setdefault("OutputCollectionNames", ["LArHitH8"]) - return CfgMgr.LArG4H8CalibSDTool(name, **kwargs) + return CfgMgr.LArG4__H8CalibSDTool(name, **kwargs) + +def getLArTBCryostatCalibrationCalculator(name="LArTBCryostatCalibrationCalculator", **kwargs): + return CfgMgr.LArTBCryostatCalibrationCalculator(name, kwargs) + +def getH8CalibrationDefaultCalculator(name="H8CalibrationDefaultCalculator", **kwargs): + return CfgMgr.H8CalibrationDefaultCalculator(name, **kwargs) diff --git a/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfigDb.py b/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfigDb.py index 5f7a8c4ebad3..8ded81fbe337 100644 --- a/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfigDb.py +++ b/LArCalorimeter/LArG4/LArG4H8SD/python/LArG4H8SDConfigDb.py @@ -1,4 +1,7 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -from AthenaCommon.CfgGetter import addTool +from AthenaCommon.CfgGetter import addTool, addService addTool("LArG4H8SD.LArG4H8SDConfig.getLArH8CalibSensitiveDetector","LArH8CalibSensitiveDetector") + +addService("LArG4H8SD.LArG4H8SDConfig.getLArTBCryostatCalibrationCalculator", "LArTBCryostatCalibrationCalculator") +addService("LArG4H8SD.LArG4H8SDConfig.getH8CalibrationDefaultCalculator", "H8CalibrationDefaultCalculator") diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.cc b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.cc new file mode 100644 index 000000000000..19664e06660b --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.cc @@ -0,0 +1,109 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "H8CalibSDTool.h" + +// LArG4 includes +#include "LArG4Code/SDWrapper.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" +//#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/EscapedEnergyProcessing.h" +//#include "LArG4Code/CalibrationDefaultCalculator.h" + +//#include "CaloG4Sim/VEscapedEnergyProcessing.h" +#include "CaloG4Sim/EscapedEnergyRegistry.h" + +// #include "LArG4Barrel/PresamplerCalibrationCalculator.h" +// #include "LArG4Barrel/LArBarrelCalibrationCalculator.h" + +// // Local includes +// #include "LArTBCryostatCalibrationCalculator.h" +// #include "H8CalibrationDefaultCalculator.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + H8CalibSDTool::H8CalibSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : CalibSDTool(type, name, parent) + , m_hitCollName("LArH8CalibrationHits") + , m_tbbarcrycalc("LArTBCryostatCalibrationCalculator", name) // FIXME LArTBCryostatCalibrationCalculator() + , m_barpscalc("BarrelPresamplerCalibrationCalculator", name) + , m_barcalc("BarrelCalibrationCalculator", name) + , m_h8defaultcalc("H8CalibrationDefaultCalculator", name) // FIXME H8CalibrationDefaultCalculator() + { + declareProperty("LArTBCryostatCalibrationCalculator", m_tbbarcrycalc); + declareProperty("BarrelPresamplerCalibrationCalculator", m_barpscalc); + declareProperty("BarrelCalibrationCalculator", m_barcalc); + declareProperty("H8CalibrationDefaultCalculator", m_h8defaultcalc); + declareProperty("BarrelCryDeadVolumes", m_barCryVolumes); + declareProperty("BarrelPreInactiveVolumes", m_bpInVolumes); + declareProperty("BarrelPreDeadVolumes", m_bpDeadVolumes); + declareProperty("BarrelPreCalibVolumes", m_bpCalibVolumes); + declareProperty("BarrelInVolumes", m_barInVolumes); + declareProperty("BarrelDeadVolumes", m_barDeadVolumes); + } + +StatusCode H8CalibSDTool::initializeCalculators() +{ + ATH_CHECK(m_tbbarcrycalc.retrieve()); + ATH_CHECK(m_barpscalc.retrieve()); + ATH_CHECK(m_barcalc.retrieve()); + ATH_CHECK(m_h8defaultcalc.retrieve()); + return StatusCode::SUCCESS; +} + + //--------------------------------------------------------------------------- + // Create SD wrapper for current thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* H8CalibSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("H8CalibSDWrapper", m_hitCollName); + + // Create the SDs. + // Lots of singleton calculators !!! + + sdWrapper->addSD( + makeOneSD("LAr::TBBarrelCryostat::Dead", &*m_tbbarcrycalc, m_barCryVolumes) + ); + + sdWrapper->addSD( + makeOneSD("LAr::TBBarrel::Presampler::Inactive", &*m_barpscalc, m_bpInVolumes) + ); + + sdWrapper->addSD( + makeOneSD("LAr::TBBarrel::Presampler::Dead", &*m_barpscalc, m_bpDeadVolumes) + ); + + // Why is this one commented out? + // sdWrapper->addSD( + // makeOneSD("LAr::TBBarrel::Presampler::Module::Calibration", &*m_barpscalc, m_bpModVolumes) + // ); + + sdWrapper->addSD( + makeOneSD("LAr::TBBarrel::Inactive", &*m_barcalc, m_barInVolumes) + ); + + sdWrapper->addSD( + makeOneSD("LAr::TBBarrel::Dead", &*m_barcalc, m_barDeadVolumes) + ); + + std::vector<std::string> emptyStringVec; + auto uninstSD = + makeOneSD("Default::Dead::Uninstrumented::Calibration::Region", &*m_h8defaultcalc, emptyStringVec); + // WARNING: This probably isn't thread safe! + CaloG4::VEscapedEnergyProcessing* eep = + new EscapedEnergyProcessing( uninstSD.get() ); + auto registry = CaloG4::EscapedEnergyRegistry::GetInstance(); + registry->AddAndAdoptProcessing("LAr::", eep); + sdWrapper->addSD( std::move(uninstSD) ); + + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.h b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.h new file mode 100644 index 000000000000..3d6a14d4cf88 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibSDTool.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4H8SD_H8CALIBSDTOOL_H +#define LARG4H8SD_H8CALIBSDTOOL_H + +// STL includes +#include <string> +#include <vector> + +// LArG4 includes +#include "LArG4Code/CalibSDTool.h" + +class ILArCalibCalculatorSvc; +namespace LArG4 +{ + + /// @class H8CalibSDTool + /// @brief Sensitive detector tool which handles calib SDs for the H8 + /// testbeam setup (?). + /// + /// Based on the LArG4H8CalibSDTool implementation. + /// + class H8CalibSDTool : public CalibSDTool + { + + public: + + /// Constructor + H8CalibSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + ServiceHandle<ILArCalibCalculatorSvc> m_tbbarcrycalc; + ServiceHandle<ILArCalibCalculatorSvc> m_barpscalc; + ServiceHandle<ILArCalibCalculatorSvc> m_barcalc; + ServiceHandle<ILArCalibCalculatorSvc> m_h8defaultcalc; + + /// @name SD volumes + /// @{ + std::vector<std::string> m_barCryVolumes; + std::vector<std::string> m_bpInVolumes; + std::vector<std::string> m_bpDeadVolumes; + std::vector<std::string> m_bpCalibVolumes; + std::vector<std::string> m_barInVolumes; + std::vector<std::string> m_barDeadVolumes; + /// @} + + }; // class H8CalibSDTool + +} + +#endif diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.cc b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.cc old mode 100755 new mode 100644 index e90f8049dd8c..7662c8a25d40 --- a/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.cc @@ -40,222 +40,230 @@ #include <algorithm> #include <set> - H8CalibrationDefaultCalculator::H8CalibrationDefaultCalculator() - { - // to check identifiers - m_geometry = LArG4::Barrel::Geometry::GetInstance(); - } +H8CalibrationDefaultCalculator::H8CalibrationDefaultCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + // , m_geometry("LArBarrelGeometry", name) +{ +} +// StatusCode H8CalibrationDefaultCalculator::initialize() +// { +// // to check identifiers +// m_geometry = LArG4::Barrel::Geometry::GetInstance(); +// return StatusCode::SUCCESS; +// } - H8CalibrationDefaultCalculator::~H8CalibrationDefaultCalculator() - { - } +H8CalibrationDefaultCalculator::~H8CalibrationDefaultCalculator() +{ +} - G4bool H8CalibrationDefaultCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); +G4bool H8CalibrationDefaultCalculator::Process( const G4Step* a_step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing a_process ) const +{ + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + energies.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyEnergy ) + { + m_energyCalculator.Energies( a_step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); - m_identifier.clear(); - G4String volName = ""; - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4VPhysicalVolume* vol = pre_step_point->GetPhysicalVolume(); - volName = vol->GetName(); + identifier.clear(); + G4String volName = ""; + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyID ) + { - G4int detector = 10; // calorimeter "dead" materials + G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + G4VPhysicalVolume* vol = pre_step_point->GetPhysicalVolume(); + volName = vol->GetName(); - // Initialize identifier variables with (invalid) default - // values (INT_MIN is defined in <climits>). - G4int subdet = 4; // LAr -//GU 26-Sep-05, type=3 does not work with offline calodm identifier -// G4int type = 3; // test beam specific - G4int type = 1; - G4int sampling = INT_MIN; - G4int region = 0; - G4int etaBin = 0; - G4int phiBin = 0; + G4int detector = 10; // calorimeter "dead" materials - G4double x_table=5733.*CLHEP::mm; //FIXME + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int subdet = 4; // LAr + //GU 26-Sep-05, type=3 does not work with offline calodm identifier + // G4int type = 3; // test beam specific + G4int type = 1; + G4int sampling = INT_MIN; + G4int region = 0; + G4int etaBin = 0; + G4int phiBin = 0; - G4ThreeVector startPoint = pre_step_point->GetPosition(); + G4double x_table=5733.*CLHEP::mm; //FIXME + + G4ThreeVector startPoint = pre_step_point->GetPosition(); -// directly in world volume, use x position to decide before/after calorimeters - if (volName=="CTB::CTB") { - if (startPoint.x() < x_table) sampling=0; - else - { -//GU 26-Sep-05, to work for leakage after the calorimeter + // directly in world volume, use x position to decide before/after calorimeters + if (volName=="CTB::CTB") { + if (startPoint.x() < x_table) sampling=0; + else + { + //GU 26-Sep-05, to work for leakage after the calorimeter sampling=3; subdet=5; - } -// find detector envelop in which we are - } else { - const G4NavigationHistory* g4navigation = pre_step_point->GetTouchable()->GetHistory(); - G4int ndep = g4navigation->GetDepth(); - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - G4String vName = v1->GetName(); -//GU 10dec04 change in envelopes for tracker in ctb setup : IDET=mother envelope - if ( vName=="IDET::IDET") { - sampling=0; - break; - } - if ( vName=="CALO::CALO") { -// compute local radius in CALO::CALO frame (<=> atlas frame for calorimeter) - const G4AffineTransform transformation = g4navigation->GetTransform(ii); - G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); - double rloc = sqrt(startPointinLocal.x()*startPointinLocal.x() + - startPointinLocal.y()*startPointinLocal.y()); - double etaloc = fabs(startPointinLocal.pseudoRapidity()); - double philoc = startPointinLocal.phi()+M_PI/16.; - if (philoc<0. ) { philoc+= 2.*M_PI; } - //static double rend_lar = 1960.; - const static double rbeg_lar = 1500.; - const static double rend_tile = 3835.; - const static double rps= 0.5*(1410.+1447.); - if (rloc<rbeg_lar) { - sampling=1; - if (rloc<rps) region=2; - else region=3; - } - else if (rloc<rend_tile) { - sampling=2; - region=0; - } - else { - subdet=5; - sampling=3; - region=0; - } - if (sampling==2 && etaloc>1.0) { - region=2; - etaBin = (int) ((etaloc-1.0)/0.1); - if (etaBin>4) etaBin=4; - } else { - etaBin = (int) (etaloc/0.1); - if (sampling==2 && etaBin>10) etaBin=10; - if (sampling==1 && etaBin>14) etaBin=14; - if (sampling==3 && etaBin>16) etaBin=16; - } - phiBin = (int) (philoc*32./M_PI); - if (phiBin>63) phiBin=63; - break; - } - if ( vName=="MUON::MUON") { - subdet=5; - sampling=3; - break; - } } - } - if (sampling==INT_MIN) { - -//G0 10 dec04 to recover anciliary detectors - G4ThreeVector startPoint = pre_step_point->GetPosition(); - if (startPoint.x() < x_table) sampling=0; - else - { - sampling=3; - subdet=5; - } - } - -#ifdef DEBUG_HITS - double rr=sqrt(startPoint.y()*startPoint.y()+startPoint.z()*startPoint.z()); - double rloc=0.; + // find detector envelop in which we are + } else { const G4NavigationHistory* g4navigation = pre_step_point->GetTouchable()->GetHistory(); G4int ndep = g4navigation->GetDepth(); for (G4int ii=0;ii<=ndep;ii++) { G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); G4String vName = v1->GetName(); + //GU 10dec04 change in envelopes for tracker in ctb setup : IDET=mother envelope + if ( vName=="IDET::IDET") { + sampling=0; + break; + } if ( vName=="CALO::CALO") { -// compute local radius in CALO::CALO frame (<=> atlas frame for calorimeter) + // compute local radius in CALO::CALO frame (<=> atlas frame for calorimeter) const G4AffineTransform transformation = g4navigation->GetTransform(ii); G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); - rloc = sqrt(startPointinLocal.x()*startPointinLocal.x() + - startPointinLocal.y()*startPointinLocal.y()); + double rloc = sqrt(startPointinLocal.x()*startPointinLocal.x() + + startPointinLocal.y()*startPointinLocal.y()); + double etaloc = fabs(startPointinLocal.pseudoRapidity()); + double philoc = startPointinLocal.phi()+M_PI/16.; + if (philoc<0. ) { philoc+= 2.*M_PI; } + //static double rend_lar = 1960.; + const static double rbeg_lar = 1500.; + const static double rend_tile = 3835.; + const static double rps= 0.5*(1410.+1447.); + if (rloc<rbeg_lar) { + sampling=1; + if (rloc<rps) region=2; + else region=3; + } + else if (rloc<rend_tile) { + sampling=2; + region=0; + } + else { + subdet=5; + sampling=3; + region=0; + } + if (sampling==2 && etaloc>1.0) { + region=2; + etaBin = (int) ((etaloc-1.0)/0.1); + if (etaBin>4) etaBin=4; + } else { + etaBin = (int) (etaloc/0.1); + if (sampling==2 && etaBin>10) etaBin=10; + if (sampling==1 && etaBin>14) etaBin=14; + if (sampling==3 && etaBin>16) etaBin=16; + } + phiBin = (int) (philoc*32./M_PI); + if (phiBin>63) phiBin=63; + break; + } + if ( vName=="MUON::MUON") { + subdet=5; + sampling=3; break; } } + } + if (sampling==INT_MIN) { + + //G0 10 dec04 to recover anciliary detectors + G4ThreeVector startPoint = pre_step_point->GetPosition(); + if (startPoint.x() < x_table) sampling=0; + else + { + sampling=3; + subdet=5; + } + } + +#ifdef DEBUG_HITS + double rr=sqrt(startPoint.y()*startPoint.y()+startPoint.z()*startPoint.z()); + double rloc=0.; + const G4NavigationHistory* g4navigation = pre_step_point->GetTouchable()->GetHistory(); + G4int ndep = g4navigation->GetDepth(); + for (G4int ii=0;ii<=ndep;ii++) { + G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); + G4String vName = v1->GetName(); + if ( vName=="CALO::CALO") { + // compute local radius in CALO::CALO frame (<=> atlas frame for calorimeter) + const G4AffineTransform transformation = g4navigation->GetTransform(ii); + G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); + rloc = sqrt(startPointinLocal.x()*startPointinLocal.x() + + startPointinLocal.y()*startPointinLocal.y()); + break; + } + } - if (subdet==4 && type==1 && sampling==0) - std::cout << "H8HitPos D4T1S0 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==1 && region==0) - std::cout << "H8HitPos D4T1S1R0 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==1 && region==1) - std::cout << "H8HitPos D4T1S1R1 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==1 && region==2) - std::cout << "H8HitPos D4T1S1R2 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==1 && region==3) - std::cout << "H8HitPos D4T1S1R3 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==1 && region>3) - std::cout << "H8HitPos D4T1S1R4 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==2 && region==0) - std::cout << "H8HitPos D4T1S2R0 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==2 && region==1) - std::cout << "H8HitPos D4T1S2R1 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==2 && region==2) - std::cout << "H8HitPos D4T1S2R2 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==2 && region>=3) - std::cout << "H8HitPos D4T1S2R3 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==1 && sampling==3 ) - std::cout << "H8HitPos D4T1S3 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==4 && type==2 ) - std::cout << "H8HitPos D4T2 " << startPoint.x() << " " << rr << " " << rloc << std::endl; - if (subdet==5) - std::cout << "H8HitPos D5 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==0) + std::cout << "H8HitPos D4T1S0 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==1 && region==0) + std::cout << "H8HitPos D4T1S1R0 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==1 && region==1) + std::cout << "H8HitPos D4T1S1R1 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==1 && region==2) + std::cout << "H8HitPos D4T1S1R2 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==1 && region==3) + std::cout << "H8HitPos D4T1S1R3 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==1 && region>3) + std::cout << "H8HitPos D4T1S1R4 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==2 && region==0) + std::cout << "H8HitPos D4T1S2R0 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==2 && region==1) + std::cout << "H8HitPos D4T1S2R1 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==2 && region==2) + std::cout << "H8HitPos D4T1S2R2 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==2 && region>=3) + std::cout << "H8HitPos D4T1S2R3 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==1 && sampling==3 ) + std::cout << "H8HitPos D4T1S3 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==4 && type==2 ) + std::cout << "H8HitPos D4T2 " << startPoint.x() << " " << rr << " " << rloc << std::endl; + if (subdet==5) + std::cout << "H8HitPos D5 " << startPoint.x() << " " << rr << " " << rloc << std::endl; #endif - // Create the LArG4Identifier. - m_identifier << detector - << subdet - << type - << sampling - << region - << etaBin - << phiBin; -// if (subdet==4) { -// if (!m_geometry->CheckDMIdentifier(type,sampling,region,etaBin,phiBin)) -// { -// std::cout << "H8CalibrationDefaultCalculator: invalid DM identifier " -// << std::string(m_identifier) << std::endl; -// } -// } + // Create the LArG4Identifier. + identifier << detector + << subdet + << type + << sampling + << region + << etaBin + << phiBin; + // if (subdet==4) { + // if (!m_geometry->CheckDMIdentifier(type,sampling,region,etaBin,phiBin)) + // { + // std::cout << "H8CalibrationDefaultCalculator: invalid DM identifier " + // << std::string(identifier) << std::endl; + // } + // } + + } - } - #ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "H8CalibrationDefaultCalculator::Process" - << " volName " << volName - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "H8CalibrationDefaultCalculator::Process" + << " volName " << volName + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; #endif - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; + // Check for bad result. + if ( identifier == LArG4Identifier() ) + return false; - return true; - } + return true; +} diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.h b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.h old mode 100755 new mode 100644 index 6f2cf53922a3..6d87be8a733b --- a/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.h +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/H8CalibrationDefaultCalculator.h @@ -18,11 +18,11 @@ #ifndef LArG4H8SD_H8CalibrationDefaultCalculator_H #define LArG4H8SD_H8CalibrationDefaultCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" -#include "LArG4Barrel/LArBarrelGeometry.h" +// #include "LArG4Barrel/LArBarrelGeometry.h" #include "globals.hh" @@ -31,44 +31,36 @@ // Forward declaractions: class G4Step; - class H8CalibrationDefaultCalculator : public LArG4::VCalibrationCalculator { - public: - - H8CalibrationDefaultCalculator(); - virtual ~H8CalibrationDefaultCalculator(); - - // The Process method returns a boolean value. If it's true, the - // hit can be used by Geant4; if it's false, there's something wrong - // with the energy deposit and it should be ignored. - - // For calibration work, most of the time we want the calculator - // to determine both the energy and the identifier. However, - // sometimes we want it calculate only the identifier (for escaped - // energy), or only the energy (no known application yet, but you - // can never tell). Use the enum to control any special - // processing. - - virtual G4bool Process (const G4Step*, - const eCalculatorProcessing = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } - - private: - - // The results of the calculation. - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - - // The usual calibration energy calculator. - CaloG4::SimulationEnergies m_energyCalculator; - - LArG4::Barrel::Geometry* m_geometry; - - }; +class H8CalibrationDefaultCalculator : public LArCalibCalculatorSvcImp +{ +public: + + H8CalibrationDefaultCalculator(const std::string& name, ISvcLocator *pSvcLocator); + // virtual StatusCode initialize() override final; + virtual ~H8CalibrationDefaultCalculator(); + + // The Process method returns a boolean value. If it's true, the + // hit can be used by Geant4; if it's false, there's something wrong + // with the energy deposit and it should be ignored. + + // For calibration work, most of the time we want the calculator + // to determine both the energy and the identifier. However, + // sometimes we want it calculate only the identifier (for escaped + // energy), or only the energy (no known application yet, but you + // can never tell). Use the enum to control any special + // processing. + + virtual G4bool Process (const G4Step*, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing = LArG4::kEnergyAndID) const override final; + +private: + + // The usual calibration energy calculator. + CaloG4::SimulationEnergies m_energyCalculator; + + // LArG4::Barrel::Geometry* m_geometry; + +}; #endif // LArG4TB_H8CalibrationDefaultCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.cc b/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.cc old mode 100755 new mode 100644 index 4c605e3960fe..d09f215cd8c5 --- a/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.cc +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.cc @@ -4,104 +4,109 @@ #include "LArG4H8CalibSDTool.h" -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" #include "LArG4Code/LArG4CalibSD.h" #include "LArG4Code/EscapedEnergyProcessing.h" -#include "LArG4Code/CalibrationDefaultCalculator.h" -#include "CaloG4Sim/VEscapedEnergyProcessing.h" +// #include "LArG4Code/CalibrationDefaultCalculator.h" +// #include "CaloG4Sim/VEscapedEnergyProcessing.h" #include "CaloG4Sim/EscapedEnergyRegistry.h" -#include "LArG4Barrel/PresamplerCalibrationCalculator.h" -#include "LArG4Barrel/LArBarrelCalibrationCalculator.h" +// #include "LArG4Barrel/PresamplerCalibrationCalculator.h" +// #include "LArG4Barrel/LArBarrelCalibrationCalculator.h" -#include "LArTBCryostatCalibrationCalculator.h" -#include "H8CalibrationDefaultCalculator.h" +// #include "LArTBCryostatCalibrationCalculator.h" +// #include "H8CalibrationDefaultCalculator.h" -#include "CaloG4Sim/CalibrationDefaultProcessing.h" +// #include "CaloG4Sim/CalibrationDefaultProcessing.h" #include "CxxUtils/make_unique.h" LArG4H8CalibSDTool::LArG4H8CalibSDTool(const std::string& type, const std::string& name, const IInterface *parent) : LArG4SDTool(type,name,parent) , m_HitColl("LArH8CalibrationHits") + , m_tbbarcrycalc("LArTBCryostatCalibrationCalculator", name) // FIXME LArTBCryostatCalibrationCalculator() + , m_barpscalc("BarrelPresamplerCalibrationCalculator", name) + , m_barcalc("BarrelCalibrationCalculator", name) + , m_h8defaultcalc("H8CalibrationDefaultCalculator", name) // FIXME H8CalibrationDefaultCalculator() , m_barCrySD (nullptr) , m_bpInSD (nullptr) , m_bpDeadSD (nullptr) - //, m_bpModSD (nullptr) + //, m_bpModSD (nullptr) , m_barInSD (nullptr) , m_barDeadSD (nullptr) , m_uninstSD (nullptr) { - declareProperty("BarrelCryDeadVolumes",m_barCryVolumes); - declareProperty("BarrelPreInactiveVolumes",m_bpInVolumes); - declareProperty("BarrelPreDeadVolumes",m_bpDeadVolumes); - declareProperty("BarrelPreCalibVolumes",m_bpCalibVolumes); - declareProperty("BarrelInVolumes",m_barInVolumes); - declareProperty("BarrelDeadVolumes",m_barDeadVolumes); + declareProperty("LArTBCryostatCalibrationCalculator", m_tbbarcrycalc); + declareProperty("BarrelPresamplerCalibrationCalculator", m_barpscalc); + declareProperty("BarrelCalibrationCalculator", m_barcalc); + declareProperty("H8CalibrationDefaultCalculator", m_h8defaultcalc); + declareProperty("BarrelCryDeadVolumes",m_barCryVolumes); + declareProperty("BarrelPreInactiveVolumes",m_bpInVolumes); + declareProperty("BarrelPreDeadVolumes",m_bpDeadVolumes); + declareProperty("BarrelPreCalibVolumes",m_bpCalibVolumes); + declareProperty("BarrelInVolumes",m_barInVolumes); + declareProperty("BarrelDeadVolumes",m_barDeadVolumes); +} + +StatusCode LArG4H8CalibSDTool::initializeCalculators() +{ + ATH_CHECK(m_tbbarcrycalc.retrieve()); + ATH_CHECK(m_barpscalc.retrieve()); + ATH_CHECK(m_barcalc.retrieve()); + ATH_CHECK(m_h8defaultcalc.retrieve()); + return StatusCode::SUCCESS; } StatusCode LArG4H8CalibSDTool::initializeSD() { - m_barCrySD = new LArG4CalibSD( "LAr::TBBarrelCryostat::Dead" , new LArTBCryostatCalibrationCalculator() ); - m_bpInSD = new LArG4CalibSD( "LAr::TBBarrel::Presampler::Inactive" , new LArG4::BarrelPresampler::CalibrationCalculator() ); - m_bpDeadSD = new LArG4CalibSD( "LAr::TBBarrel::Presampler::Dead" , new LArG4::BarrelPresampler::CalibrationCalculator() ); -// m_bpModSD = new LArG4CalibSD( "LAr::TBBarrel::Presampler::Module::Calibration" , new LArG4::BarrelPresampler::CalibrationCalculator() ); - m_barInSD = new LArG4CalibSD( "LAr::TBBarrel::Inactive" , new LArG4::Barrel::CalibrationCalculator() ); - m_barDeadSD = new LArG4CalibSD( "LAr::TBBarrel::Dead" , new LArG4::Barrel::CalibrationCalculator() ); - - m_uninstSD = new LArG4CalibSD( "Default::Dead::Uninstrumented::Calibration::Region" , new H8CalibrationDefaultCalculator() ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_barCrySD] = &m_barCryVolumes; - configuration[m_bpInSD] = &m_bpInVolumes; - configuration[m_bpDeadSD] = &m_bpDeadVolumes; -// configuration[m_bpModSD] = &m_bpModVolumes; - configuration[m_barInSD] = &m_barInVolumes; - configuration[m_barDeadSD] = &m_barDeadVolumes; - configuration[m_uninstSD] = new std::vector<std::string>; // No volumes for this guy - setupAllSDs(configuration); - - setupHelpers(m_barCrySD); - setupHelpers(m_bpInSD); - setupHelpers(m_bpDeadSD); -// setupHelpers(m_bpModSD); - setupHelpers(m_barInSD); - setupHelpers(m_barDeadSD); - setupHelpers(m_uninstSD); - - ATH_MSG_DEBUG( " **** Call LArG4H8CalibSD::initializeProcessing() " ); - - // ADS not needed with new user actions. -// ATH_MSG_INFO("CalibrationDefaultProcessing"); -// CaloG4::CalibrationDefaultProcessing * cdp = new CaloG4::CalibrationDefaultProcessing(); // Registers itself -// ATH_MSG_INFO("setting default SD"); -// cdp->SetDefaultSD(m_uninstSD); - - // Initialize the escaped energy processing for LAr volumes. - CaloG4::VEscapedEnergyProcessing* eep = new EscapedEnergyProcessing(m_uninstSD); - CaloG4::EscapedEnergyRegistry* registry = CaloG4::EscapedEnergyRegistry::GetInstance(); - registry->AddAndAdoptProcessing( "LAr::", eep ); - - return StatusCode::SUCCESS; + m_barCrySD = new LArG4CalibSD( "LAr::TBBarrelCryostat::Dead" , &*m_tbbarcrycalc ); + m_bpInSD = new LArG4CalibSD( "LAr::TBBarrel::Presampler::Inactive" , &*m_barpscalc ); + m_bpDeadSD = new LArG4CalibSD( "LAr::TBBarrel::Presampler::Dead" , &*m_barpscalc ); + // m_bpModSD = new LArG4CalibSD( "LAr::TBBarrel::Presampler::Module::Calibration" , &*m_barpscalc ); + m_barInSD = new LArG4CalibSD( "LAr::TBBarrel::Inactive" , &*m_barcalc ); + m_barDeadSD = new LArG4CalibSD( "LAr::TBBarrel::Dead" , &*m_barcalc ); + m_uninstSD = new LArG4CalibSD( "Default::Dead::Uninstrumented::Calibration::Region" , &*m_h8defaultcalc ); + + std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; + configuration[m_barCrySD] = &m_barCryVolumes; + configuration[m_bpInSD] = &m_bpInVolumes; + configuration[m_bpDeadSD] = &m_bpDeadVolumes; + // configuration[m_bpModSD] = &m_bpModVolumes; + configuration[m_barInSD] = &m_barInVolumes; + configuration[m_barDeadSD] = &m_barDeadVolumes; + configuration[m_uninstSD] = new std::vector<std::string>; // No volumes for this guy + setupAllSDs(configuration); + + setupHelpers(m_barCrySD); + setupHelpers(m_bpInSD); + setupHelpers(m_bpDeadSD); + // setupHelpers(m_bpModSD); + setupHelpers(m_barInSD); + setupHelpers(m_barDeadSD); + setupHelpers(m_uninstSD); + + ATH_MSG_DEBUG( " **** Call LArG4H8CalibSD::initializeProcessing() " ); + + // Initialize the escaped energy processing for LAr volumes. + CaloG4::VEscapedEnergyProcessing* eep = new EscapedEnergyProcessing(m_uninstSD); + CaloG4::EscapedEnergyRegistry* registry = CaloG4::EscapedEnergyRegistry::GetInstance(); + registry->AddAndAdoptProcessing( "LAr::", eep ); + + return StatusCode::SUCCESS; } StatusCode LArG4H8CalibSDTool::Gather() { - // In this case, *unlike* other SDs, the *tool* owns the collection -#ifdef ATHENAHIVE - // Temporary fix for Hive until isValid is fixed - m_HitColl = CxxUtils::make_unique<CaloCalibrationHitContainer>(m_HitColl.name()); -#else - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<CaloCalibrationHitContainer>(m_HitColl.name()); -#endif - m_barCrySD ->EndOfAthenaEvent( &*m_HitColl ); - m_bpInSD ->EndOfAthenaEvent( &*m_HitColl ); - m_bpDeadSD ->EndOfAthenaEvent( &*m_HitColl ); -// m_bpModSD ->EndOfAthenaEvent( &*m_HitColl ); - m_barInSD ->EndOfAthenaEvent( &*m_HitColl ); - m_barDeadSD ->EndOfAthenaEvent( &*m_HitColl ); - m_uninstSD ->EndOfAthenaEvent( &*m_HitColl ); - return StatusCode::SUCCESS; + // In this case, *unlike* other SDs, the *tool* owns the collection + if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<CaloCalibrationHitContainer>(m_HitColl.name()); + m_barCrySD ->EndOfAthenaEvent( &*m_HitColl ); + m_bpInSD ->EndOfAthenaEvent( &*m_HitColl ); + m_bpDeadSD ->EndOfAthenaEvent( &*m_HitColl ); + // m_bpModSD ->EndOfAthenaEvent( &*m_HitColl ); + m_barInSD ->EndOfAthenaEvent( &*m_HitColl ); + m_barDeadSD ->EndOfAthenaEvent( &*m_HitColl ); + m_uninstSD ->EndOfAthenaEvent( &*m_HitColl ); + return StatusCode::SUCCESS; } diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.h b/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.h old mode 100755 new mode 100644 index a748e30c0aac..3bd034c25d19 --- a/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.h +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/LArG4H8CalibSDTool.h @@ -15,19 +15,22 @@ #include <string> class LArG4CalibSD; +class ILArCalibCalculatorSvc; class LArG4H8CalibSDTool : public LArG4SDTool { public: LArG4H8CalibSDTool(const std::string& type, const std::string& name, const IInterface *parent); ~LArG4H8CalibSDTool() {} - + StatusCode initializeSD() override final; // Calls down to all the SDs to get them to pack their hits into a central collection StatusCode Gather() override final; - + private: + StatusCode initializeCalculators() override final; + // The actual hit container - here because the base class is for both calib and standard SD tools SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; @@ -39,6 +42,11 @@ private: std::vector<std::string> m_barInVolumes; std::vector<std::string> m_barDeadVolumes; + ServiceHandle<ILArCalibCalculatorSvc> m_tbbarcrycalc; + ServiceHandle<ILArCalibCalculatorSvc> m_barpscalc; + ServiceHandle<ILArCalibCalculatorSvc> m_barcalc; + ServiceHandle<ILArCalibCalculatorSvc> m_h8defaultcalc; + // The actual SD pointers LArG4CalibSD* m_barCrySD; LArG4CalibSD* m_bpInSD; diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.cc old mode 100755 new mode 100644 index 5b59ffc3f784..725a0f4f5351 --- a/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.cc @@ -14,7 +14,6 @@ #include "LArTBCryostatCalibrationCalculator.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/VCalibrationCalculator.h" #include "G4Step.hh" #include "G4StepPoint.hh" @@ -31,144 +30,149 @@ #include <algorithm> #include <cmath> -LArTBCryostatCalibrationCalculator::LArTBCryostatCalibrationCalculator() +LArTBCryostatCalibrationCalculator::LArTBCryostatCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + // , m_geometry(nullptr) { -// improvement would be to fetch this from database (for accordion) - m_radiusPS = 0.5*(1385.+1447.)*CLHEP::mm; - m_rminAcc = 1500.24*CLHEP::mm; - m_rmaxAcc = 1960.00*CLHEP::mm; - - m_geometry = LArG4::Barrel::Geometry::GetInstance(); - + // improvement would be to fetch this from database (for accordion) + m_radiusPS = 0.5*(1385.+1447.)*CLHEP::mm; + m_rminAcc = 1500.24*CLHEP::mm; + m_rmaxAcc = 1960.00*CLHEP::mm; } +// StatusCode LArTBCryostatCalibrationCalculator::initialize() +// { +// m_geometry = LArG4::Barrel::Geometry::GetInstance(); +// return StatusCode::SUCCESS; +// } + -LArTBCryostatCalibrationCalculator::~LArTBCryostatCalibrationCalculator() +LArTBCryostatCalibrationCalculator::~LArTBCryostatCalibrationCalculator() { } -G4bool LArTBCryostatCalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) +G4bool LArTBCryostatCalibrationCalculator::Process( const G4Step* a_step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing a_process ) const { -// Use the calculators to determine the energies and the -// identifier associated with this G4Step. Note that the -// default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. - m_identifier.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyEnergy ) + { + m_energyCalculator.Energies( a_step, energies ); + } + else + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); - G4StepPoint *thisStepPoint = a_step->GetPreStepPoint(); - const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); - G4int ndep = g4navigation->GetDepth(); - G4int ind=-1; + identifier.clear(); + if ( a_process == LArG4::kEnergyAndID || a_process == LArG4::kOnlyID ) + { - // Now navigate through the volumes hierarchy + G4StepPoint *thisStepPoint = a_step->GetPreStepPoint(); + const G4NavigationHistory* g4navigation = thisStepPoint->GetTouchable()->GetHistory(); + G4int ndep = g4navigation->GetDepth(); + G4int ind=-1; - for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - if ( (v1->GetName()).find("LAr::TBBarrel::Cryostat::Envelope") != std::string::npos ) { - ind = ii; - break; - } - } + // Now navigate through the volumes hierarchy - if (ind < 0) - { - std::cout << "LArTBCryostatCalibrationCalculator: Not in Cryostat !!!! " << std::endl; - std::cout << " ndep " << ndep << std::endl; for (G4int ii=0;ii<=ndep;ii++) { - G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); - std::cout << " volname " << v1->GetName() << std::endl; + G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); + if ( (v1->GetName()).find("LAr::TBBarrel::Cryostat::Envelope") != std::string::npos ) { + ind = ii; + break; + } } - return false; - } - G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = thisStepPoint->GetPosition(); - G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); - const G4AffineTransform transformation = g4navigation->GetTransform(ind); - G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); - G4ThreeVector endPointinLocal = transformation.TransformPoint(startPoint); - G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5; - G4double xZpos = midinLocal.x(); - G4double yZpos = midinLocal.y(); - //G4double zZpos = midinLocal.z(); + if (ind < 0) + { + std::cout << "LArTBCryostatCalibrationCalculator: Not in Cryostat !!!! " << std::endl; + std::cout << " ndep " << ndep << std::endl; + for (G4int ii=0;ii<=ndep;ii++) { + G4VPhysicalVolume* v1 = g4navigation->GetVolume(ii); + std::cout << " volname " << v1->GetName() << std::endl; + } + return false; + } + + G4StepPoint *thisStepBackPoint = a_step->GetPostStepPoint(); + G4ThreeVector startPoint = thisStepPoint->GetPosition(); + G4ThreeVector endPoint = thisStepBackPoint->GetPosition(); + const G4AffineTransform transformation = g4navigation->GetTransform(ind); + G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); + G4ThreeVector endPointinLocal = transformation.TransformPoint(startPoint); + G4ThreeVector midinLocal = (startPointinLocal+endPointinLocal)*0.5; + G4double xZpos = midinLocal.x(); + G4double yZpos = midinLocal.y(); + //G4double zZpos = midinLocal.z(); #ifdef DEBUG_HITS - std::cout << " LArTBCryostatCalibrationCalculator x,y,z " << - startPoint.x() << " " << startPoint.y() << " " << startPoint.z() << std::endl; - std::cout << " LArTBCryostatCalibrationCalculator x,y,z local mid" << xZpos << - " " << yZpos << " " << zZpos << std::endl; + std::cout << " LArTBCryostatCalibrationCalculator x,y,z " << + startPoint.x() << " " << startPoint.y() << " " << startPoint.z() << std::endl; + std::cout << " LArTBCryostatCalibrationCalculator x,y,z local mid" << xZpos << + " " << yZpos << " " << zZpos << std::endl; #endif - G4double etaZpos = midinLocal.pseudoRapidity(); - G4double phiZpos = midinLocal.phi(); - if(phiZpos<0.) phiZpos = phiZpos + 2.*M_PI; - G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos; - G4double radiusZpos = sqrt(radius2Zpos); - - G4int zSide = 1; - G4int numDeadPhiBins = 64; - G4double DM1EtaWidth = 0.1 ; - G4double DM1PhiWidth = 2.*M_PI / numDeadPhiBins ; - G4int etaBin = (G4int) ( std::fabs(etaZpos) / DM1EtaWidth ) ; - G4int phiBin = (G4int) (phiZpos/ DM1PhiWidth ); - if (phiBin>63) phiBin=63; - G4int sampling; - G4int region; - G4int type=1; - - if (radiusZpos < m_radiusPS) - { -// before PSactive - sampling=1; - G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume(); - G4String volName = vol->GetName(); - if (volName.find("LAr::TBBarrel::Cryostat::WarmTube") != std::string::npos) region=0; - else if (volName.find("LAr::TBBarrel::Cryostat::ColdTube") != std::string::npos ) region=1; - else region=2; - if (etaBin>14) etaBin=14; - } - else if (radiusZpos < m_rminAcc) - { -// between PS and Accordion - sampling=1; - region=3; - if (etaBin>14) etaBin=14; - } - else if (radiusZpos < m_rmaxAcc) - { -// we will use this for the leakage on the side of the test beam module... - sampling=2; - if (fabs(etaZpos)<1.0) { - region=0; - etaBin=0; - } else { - region=2; - etaBin=0; - } - } - else - { -// between LAr and Tile - sampling=2; - region=0; - if (std::fabs(etaZpos) > 1.0) { - region=2; - etaBin = (G4int) ( std::fabs(etaZpos-1.0) / DM1EtaWidth ) ; - if (etaBin>4) etaBin=4; - } - } - - m_identifier << 10 // LArCalorimeter + G4double etaZpos = midinLocal.pseudoRapidity(); + G4double phiZpos = midinLocal.phi(); + if(phiZpos<0.) phiZpos = phiZpos + 2.*M_PI; + G4double radius2Zpos = xZpos*xZpos + yZpos*yZpos; + G4double radiusZpos = sqrt(radius2Zpos); + + G4int zSide = 1; + G4int numDeadPhiBins = 64; + G4double DM1EtaWidth = 0.1 ; + G4double DM1PhiWidth = 2.*M_PI / numDeadPhiBins ; + G4int etaBin = (G4int) ( std::fabs(etaZpos) / DM1EtaWidth ) ; + G4int phiBin = (G4int) (phiZpos/ DM1PhiWidth ); + if (phiBin>63) phiBin=63; + G4int sampling; + G4int region; + G4int type=1; + + if (radiusZpos < m_radiusPS) + { + // before PSactive + sampling=1; + G4VPhysicalVolume* vol = thisStepPoint->GetPhysicalVolume(); + G4String volName = vol->GetName(); + if (volName.find("LAr::TBBarrel::Cryostat::WarmTube") != std::string::npos) region=0; + else if (volName.find("LAr::TBBarrel::Cryostat::ColdTube") != std::string::npos ) region=1; + else region=2; + if (etaBin>14) etaBin=14; + } + else if (radiusZpos < m_rminAcc) + { + // between PS and Accordion + sampling=1; + region=3; + if (etaBin>14) etaBin=14; + } + else if (radiusZpos < m_rmaxAcc) + { + // we will use this for the leakage on the side of the test beam module... + sampling=2; + if (fabs(etaZpos)<1.0) { + region=0; + etaBin=0; + } else { + region=2; + etaBin=0; + } + } + else + { + // between LAr and Tile + sampling=2; + region=0; + if (std::fabs(etaZpos) > 1.0) { + region=2; + etaBin = (G4int) ( std::fabs(etaZpos-1.0) / DM1EtaWidth ) ; + if (etaBin>4) etaBin=4; + } + } + + identifier << 10 // LArCalorimeter << zSide * 4 // LArBarrel << type << sampling @@ -176,27 +180,26 @@ G4bool LArTBCryostatCalibrationCalculator::Process( const G4Step* a_step, << etaBin << phiBin; -// if (!m_geometry->CheckDMIdentifier(type,sampling,region,etaBin,phiBin)) -// { -// std::cout << " LArTBCryostatCalibrationCalculator: Invalid DM identifier " -// << std::string(m_identifier) << std::endl; -// } + // if (!m_geometry->CheckDMIdentifier(type,sampling,region,etaBin,phiBin)) + // { + // std::cout << " LArTBCryostatCalibrationCalculator: Invalid DM identifier " + // << std::string(identifier) << std::endl; + // } - } // calculate identifier - + } // calculate identifier + #ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArTBBarrelCryostatCalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; + G4double energy = accumulate(energies.begin(),energies.end(),0.); + std::cout << "LArTBBarrelCryostatCalibrationCalculator::Process" + << " ID=" << std::string(identifier) + << " energy=" << energy + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" + << std::endl; #endif return true; } - diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.h old mode 100755 new mode 100644 index c2fbe9dd57e5..cd285b5a540a --- a/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/LArTBCryostatCalibrationCalculator.h @@ -6,7 +6,7 @@ // 22 sep 2004 G.Unal // This class calculates the values needed for calibration hits in the -// simulation. +// simulation. // A "calculator" is used in much the same way as a hand-held // calculator might be. The user supplies a value and hits 'Enter' @@ -22,11 +22,11 @@ #ifndef LArG4H8SD_Cryostat_CalibrationCalculator_H #define LArG4H8SD_Cryostat_CalibrationCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" -#include "LArG4Barrel/LArBarrelGeometry.h" +// #include "LArG4Barrel/LArBarrelGeometry.h" #include "globals.hh" @@ -40,48 +40,39 @@ class G4Step; // like LArG4HECCalibrationCalculator). This class is contained in // the namespace LArG4::BarrelCryostat. -class LArTBCryostatCalibrationCalculator : public LArG4::VCalibrationCalculator +class LArTBCryostatCalibrationCalculator : public LArCalibCalculatorSvcImp { - public: - - LArTBCryostatCalibrationCalculator(); - virtual ~LArTBCryostatCalibrationCalculator(); - - // The Process method returns a boolean value. If it's true, the - // hit can be used by Geant4; if it's false, there's something wrong - // with the energy deposit and it should be ignored. - - // For calibration work, most of the time we want the calculator - // to determine both the energy and the identifier. However, - // sometimes we want it calculate only the identifier (for - // escaped energy), or only the energy (no known application - // yet, but you can never tell). Use the enum (defined in - // VCalibrationCalculator.h) to control any special processing. - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } - - private: - - // The values calculated by Process(). - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - - // Energy calculator - CaloG4::SimulationEnergies m_energyCalculator; - - LArG4::Barrel::Geometry* m_geometry; - - G4double m_radiusPS; - G4double m_rminAcc; - G4double m_rmaxAcc; +public: + + LArTBCryostatCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + // virtual StatusCode initialize() override final; + virtual ~LArTBCryostatCalibrationCalculator(); + + // The Process method returns a boolean value. If it's true, the + // hit can be used by Geant4; if it's false, there's something wrong + // with the energy deposit and it should be ignored. + + // For calibration work, most of the time we want the calculator + // to determine both the energy and the identifier. However, + // sometimes we want it calculate only the identifier (for + // escaped energy), or only the energy (no known application + // yet, but you can never tell). Use the enum (defined in + // VCalibrationCalculator.h) to control any special processing. + + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const LArG4::eCalculatorProcessing p = LArG4::kEnergyAndID) const override final; + +private: + + // Energy calculator + CaloG4::SimulationEnergies m_energyCalculator; + + // LArG4::Barrel::Geometry* m_geometry; + + G4double m_radiusPS; + G4double m_rminAcc; + G4double m_rmaxAcc; }; diff --git a/LArCalorimeter/LArG4/LArG4H8SD/src/components/LArG4H8SD_entries.cxx b/LArCalorimeter/LArG4/LArG4H8SD/src/components/LArG4H8SD_entries.cxx index e8e84bc2a9c2..18e8f8f61512 100644 --- a/LArCalorimeter/LArG4/LArG4H8SD/src/components/LArG4H8SD_entries.cxx +++ b/LArCalorimeter/LArG4/LArG4H8SD/src/components/LArG4H8SD_entries.cxx @@ -1,5 +1,13 @@ #include "GaudiKernel/DeclareFactoryEntries.h" #include "../LArG4H8CalibSDTool.h" +#include "../H8CalibSDTool.h" -DECLARE_TOOL_FACTORY( LArG4H8CalibSDTool ) \ No newline at end of file +#include "../LArTBCryostatCalibrationCalculator.h" +#include "../H8CalibrationDefaultCalculator.h" + +DECLARE_TOOL_FACTORY( LArG4::H8CalibSDTool ) +DECLARE_TOOL_FACTORY( LArG4H8CalibSDTool ) + +DECLARE_SERVICE_FACTORY(LArTBCryostatCalibrationCalculator) +DECLARE_SERVICE_FACTORY(H8CalibrationDefaultCalculator) diff --git a/LArCalorimeter/LArG4/LArG4HEC/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4HEC/CMakeLists.txt index 49126ca1c835..713f43de41c0 100644 --- a/LArCalorimeter/LArG4/LArG4HEC/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4HEC/CMakeLists.txt @@ -7,16 +7,16 @@ atlas_subdir( LArG4HEC ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC - Calorimeter/CaloG4Sim - LArCalorimeter/LArG4/LArG4Code LArCalorimeter/LArGeoModel/LArReadoutGeometry + Control/AthenaBaseComps PRIVATE Control/AthenaKernel Control/StoreGate Database/AthenaPOOL/RDBAccessSvc DetectorDescription/GeoModel/GeoModelInterfaces GaudiKernel - LArCalorimeter/LArG4/LArG4RunControl + Calorimeter/CaloG4Sim + LArCalorimeter/LArG4/LArG4Code LArCalorimeter/LArGeoModel/LArHV ) # External dependencies: @@ -27,12 +27,14 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_library( LArG4HEC +atlas_add_component( LArG4HEC src/*.cc + src/components/*.cxx PUBLIC_HEADERS LArG4HEC INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} DEFINITIONS ${CLHEP_DEFINITIONS} - LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} LArG4Code LArReadoutGeometry CaloG4SimLib StoreGateLib SGtests + LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} AthenaBaseComps LArG4Code LArReadoutGeometry CaloG4SimLib StoreGateLib SGtests PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} AthenaKernel GaudiKernel LArG4RunControl LArHV ) +atlas_install_python_modules( python/*.py ) diff --git a/LArCalorimeter/LArG4/LArG4HEC/GNUmakefile b/LArCalorimeter/LArG4/LArG4HEC/GNUmakefile old mode 100755 new mode 100644 diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/CalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/CalibrationCalculator.h deleted file mode 100755 index 5265119af225..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/CalibrationCalculator.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::HEC::CalibrationCalculator -// Prepared 13-Jan-2004 Bill Seligman - -// This class calculates the values needed for calibration hits in the -// simulation. - -// A "calculator" is used in much the same way as a hand-held -// calculator might be. The user supplies a value and hits 'Enter' -// (i.e., invokes the Process() method). Then they read off whatever -// values are of interest. - -#ifndef LArG4_HEC_CalibrationCalculator_H -#define LArG4_HEC_CalibrationCalculator_H - -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4HEC/Geometry.h" -#include "CaloG4Sim/SimulationEnergies.h" - -#include "globals.hh" - -#include <vector> - -// Forward declaractions: -class G4Step; - -// Note the use of nested namespaces (mainly to prevent long names -// like LArG4HECCalibrationCalculator). This class is contained in -// the namespace LArG4::HEC. - -namespace LArG4 { - - namespace HEC { - - - class CalibrationCalculator : public VCalibrationCalculator { - public: - - CalibrationCalculator(const eGeometryType type = kActive); - virtual ~CalibrationCalculator(); - - // The Process method returns a boolean value. If it's true, the - // hit can be used by Geant4; if it's false, there's something wrong - // with the energy deposit and it should be ignored. - - // For calibration work, most of the time we want the calculator - // to determine both the energy and the identifier. However, - // sometimes we want it calculate only the identifier (for - // escaped energy), or only the energy (no known application - // yet, but you can never tell). Use the enum (defined in - // VCalibrationCalculator.h) to control any special processing. - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } - - private: - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; - - // Geometry calculator - Geometry* m_geometryCalculator; - - // Geometry type - eGeometryType m_geometryType; - - // Energy calculator - CaloG4::SimulationEnergies m_energyCalculator; - - }; - - } // namespace HEC - -} // namespace LArG4 - -#endif // LArG4_HEC_CalibrationCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/Geometry.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/Geometry.h deleted file mode 100755 index 14f25c8165ca..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/Geometry.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::HEC::Geometry - -// This class contains the geometry calculations needed to calculate -// an identifier for a given G4Step. - -// 13-Jan-2004: Karapetian Gaiane wrote the geometry code, Bill -// Seligman structured into the LArG4 processing. - -// Note: This class is intended for use in calculating identifiers in -// both active and inactive regions of the detector. For calibration -// studies, it must work properly whether the energy is deposited in -// the liquid argon or the absorber. - -#ifndef LArG4_HEC_Geometry_H -#define LArG4_HEC_Geometry_H - -#include "G4ThreeVector.hh" -#include "globals.hh" - -// Forward declarations. -class LArG4Identifier; -class G4Step; - -// Note the use of nested namespaces (mainly to prevent long names -// like LArG4HECGeometry). This class is contained in the namespace -// LArG4::HEC. - -namespace LArG4 { - - namespace HEC { - - enum eGeometryType { kActive, kInactive, kDead }; - - class Geometry { - - public: - - // Standard implementation of a singleton pattern. - static Geometry* GetInstance(); - virtual ~Geometry(); - - // This is the "meat" of this class: calculate the identifier - // given a G4Step. - LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eGeometryType type = kActive ); - - protected: - // Constructor is protected according to the singleton pattern. - Geometry(); - - private: - - // Nominal z-shift from base. (Note: someday, this will have to - // be replaced with a G4Transform3D or similar description that's - // suitable for re-alignment; for now, this will do.) - G4float m_zShift; - - }; - - } // namespace HEC - -} // namespace LArG4 - -#endif // LArG4_HEC_Geometry_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/HECGeometry.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/HECGeometry.h old mode 100755 new mode 100644 index 623648b8ffde..0b1bf4ecd805 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/HECGeometry.h +++ b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/HECGeometry.h @@ -5,65 +5,64 @@ // This class contains the geometry calculations needed to calculate // an identifier for a given G4Step in the HEC. -// Jan-2008: (M.Fincke) To be used for new Module-Geometry +// Jan-2008: (M.Fincke) To be used for new Module-Geometry #ifndef LArG4_HEC_HECGeometry_H #define LArG4_HEC_HECGeometry_H +#include "LArG4HEC/IHECGeometry.h" +#include "AthenaBaseComps/AthService.h" + #include "LArReadoutGeometry/HECDetectorManager.h" -#include "LArReadoutGeometry/HECDetectorRegion.h" -#include "LArG4Code/LArVG4DetectorParameters.h" +//#include "LArReadoutGeometry/HECDetectorRegion.h" #include "globals.hh" // Forward declarations. class LArG4Identifier; class G4Step; -class MsgStream; +class G4LogicalVolume; +class G4VPhysicalVolume; namespace LArG4 { namespace HEC { - enum eHECGeometryType { kWheelActive, kWheelInactive, kWheelDead }; - - class HECGeometry { + class HECGeometry: public AthService, virtual public IHECGeometry { public: - // Standard implementation of a singleton pattern. - static HECGeometry* GetInstance(); + HECGeometry(const std::string& name, ISvcLocator * pSvcLocator); + StatusCode initialize() override final; virtual ~HECGeometry(){;} - LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eHECGeometryType type = kWheelActive, int *subgap=NULL); - + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; - protected: - HECGeometry(); + LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eHECGeometryType type = kWheelActive, int *subgap=NULL) const override final; private: - static HECGeometry *m_instance; - - const HECDetectorManager *hecManager; - - static bool m_depthHist; - static bool m_withMother; - static bool m_inMother; - - static int m_g4historyDepth; - static double depthSize[7]; - static double depthSum[7]; - static double minval[7][2][10]; - static double maxval[7][2][10]; - - static double firstAbsThickness[2]; - static double wheel1; - static double wheel2; - static double betweenWheels; - static double hecLength; - static double startHec2; - static double rOuter; - static double rInner1; - static double rInner2; + bool checkDaughters(const G4LogicalVolume *possibleParent, const G4VPhysicalVolume *thePhysicalVolume, int& level) const; + + const HECDetectorManager *m_hecManager; + + bool m_depthHist; + bool m_withMother; + + int m_g4historyDepth; + double m_depthSize[7]; + double m_depthSum[7]; + double m_minval[7][2][10]; + double m_maxval[7][2][10]; + + double m_firstAbsThickness[2]; + double m_wheel1; + double m_wheel2; + double m_betweenWheels; + double m_hecLength; + double m_startHec2; + double m_rOuter; + double m_rInner1; + double m_rInner2; }; diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/IHECGeometry.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/IHECGeometry.h new file mode 100644 index 000000000000..0ab868d71b53 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/IHECGeometry.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// IHECGeometry.h +// Common interface for Geometry Calculator classes + +#ifndef __LARG4HEC_IHECGEOMETRY_H__ +#define __LARG4HEC_IHECGEOMETRY_H__ + +#include "GaudiKernel/IService.h" + +//#include "globals.hh" + +//#include "LArG4Code/LArG4Identifier.h" + +#include <string> + +class G4Step; +class LArG4Identifier; + +namespace LArG4 +{ + namespace HEC + { + + enum eHECGeometryType { kWheelActive, kWheelInactive, kWheelDead }; + + class IHECGeometry : virtual public IService + { + public: + IHECGeometry() {} + virtual ~IHECGeometry() {} + + static const InterfaceID& interfaceID() { + static const InterfaceID IID_IHECGeometry("IHECGeometry",1,0); + return IID_IHECGeometry; + } + + virtual LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eHECGeometryType type = kWheelActive, int *subgap=NULL) const = 0; + + }; + + } +} +#endif //__LARG4HEC_IHECGEOMETRY_H__ diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/ILocalGeometry.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/ILocalGeometry.h new file mode 100644 index 000000000000..8f5bdf8d6746 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/ILocalGeometry.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ILocalGeometry.h + +#ifndef __LARG4HEC_ILOCALGEOMETRY_H__ +#define __LARG4HEC_ILOCALGEOMETRY_H__ + +#include "GaudiKernel/IService.h" +#include "CLHEP/Units/SystemOfUnits.h" + +//#include "globals.hh" + +//#include "LArG4Code/LArG4Identifier.h" + +#include <string> + +class G4Step; +class LArG4Identifier; + +namespace LArG4 +{ + namespace HEC + { + + enum eLocalGeometryType { kLocActive, kLocInactive, kLocDead }; + + class ILocalGeometry : virtual public IService + { + public: + ILocalGeometry() {} + virtual ~ILocalGeometry() {} + + static const InterfaceID& interfaceID() { + static const InterfaceID IID_ILocalGeometry("ILocalGeometry",1,0); + return IID_ILocalGeometry; + } + + virtual LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eLocalGeometryType type = kLocActive, + int depthadd = 0, double deadzone = 4.*CLHEP::mm, double locyadd = 0.*CLHEP::mm) const = 0; + + }; + + } +} +#endif //__LARG4HEC_ILOCALGEOMETRY_H__ diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalculator.h deleted file mode 100755 index 305a024ffdd3..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalculator.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArHECCalculator - -// Revision history: - -// 31-May-2002 : Karapetian Gaiane - -// 13-Jan-2004 WGS: Now uses LArG4::HEC::Geometry for the Identifier calculations. - -#ifndef LARG4HEC_LARHECCALCULATOR_H -#define LARG4HEC_LARHECCALCULATOR_H - -#include "globals.hh" -#include "G4ThreeVector.hh" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include <stdexcept> -// Forward declarations. -class G4Step; -namespace LArG4 { - namespace HEC { - class Geometry; - } -} - -class LArHECCalculator : public LArVCalculator { -public: - - // Accessor for pointer to the singleton. - static LArHECCalculator* GetCalculator(); - - // "zShift" is the z-distance (cm) that the EM endcap is shifted - // (due to cabling, etc.) - G4float zShift() const { return m_zShift; } - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata); - - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - }; - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - - ///////////////////////////////////////////// - - G4bool GetDoChargeCollection() const { return m_chargeCollection; } - void SetDoChargeCollection(G4bool f) { m_chargeCollection = f; } - -protected: - // The constructor is protected according to the singleton design - // pattern. - LArHECCalculator(); - -private: - static LArHECCalculator* m_instance; - - G4float m_zShift; - G4float m_OOTcut; -// LArG4Identifier m_identifier; - -// G4double m_time; -// G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4bool m_isInTime; - - // Class for calculating the identifier. - LArG4::HEC::Geometry* m_geometry; - - // Flag to determine if we invoke charge-collection processing. - G4bool m_chargeCollection; -}; - -#endif // not LARG4HEC_LARHECCALCULATOR_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalibrationWheelCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalibrationWheelCalculator.h deleted file mode 100755 index 17169b9ba4e8..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECCalibrationWheelCalculator.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// Jan-2008: (M.Fincke) To be used for new Module-Geometry - -#ifndef LArG4_HEC_LArHECCalibrationWheelCalculator_H -#define LArG4_HEC_LArHECCalibrationWheelCalculator_H - -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4HEC/HECGeometry.h" -#include "CaloG4Sim/SimulationEnergies.h" - -#include "globals.hh" - -#include <vector> - -// Forward declaractions: -class G4Step; - -namespace LArG4 { - - namespace HEC { - - - class LArHECCalibrationWheelCalculator : public VCalibrationCalculator { - public: - - LArHECCalibrationWheelCalculator(const eHECGeometryType type = kWheelActive); - virtual ~LArHECCalibrationWheelCalculator(); - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - virtual const std::vector<G4double>& energies() const { return m_energies; } - - private: - LArG4Identifier m_identifier; - - std::vector<G4double> m_energies; - - HECGeometry* m_geometryCalculator; - - eHECGeometryType m_geometryType; - - CaloG4::SimulationEnergies m_energyCalculator; - - }; - - } // namespace HEC - -} // namespace LArG4 - -#endif // LArG4_HEC_LArHECCalibrationWheelCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECLocalCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECLocalCalculator.h deleted file mode 100755 index 49ca9743c5ca..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECLocalCalculator.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4HECLocalCalculator.hh - -// Revision history: - -// 17-Feb-2006 : Pavol Strizenec - -#ifndef __LArG4HECLocalCalculator_H__ -#define __LArG4HECLocalCalculator_H__ - -//#include "globals.hh" -//#include "G4ThreeVector.hh" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include <stdexcept> -#include "CLHEP/Units/SystemOfUnits.h" - - -// Forward declarations. -class G4Step; -class LocalGeometry; -class IMessageSvc; -class LArG4BirksLaw; - -namespace LArG4 { - namespace HEC { - class LocalGeometry; - } -} - - -class LArHECLocalCalculator : public LArVCalculator { -public: - - // Accessor for pointer to the singleton. - static LArHECLocalCalculator* GetCalculator(); - - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } - - virtual G4bool Process(const G4Step* a_step){ return Process(a_step,0, 4.*CLHEP::mm, m_hdata);} - virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata){ return Process(a_step,0, 4.*CLHEP::mm, hdata);} - virtual G4bool Process(const G4Step* a_step, int depthadd, double deadzone, std::vector<LArHitData>& hdata); - - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - }; - virtual G4bool isInTime() const { return m_isInTime; } - virtual G4bool isInTime(int i) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime() const { return ( ! m_isInTime ); } - virtual G4bool isOutOfTime(int i) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - G4bool isX() const { return m_isX; } - void SetX(bool x); - -protected: - // The constructor is protected according to the singleton design - // pattern. - LArHECLocalCalculator(); - ~LArHECLocalCalculator(); - -private: - static LArHECLocalCalculator* m_instance; - - LArG4::HEC::LocalGeometry *m_Geometry; - - IMessageSvc *m_msgSvc; - -// LArG4Identifier m_identifier; - -// G4double m_time; -// G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4float m_OOTcut; - G4bool m_isInTime; - - LArG4BirksLaw *m_birksLaw; - static G4bool m_isX; - - LArHECLocalCalculator (const LArHECLocalCalculator&); - LArHECLocalCalculator operator= (const LArHECLocalCalculator&); -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECWheelCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECWheelCalculator.h deleted file mode 100755 index 97ca932773c9..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LArHECWheelCalculator.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArHECWheelCalculator.hh - -// Revision history: - -// Jan-2008: (M.Fincke) To be used for new Module-Geometry - -#ifndef __LArG4HECWheelCalculator_H__ -#define __LArG4HECWheelCalculator_H__ - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include <stdexcept> - -// Forward declarations. - -class G4Step; -class HECGeometry; -class IMessageSvc; -class LArG4BirksLaw; -class HECDetectorManager; - -namespace LArG4 { - namespace HEC { - class HECGeometry; - } -} - - -class LArHECWheelCalculator : public LArVCalculator { -public: - - // Accessor for pointer to the singleton. - static LArHECWheelCalculator* GetCalculator(); - - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } - - virtual G4bool Process(const G4Step* a_step){ return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata); - - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - }; - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( ! m_isInTime ); - } - - ~LArHECWheelCalculator(); - -protected: - // The constructor is protected according to the singleton design - // pattern. - LArHECWheelCalculator(); - -private: - static LArHECWheelCalculator* m_instance; - - LArG4::HEC::HECGeometry *m_Geometry; - const HECDetectorManager *m_DetectorManager; - - IMessageSvc *m_msgSvc; - -// LArG4Identifier m_identifier; - -// G4double m_time; -// G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4float m_OOTcut; - G4bool m_isInTime; - LArG4BirksLaw *m_birksLaw; - - LArHECWheelCalculator (const LArHECWheelCalculator&); - LArHECWheelCalculator& operator= (const LArHECWheelCalculator&); -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalCalibrationCalculator.h deleted file mode 100755 index f04162633f63..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalCalibrationCalculator.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LArG4_HEC_LocalCalibrationCalculator_H -#define LArG4_HEC_LocalCalibrationCalculator_H - -#include "LArG4Code/VCalibrationCalculator.h" -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4HEC/LocalGeometry.h" -#include "CaloG4Sim/SimulationEnergies.h" - -#include "globals.hh" - -#include <vector> - -// Forward declaractions: -class G4Step; - -namespace LArG4 { - - namespace HEC { - - - class LocalCalibrationCalculator : public VCalibrationCalculator { - public: - - LocalCalibrationCalculator(const eLocalGeometryType type = kLocActive); - virtual ~LocalCalibrationCalculator(); - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - virtual const std::vector<G4double>& energies() const { return m_energies; } - - private: - LArG4Identifier m_identifier; - - std::vector<G4double> m_energies; - - LocalGeometry* m_geometryCalculator; - - eLocalGeometryType m_geometryType; - - CaloG4::SimulationEnergies m_energyCalculator; - - }; - - } // namespace HEC - -} // namespace LArG4 - -#endif // LArG4_HEC_LocalCalibrationCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h old mode 100755 new mode 100644 index 7a4287178724..f8d9dbcba7aa --- a/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h +++ b/LArCalorimeter/LArG4/LArG4HEC/LArG4HEC/LocalGeometry.h @@ -17,44 +17,51 @@ #ifndef LArG4_HEC_LocalGeometry_H #define LArG4_HEC_LocalGeometry_H -#include "LArG4Code/LArVG4DetectorParameters.h" -#include "globals.hh" -#include "CLHEP/Units/SystemOfUnits.h" +#include "LArG4HEC/ILocalGeometry.h" +#include "AthenaBaseComps/AthService.h" +#include "GeoModelInterfaces/IGeoModelSvc.h" +#include "RDBAccessSvc/IRDBAccessSvc.h" +//#include "globals.hh" // Forward declarations. class LArG4Identifier; class G4Step; -class MsgStream; +// class IGeoModelSvc; +// class IRDBAccessSvc; namespace LArG4 { namespace HEC { - enum eLocalGeometryType { kLocActive, kLocInactive, kLocDead }; - - class LocalGeometry { + class LocalGeometry: public AthService, virtual public ILocalGeometry { public: - // Standard implementation of a singleton pattern. - static LocalGeometry* GetInstance(); + LocalGeometry(const std::string& name, ISvcLocator * pSvcLocator); + StatusCode initialize() override final; virtual ~LocalGeometry(){;} - LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eLocalGeometryType type = kLocActive , int depthadd = 0, double deadzone = 4.*CLHEP::mm, double locyadd = 0.*CLHEP::mm); + /** Query interface method to make athena happy */ + virtual StatusCode queryInterface(const InterfaceID&, void**) override final; - bool isX() const { return m_isX; } - void SetX(G4bool x) { m_isX = x; } + LArG4Identifier CalculateIdentifier( const G4Step* a_step, const eLocalGeometryType type = kLocActive, + int depthadd = 0, double deadzone = 4.*CLHEP::mm, double locyadd = 0.*CLHEP::mm) const override final; - protected: - LocalGeometry(); + //bool isX() const { return m_isX; } //UNUSED + //void SetX(G4bool x) { m_isX = x; } private: - static LocalGeometry *m_instance; - - MsgStream *m_log; - - static bool m_isX; - + int binSearch(double ly, int depth, int reg) const; + int binSearchAll(double ly, int depth, bool regular=false) const; + double deadZone(double locx, double locy) const; + ServiceHandle<IGeoModelSvc> m_geoModel; + ServiceHandle<IRDBAccessSvc> m_AccessSvc; + + bool m_isX; + double m_depthSize[7] = {0.0}; + double m_firstAbsorber[7] = {0.0}; + double m_pads[7][15] = {}; // 15 is the number of bins in eta. + double m_betweenWheel = 0.0; }; } // namespace HEC diff --git a/LArCalorimeter/LArG4/LArG4HEC/cmt/requirements b/LArCalorimeter/LArG4/LArG4HEC/cmt/requirements index 92070d06997e..f1487a9374f5 100755 --- a/LArCalorimeter/LArG4/LArG4HEC/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4HEC/cmt/requirements @@ -10,27 +10,30 @@ author Mikhail Leltchouk <lelchuk@nevis.columbia.edu> # hadronic endcap calorimeter (HEC). use AtlasPolicy AtlasPolicy-* -use LArReadoutGeometry LArReadoutGeometry-* LArCalorimeter/LArGeoModel -use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use CaloG4Sim CaloG4Sim-* Calorimeter +use AthenaBaseComps AthenaBaseComps-* Control +use LArReadoutGeometry LArReadoutGeometry-* LArCalorimeter/LArGeoModel +use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL +use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel -use Geant4 Geant4-* External use AtlasCLHEP AtlasCLHEP-* External # Build the library (and export the headers) -library LArG4HEC *.cc -apply_pattern installed_library +library LArG4HEC *.cc -s=components *.cxx +apply_pattern component_library +apply_pattern declare_python_modules files="*.py" #======================================================= private -macro_append LArG4HEC_cppflags " -O -Wno-unused" -macro_append LArG4HEC_cppflags " -g -O0" +#macro_append LArG4HEC_cppflags " -O -Wno-unused" +#macro_append LArG4HEC_cppflags " -g -O0" -use GaudiInterface GaudiInterface-* External +use GaudiInterface GaudiInterface-* External use AthenaKernel AthenaKernel-* Control use StoreGate StoreGate-* Control -use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL -use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel -use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 +#use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL +#use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel use LArHV LArHV-* LArCalorimeter/LArGeoModel +use LArG4Code LArG4Code-* LArCalorimeter/LArG4 +use CaloG4Sim CaloG4Sim-* Calorimeter +use Geant4 Geant4-* External diff --git a/LArCalorimeter/LArG4/LArG4HEC/python/HECGeometryType.py b/LArCalorimeter/LArG4/LArG4HEC/python/HECGeometryType.py new file mode 100644 index 000000000000..23eb3a88833a --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/python/HECGeometryType.py @@ -0,0 +1,5 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +kWheelActive=0 +kWheelInactive=1 +kWheelDead=2 diff --git a/LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfig.py b/LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfig.py new file mode 100644 index 000000000000..803eab3382cf --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfig.py @@ -0,0 +1,36 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr +from LArG4HEC import HECGeometryType + +def getLArHECLocalCalculator(name="LArHECLocalCalculator", **kwargs): + return CfgMgr.LArHECLocalCalculator(name, **kwargs) + +def getLocalCalibrationCalculator(name="LocalCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__HEC__LocalCalibrationCalculator(name, **kwargs) + +def getLocalHECGeometry(name="LocalHECGeometry", **kwargs): + return CfgMgr.LArG4__HEC__LocalGeometry(name, **kwargs) + + +def getHECWheelCalculator(name="HECWheelCalculator", **kwargs): + return CfgMgr.LArHECWheelCalculator(name, **kwargs) + +def getLArHECCalibrationWheelCalculator(name="LArHECCalibrationWheelCalculator", **kwargs): + return CfgMgr.LArG4__HEC__LArHECCalibrationWheelCalculator(name, **kwargs) + +def getHECCalibrationWheelActiveCalculator(name="HECCalibrationWheelActiveCalculator", **kwargs): + kwargs.setdefault("GeometryType", HECGeometryType.kWheelActive) + return getLArHECCalibrationWheelCalculator(name, **kwargs) + +def getHECCalibrationWheelInactiveCalculator(name="HECCalibrationWheelInactiveCalculator", **kwargs): + kwargs.setdefault("GeometryType", HECGeometryType.kWheelInactive) + return getLArHECCalibrationWheelCalculator(name, **kwargs) + +def getHECCalibrationWheelDeadCalculator(name="HECCalibrationWheelDeadCalculator", **kwargs): + kwargs.setdefault("GeometryType", HECGeometryType.kWheelDead) + return getLArHECCalibrationWheelCalculator(name, **kwargs) + +def getHECGeometry(name="HECGeometry", **kwargs): + return CfgMgr.LArG4__HEC__HECGeometry(name, **kwargs) + diff --git a/LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfigDb.py b/LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfigDb.py new file mode 100644 index 000000000000..4b91afbd062c --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/python/LArG4HECConfigDb.py @@ -0,0 +1,13 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addService + +addService("LArG4HEC.LArG4HECConfig.getLArHECLocalCalculator","LArHECLocalCalculator") +addService("LArG4HEC.LArG4HECConfig.getLocalCalibrationCalculator","LocalCalibrationCalculator") +addService("LArG4HEC.LArG4HECConfig.getLocalHECGeometry","LocalHECGeometry") + +addService("LArG4HEC.LArG4HECConfig.getHECWheelCalculator","HECWheelCalculator") +addService("LArG4HEC.LArG4HECConfig.getHECCalibrationWheelActiveCalculator","HECCalibrationWheelActiveCalculator") +addService("LArG4HEC.LArG4HECConfig.getHECCalibrationWheelInactiveCalculator","HECCalibrationWheelInactiveCalculator") +addService("LArG4HEC.LArG4HECConfig.getHECCalibrationWheelDeadCalculator","HECCalibrationWheelDeadCalculator") +addService("LArG4HEC.LArG4HECConfig.getHECGeometry","HECGeometry") diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/CalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/CalibrationCalculator.cc deleted file mode 100755 index e872dd3f5a09..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/src/CalibrationCalculator.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::HEC::CalibrationCalculator -// Prepared 13-Jan-2004 Bill Seligman - -// This class calculates the values needed for calibration hits in the -// simulation. - -#undef DEBUG_HITS - -#include "LArG4HEC/CalibrationCalculator.h" -#include "LArG4HEC/Geometry.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4Step.hh" -#include "globals.hh" - -#include <algorithm> - -namespace LArG4 { - - namespace HEC { - - CalibrationCalculator::CalibrationCalculator(const eGeometryType type) - { - // Initialize the geometry calculator. - m_geometryCalculator = Geometry::GetInstance(); - m_geometryType = type; - } - - - CalibrationCalculator::~CalibrationCalculator() - { - } - - - G4bool CalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) - { - // Use the calculators to determine the energies and the - // identifier associated with this G4Step. Note that the - // default is to process both the energy and the ID. - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { -#ifdef DEBUG_HITS - std::cout << "LArG4::HEC::CalibrationCalculator::Process" - << " calling SimulationEnergies" << std::endl; -#endif - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - m_identifier = m_geometryCalculator->CalculateIdentifier( a_step, m_geometryType ); - } - else - m_identifier = LArG4Identifier(); - - -#ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); - std::cout << "LArG4::HEC::CalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) - << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" - << std::endl; -#endif - - // Check for bad result. - if ( m_identifier == LArG4Identifier() ) - return false; - - return true; - } - - } // namespace HEC - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/Geometry.cc b/LArCalorimeter/LArG4/LArG4HEC/src/Geometry.cc deleted file mode 100755 index 1f3fdb7c80ce..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/src/Geometry.cc +++ /dev/null @@ -1,396 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArG4::HEC::Geometry - -// This class contains the geometry calculations needed to calculate -// an identifier for a given G4Step. - -// 13-Jan-2004: Karapetian Gaiane wrote the geometry code, Bill -// Seligman structured into the LArG4 processing. - -#include "LArG4HEC/Geometry.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4ThreeVector.hh" -#include "G4StepPoint.hh" -#include "G4Step.hh" -#include "G4LogicalVolume.hh" -#include "G4LogicalVolumeStore.hh" -#include "G4TouchableHistory.hh" - - -#include "RDBAccessSvc/IRDBAccessSvc.h" -#include "RDBAccessSvc/IRDBRecord.h" -#include "RDBAccessSvc/IRDBRecordset.h" -#include "GeoModelInterfaces/IGeoModelSvc.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" -#include "globals.hh" -// 03-Jan-2002 WGS: For 'copysign'. -#include <cmath> -#include <stdexcept> -static G4double depthSize[7]; -static G4double firstAbsorber[7]; -static G4int gapNumber[7]; -static G4double moduleNumber; -static G4double zStart ; -static G4double betweenWheel; -static G4double moduleDeltaPhi; -static G4double samplingStartZ[4]; -static G4double samplingEndZ[4]; -static G4double moduleRinner1; -static G4double moduleRinner2; - -static const G4double deadZone = 4.*CLHEP::mm; - - -#undef DEBUG_HEC - -namespace LArG4 { - - namespace HEC { - - // Standard implementation of a singleton pattern. - - Geometry* Geometry::GetInstance() - { - static Geometry instance; - return &instance; - } - - - Geometry::Geometry() - { - - std::cout<<"LArG4::HEC::Geometry ERROR, should not be called !!!!"<<std::endl; - - StatusCode status; - // Access the GeoModelSvc: - ISvcLocator *svcLocator = Gaudi::svcLocator(); - IGeoModelSvc *geoModel; - status = svcLocator->service ("GeoModelSvc",geoModel); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); - } - - // Access the geometry database: - IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); - } - - // Obtain the geometry version information: - - std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); - - std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; - std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; - - - const IRDBRecordset *hecLongitudinalBlock = pAccessSvc->getRecordset("HecLongitudinalBlock",detectorKey,detectorNode); - if (hecLongitudinalBlock->size()==0) { - throw std::runtime_error("Cannot find the HecLongitinalBlock Table"); - } - - const IRDBRecordset *hadronicEndcap = pAccessSvc->getRecordset("HadronicEndcap",detectorKey,detectorNode); - if (hadronicEndcap->size()==0) { - throw std::runtime_error("Cannot find the HadronicEndcap Table"); - } - - const IRDBRecordset *emecGeometry = pAccessSvc->getRecordset("EmecGeometry",detectorKey,detectorNode); - if (emecGeometry->size()==0) { - throw std::runtime_error("Cannot find the EmecGeometry Table"); - } - - - // Constructor initializes the geometry. - - - // Get the endcap shift from the detector parameters. - m_zShift = (*emecGeometry)[0]->getDouble("ZSHIFT")*CLHEP::cm; - - // Get HEC parameters from the detector parameters. - zStart = (*hadronicEndcap)[0]->getDouble("ZSTART")*CLHEP::cm; // 427.7.*cm - - betweenWheel = (*hadronicEndcap)[0]->getDouble("GAPWHL")*CLHEP::cm-0.001*CLHEP::cm; //40.5*CLHEP::mm - moduleNumber = (*hadronicEndcap)[0]->getInt("NSCT"); // 32 Modules - for (G4int indexloop=0; indexloop < 7; ++indexloop){ - - depthSize[indexloop] = (*hecLongitudinalBlock)[indexloop]->getDouble("BLDPTH")*CLHEP::cm; - firstAbsorber[indexloop]= (*hecLongitudinalBlock)[indexloop]->getDouble("PLATE0")*CLHEP::cm; - gapNumber[indexloop] = (int) (*hecLongitudinalBlock)[indexloop]->getDouble("BLMOD"); - } - samplingStartZ[0] = zStart; - samplingEndZ[0] = zStart+depthSize[0]; - samplingStartZ[1] = samplingEndZ[0]; - samplingEndZ[1] = samplingEndZ[0] +depthSize[1]+depthSize[2]; - samplingStartZ[2] = samplingEndZ[1] + betweenWheel; - samplingEndZ[2] = samplingEndZ[1] +depthSize[3]+depthSize[4]+ betweenWheel; - samplingStartZ[3] = samplingEndZ[2]; - samplingEndZ[3] = samplingEndZ[2] +depthSize[5]+depthSize[6]; - - moduleDeltaPhi = 2*M_PI/moduleNumber; //11.25*deg; - - moduleRinner1 = (*hecLongitudinalBlock)[0]->getDouble("BLRMN")*CLHEP::cm; - moduleRinner2 = (*hecLongitudinalBlock)[0]->getDouble("BLRMN")*CLHEP::cm; - } - - - Geometry::~Geometry() {;} - - - LArG4Identifier Geometry::CalculateIdentifier(const G4Step* a_step, const eGeometryType g_type) - { - // Given a G4Step, find the sampling, region, eta bin, and phi bin - // in the LAr HEC associated with that point. - - // Note that we don't do any range checking; it is assumed that p - // lies within the LAr endcap. But we do have debug checks via asserts. - - // The default result is a blank identifier. - LArG4Identifier result = LArG4Identifier(); - - // Find out how long it took the energy to get here. - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - // Adjust the input point for any endcap offset (the endcap - // geometry was designed to point at (0,0,0) in the detector; if - // we've shifted the endcap, we have to project the geometry to a - // different point). - G4double pointZ = p.z(); - - G4double pointZshift = pointZ - copysign(m_zShift,pointZ); - - G4ThreeVector pointShift(p.x(), - p.y(), - pointZshift); - - // Determine eta, phi, and z w.r.t. the shifted point. - G4double eta = fabs( pointShift.pseudoRapidity() ); - G4double phi = pointShift.phi(); - if (phi < 0) phi += 2*M_PI; - G4double absZ = fabs( pointZshift ); - -#ifdef DEBUG_HEC - G4cout<<" ***NEW STEP**** "<<G4endl; - G4cout<<"middle point="<< pointZ<<" , eta = "<<eta <<" , phi= "<<phi<<G4endl; - G4cout<<"start point hit Z="<<startPoint.z()<<" , eta = "<<startPoint.pseudoRapidity()<<" ,phi()= "<<startPoint.phi()<<G4endl; - - assert (eta > 1.375); -#endif - - // Determine the "type" of the LArHecSolid in which the hit took place. - - // Positive/negative wheel of HEC - - G4int zSide; - G4int sampling; - G4int sector; - G4int region; - G4int etaBin; - G4int phiBin; - G4int phiSector; - - zSide = 2; - if ( pointZ < 0. ) zSide = -2; - -#ifdef DEBUG_HEC_OLD_DIAGNOSTIC - - // The hitted volume's identier is possible to get by the name of his "mother" volume. - // G4cout <<" hitLogiVolume->GetNoDaughters= " <<hitLogiVolume->GetNoDaughters()<<G4endl; - // G4cout <<"+++++"<<hitLogiVolume->GetDaughter(1)->GetLogicalVolume()->GetMaterial()->GetName()<<G4endl; - // G4cout <<"+++++"<<hitLogiVolume->GetName()<<G4endl; - - G4String hitVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); - - G4int copyN=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); - - // 16-Oct-2003 WGS: Due to a revision in Geant4, - // G4VPhysicalVolume::GetMother() no longer exists. If we want to - // find a mother volume, we have to do so in a more complex way: - - G4TouchableHistory* touchHist = - (G4TouchableHistory*) a_step->GetPreStepPoint()->GetTouchable(); - G4int volDepth = touchHist->GetHistoryDepth(); - - // If the volume depth is 0, then this is the mother volume of the - // simulation. (I know that's not likely, but let's be sure.) - // Otherwise, we want to go up one level in depth to get the mother - // volume. - - //if ( volDepth != 0 ) volDepth--; - //G4VPhysicalVolume *motherPhysical = touchHist->GetVolume(volDepth); - G4VPhysicalVolume *motherPhysical = touchHist->GetVolume(1); - - // G4String motherVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetMother()->GetName(); - G4String motherVolume=motherPhysical->GetName(); - - G4String material=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName(); - - // G4int copyN1=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetMother()->GetCopyNo(); - G4int copyN1=motherPhysical->GetCopyNo(); - - G4cout <<"+++++hitVolume="<<hitVolume<<" , his material="<<material<<", copyNumber="<<copyN<<", motherVolume="<<motherVolume <<", copy1="<< copyN1<< G4endl; - -#endif - - if(g_type != kDead) { // Calculate the active and inactive ID - // Sampling Identifier - if (absZ<samplingEndZ[0]) sampling = 0; - else if ((absZ>samplingStartZ[1]) && (absZ<samplingEndZ[1])) sampling = 1; - else if ((absZ>samplingStartZ[2]) && (absZ<samplingEndZ[2])) sampling = 2; - else if ((absZ>samplingStartZ[3]) && (absZ<samplingEndZ[3])) sampling = 3; - else { // Something wrong, it is a dead hit ? - // sampling = -1; - return CalculateIdentifier(a_step, kDead); - } - - // Region Identifier - if (eta<2.5) region = 0; - else region = 1; - - // Check if not in crack between modules - G4double alph = atan(pointShift.y()/pointShift.x()); - G4double dalpha = alph - int(alph/moduleDeltaPhi + copysign(0.5,alph))*moduleDeltaPhi; - G4double distance = sqrt(pointShift.x()*pointShift.x()+pointShift.y()*pointShift.y())*sin(dalpha); - if(fabs(distance) < deadZone) { - return CalculateIdentifier(a_step, kDead); - } - - // Sector Identifier and Phi_sector Identifier will be replaced - // by Phi Identifier - // Sector Identifier - sector = G4int(phi/moduleDeltaPhi); // phi/11.25*deg; - - // Phi_sector Identifier - phiSector=0; - if ( region == 0 ) { - if ((phi-float(sector)*moduleDeltaPhi) > (moduleDeltaPhi/2.)) phiSector=1; - } - - // Sector Identifier and Phi_sector Identifier will be replaced - // by Phi Identifier - if ( region == 1 ) phiBin=sector; - else phiBin=2*sector+phiSector; - - - // eta_Bin Identifier - etaBin = -1; - if ( region == 0 ) { - etaBin = G4int((eta-1.5)/0.1); - } else { - etaBin = G4int((eta-2.5)/0.2); - if ((sampling == 2) && (etaBin >2)) etaBin = 2; - } - -#ifdef DEBUG_HEC - std::cout<<"+++++ Active:"<<std::endl; - std::cout <<"zSide = "<<zSide<<" , sector = "<<sector<< - " , sampling = "<<sampling<<" , region="<<region << - " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; -#endif - - result << 4 // LArCalorimeter - << 2 // LArHEC - << zSide - << sampling - << region - << etaBin - << phiBin; - - } else { // Calculate dead ID - - G4int type = 0; - G4int subdet; - - if ( pointZshift < 0. ) subdet = -4; else subdet = 4; - - phiBin = G4int(phi/moduleDeltaPhi); - double r = sqrt(pointShift.x()*pointShift.x()+pointShift.y()*pointShift.y()); - if(absZ<samplingEndZ[0]) sampling = 0; - else if(absZ<samplingEndZ[1]) sampling = 1; - else if(absZ<samplingEndZ[2]) sampling = 2; - else sampling = 3; - - - if (absZ<samplingStartZ[0]+firstAbsorber[0]) { // in front of HEC - type = 1; - sampling = 2; - region = 3; - etaBin = G4int((eta-1.5)/0.1); - } else if((absZ < samplingEndZ[0] && r < moduleRinner1) || - (absZ < samplingEndZ[3] && r < moduleRinner2) ) { // HEC-FCAL crack - region = 4; - etaBin = 0; - } else if ( - ((absZ>samplingStartZ[0]+firstAbsorber[0]) && (absZ<samplingEndZ[1])) || - ((absZ>samplingStartZ[2]+firstAbsorber[3]) && (absZ<samplingEndZ[3])) - ) { // intermodule cracks - G4double alph = atan(pointShift.y()/pointShift.x()); - G4double dalpha = alph - int(alph/moduleDeltaPhi + copysign(0.5,alph))*moduleDeltaPhi; - G4double distance = sqrt(pointShift.x()*pointShift.x()+pointShift.y()*pointShift.y())*sin(dalpha); - if(fabs(distance) < deadZone) { - type = 2; - if (eta<2.5) { - region = 2; - etaBin = G4int((eta-1.5)/0.1); - } else { - region = 3; - etaBin = G4int((eta-2.5)/0.2); - } - } else { // something wrong - where it comes from? - default calculator hit - type = 1; - region = sampling = 0; - etaBin = G4int((eta-1.5)/0.1); - } - } else if ((absZ>samplingEndZ[1]) && (absZ<samplingStartZ[2]+firstAbsorber[3])) { // interwheel crack - type = 1; - region = 4; - sampling = 2; - etaBin = G4int((eta-1.5)/0.1); - } else { // HEC-Ext.B crack - type = 1; - if(eta < 1.7) { - sampling = 2; - region = 5; - etaBin = G4int((eta-1.0)/0.1); - } else { // Back of the HEC - sampling = 3; - region = 0; - etaBin = G4int((eta-1.7)/0.1); - } - } - -#ifdef DEBUG_HEC - std::cout<<"+++++ Dead:"<<std::endl; - G4cout <<"subdet = "<<subdet<<" , type = "<<type<< - " , sampling = "<<sampling<<" , region="<<region << - " , phi="<<phiBin<< " , etaBin="<<etaBin <<G4endl; -#endif - - result << 10 // Calorimeter - << subdet // +-4 - LAr dead material - << type - << sampling - << region - << etaBin - << phiBin; - - } - - return result; - } - - } // namespace HEC - -} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/HECGeometry.cc b/LArCalorimeter/LArG4/LArG4HEC/src/HECGeometry.cc old mode 100755 new mode 100644 index a58e71443128..05470c23749c --- a/LArCalorimeter/LArG4/LArG4HEC/src/HECGeometry.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/HECGeometry.cc @@ -17,7 +17,7 @@ #include "LArReadoutGeometry/HECLongBlock.h" #include "LArReadoutGeometry/HECDetectorManager.h" #include "LArReadoutGeometry/HECDetectorRegion.h" - + #include "RDBAccessSvc/IRDBAccessSvc.h" #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" @@ -26,12 +26,20 @@ #include "StoreGate/StoreGateSvc.h" #include "StoreGate/StoreGate.h" #include "AthenaKernel/getMessageSvc.h" +#include "AthenaKernel/Units.h" #include "globals.hh" #include <string> #include <cmath> #include <stdexcept> +#include "G4PhysicalVolumeStore.hh" +#include "G4VPhysicalVolume.hh" +#include "G4TransportationManager.hh" + +namespace Units = Athena::Units; + + #undef DEBUG_HEC #undef DEBUG_HEC_OLD_DIAGNOSTIC @@ -48,177 +56,191 @@ namespace LArG4 { namespace HEC { -bool HECGeometry::m_depthHist = false; -bool HECGeometry::m_withMother = false; -bool HECGeometry::m_inMother = false; -int HECGeometry::m_g4historyDepth = 0; -double HECGeometry::depthSize[7]; -double HECGeometry::depthSum[7]; -double HECGeometry::minval[7][2][10]; -double HECGeometry::maxval[7][2][10]; -double HECGeometry::firstAbsThickness[2]; -double HECGeometry::wheel1; -double HECGeometry::wheel2; -double HECGeometry::betweenWheels; -double HECGeometry::hecLength; -double HECGeometry::startHec2; -double HECGeometry::rOuter; -double HECGeometry::rInner1; -double HECGeometry::rInner2; - - -HECGeometry* HECGeometry::m_instance = 0; - - -HECGeometry* HECGeometry::GetInstance() -{ - if (m_instance == 0) m_instance = new HECGeometry(); - return m_instance; -} - - - HECGeometry::HECGeometry() { - - - MsgStream log(Athena::getMessageSvc(),"LArG4HEC::HECGeometry" ); - log << MSG::DEBUG << "HECGeometry - Constructor" << endreq; - - hecManager=NULL; - - if (!hecManager){ - StoreGateSvc* detStore = StoreGate::pointer("DetectorStore"); - if (detStore->retrieve(hecManager)!=StatusCode::SUCCESS){ - throw std::runtime_error("HEC::HECGeometry Can't find HECDetectorManager!"); + HECGeometry::HECGeometry(const std::string& name, ISvcLocator * pSvcLocator) + : AthService(name, pSvcLocator) + , m_hecManager(nullptr) + , m_depthHist(false) + , m_withMother(false) + , m_g4historyDepth(0) + { + } - } + //============================================================================================ - // This is VERY clumsy, but at the moment the only way to get the eta boundaries - // for a given block from the ReadoutGeometry and at the same time have the - // eta identifier ready for any given depth. + StatusCode HECGeometry::initialize() + { - for (int iblock=0; iblock<7; iblock++) { - depthSum[iblock] = 0.; - depthSize[iblock] = 0.; - for (int ireg=0; ireg<2; ireg++) { - for (int etaseg=0; etaseg<10; etaseg++) { - minval[iblock][ireg][etaseg] = 0.; - maxval[iblock][ireg][etaseg] = 0.; + if (!m_hecManager) + { + StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); + ATH_CHECK(detStore->retrieve(m_hecManager)); + } + // This is VERY clumsy, but at the moment the only way to get the eta boundaries + // for a given block from the ReadoutGeometry and at the same time have the + // eta identifier ready for any given depth. + + for (int iblock=0; iblock<7; iblock++) { + m_depthSum[iblock] = 0.; + m_depthSize[iblock] = 0.; + for (int ireg=0; ireg<2; ireg++) { + for (int etaseg=0; etaseg<10; etaseg++) { + m_minval[iblock][ireg][etaseg] = 0.; + m_maxval[iblock][ireg][etaseg] = 0.; + } + } } - } - } - double depthsum_tally = 0.; - for (int depthIndex=0; depthIndex<7; depthIndex++) - { - depthSize[depthIndex] = hecManager->getBlock(depthIndex)->getDepth(); - depthsum_tally += depthSize[depthIndex]; - if (depthIndex==3) depthsum_tally += 40.5; // YIKES! hard-coded number...! - depthSum[depthIndex] = depthsum_tally ; - - const HECLongBlock *block = hecManager->getBlock(depthIndex); - - int isegInner = 0; - int isegOuter = block->getNumRadialSegments(); - int numBlk = block->getBlockNumber(); - - int nInReg = 4; - if (numBlk>1 && numBlk<6) { isegInner = 1; nInReg=3; } - if (numBlk>6)isegOuter=11; - else if (numBlk>4)isegOuter=12; - else if (numBlk>2)isegOuter=13; - - int ieta = nInReg; - int iregion = 1; - - for (int iseg=isegInner; iseg<isegOuter; iseg++) - { - ieta--; - if (ieta < 0) { iregion=0; ieta=9; } - - const HECRadialSegment *hecRad = block->getRadialSegment(iseg); - minval[depthIndex][iregion][ieta]= hecRad->getMinVal(); - maxval[depthIndex][iregion][ieta]= hecRad->getMaxVal(); - // This is a most terrible hack to correct numbers in the database...: - double rInner = hecManager->getBlock(depthIndex)->getInnerRadius(); - double rOuter = hecManager->getBlock(depthIndex)->getOuterRadius(); - if (hecRad->getMaxVal()==2027.) maxval[depthIndex][iregion][ieta]=rOuter; - if (hecRad->getMinVal()==375. && depthIndex==0) minval[depthIndex][iregion][ieta]=rInner; - else if (hecRad->getMinVal()==478 && depthIndex>0) minval[depthIndex][iregion][ieta]=rInner; - } + double depthsum_tally = 0.; + for (int depthIndex=0; depthIndex<7; depthIndex++) + { + m_depthSize[depthIndex] = m_hecManager->getBlock(depthIndex)->getDepth(); + depthsum_tally += m_depthSize[depthIndex]; + if (depthIndex==3) depthsum_tally += 40.5; // FIXME YIKES! hard-coded number...! + m_depthSum[depthIndex] = depthsum_tally ; + + const HECLongBlock *block = m_hecManager->getBlock(depthIndex); + + int isegInner = 0; + int isegOuter = block->getNumRadialSegments(); + int numBlk = block->getBlockNumber(); + + int nInReg = 4; + if (numBlk>1 && numBlk<6) { isegInner = 1; nInReg=3; } + if (numBlk>6)isegOuter=11; + else if (numBlk>4)isegOuter=12; + else if (numBlk>2)isegOuter=13; + + int ieta = nInReg; + int iregion = 1; + + for (int iseg=isegInner; iseg<isegOuter; iseg++) + { + ieta--; + if (ieta < 0) { iregion=0; ieta=9; } + + const HECRadialSegment *hecRad = block->getRadialSegment(iseg); + m_minval[depthIndex][iregion][ieta]= hecRad->getMinVal(); + m_maxval[depthIndex][iregion][ieta]= hecRad->getMaxVal(); + // This is a most terrible hack to correct numbers in the database...: + double rInner = m_hecManager->getBlock(depthIndex)->getInnerRadius(); + double rOuter = m_hecManager->getBlock(depthIndex)->getOuterRadius(); + if (hecRad->getMaxVal()==2027.) m_maxval[depthIndex][iregion][ieta]=rOuter; + if (hecRad->getMinVal()==375. && depthIndex==0) m_minval[depthIndex][iregion][ieta]=rInner; + else if (hecRad->getMinVal()==478 && depthIndex>0) m_minval[depthIndex][iregion][ieta]=rInner; + } + } + + + // And some essential numbers we'll need over and over again: + m_firstAbsThickness[0] = m_hecManager->getBlock(0)->getFrontPlateThickness() ; + m_firstAbsThickness[1] = m_hecManager->getBlock(3)->getFrontPlateThickness() ; + m_wheel1 = m_depthSize[0]+m_depthSize[1]+m_depthSize[2]; // 816.5; + m_wheel2 = m_depthSize[3]+m_depthSize[4]+m_depthSize[5]+m_depthSize[6]; // 961.0; + m_betweenWheels = 40.5; // FIXME HACK!! -- can't find this through LArReadoutGeometry... + m_startHec2 = m_wheel1 + m_betweenWheels + m_firstAbsThickness[1]; + m_hecLength = m_wheel1 + m_betweenWheels + m_wheel2; + m_rOuter = m_hecManager->getBlock(0)->getOuterRadius(); + m_rInner1 = m_hecManager->getBlock(0)->getInnerRadius(); + m_rInner2 = m_hecManager->getBlock(1)->getInnerRadius(); + + if (!m_depthHist) + { + const G4LogicalVolume * logicalWorld = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()->GetLogicalVolume(); + const G4VPhysicalVolume *thePhysicalVolume = G4PhysicalVolumeStore::GetInstance()->GetVolume("LArMgr::LAr::HEC::Mother",false); + int level=0; + if(this->checkDaughters(logicalWorld, thePhysicalVolume,level)) + { + m_g4historyDepth=level+1; + m_depthHist=true; + m_withMother=true; + ATH_MSG_INFO(" G4Depth of HEC::LiquidArgon " << m_g4historyDepth + << " The HEC Wheel is embedded in a HEC Mother"); + } + else + { + const G4VPhysicalVolume *thePhysicalVolume2 = G4PhysicalVolumeStore::GetInstance()->GetVolume("LArMgr::LAr::HEC::LiquidArgon",false); + int level2=0; + if(this->checkDaughters(logicalWorld, thePhysicalVolume2,level2)) + { + m_g4historyDepth=level2; + m_depthHist=true; + ATH_MSG_INFO(" G4Depth of HEC::LiquidArgon " << m_g4historyDepth); + m_withMother=false; + ATH_MSG_INFO("The HEC Wheel is independent (no Mother)"); + } + else + { + ATH_MSG_ERROR("Failed to find LArMgr::LAr::HEC::LiquidArgon!!"); + return StatusCode::FAILURE; + } + } + } + + return StatusCode::SUCCESS; } + //============================================================================================ - // And some essential numbers we'll need over and over again: - firstAbsThickness[0] = hecManager->getBlock(0)->getFrontPlateThickness() ; - firstAbsThickness[1] = hecManager->getBlock(3)->getFrontPlateThickness() ; - wheel1 = depthSize[0]+depthSize[1]+depthSize[2]; // 816.5; - wheel2 = depthSize[3]+depthSize[4]+depthSize[5]+depthSize[6]; // 961.0; - betweenWheels = 40.5; // HACK!! -- can't find this through LArReadoutGeometry... - startHec2 = wheel1 + betweenWheels + firstAbsThickness[1]; - hecLength = wheel1 + betweenWheels + wheel2; - rOuter = hecManager->getBlock(0)->getOuterRadius(); - rInner1 = hecManager->getBlock(0)->getInnerRadius(); - rInner2 = hecManager->getBlock(1)->getInnerRadius(); + StatusCode HECGeometry::queryInterface( const InterfaceID & riid, void** ppvInterface ) + { + if ( IHECGeometry::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<IHECGeometry*>(this); + } else { + // Interface is not directly available : try out a base class + return AthService::queryInterface(riid, ppvInterface); + } + addRef(); + return StatusCode::SUCCESS; + } -} + //============================================================================================ + bool HECGeometry::checkDaughters(const G4LogicalVolume *possibleParent, const G4VPhysicalVolume *thePhysicalVolume, int& level) const + { + if (possibleParent->IsDaughter(thePhysicalVolume)) + { + ++level; + return true; + } + // Otherwise Loop over the daughters + const G4int nDaughters(possibleParent->GetNoDaughters()); + for(G4int daughter(0); daughter<nDaughters; ++daughter) + { + const G4VPhysicalVolume* daughterPhysVol = possibleParent->GetDaughter(daughter); + const G4LogicalVolume* daughterLogVol = daughterPhysVol->GetLogicalVolume(); + if (this->checkDaughters(daughterLogVol, thePhysicalVolume,level)) + { + ++level; + return true; + } + } + return false; + } -//============================================================================================ + //============================================================================================ - LArG4Identifier HECGeometry::CalculateIdentifier(const G4Step* a_step, - const eHECGeometryType g_type, - int *subgap) + LArG4Identifier HECGeometry::CalculateIdentifier(const G4Step* a_step, + const eHECGeometryType g_type, + int *subgap) const { - - if (!hecManager){ - StoreGateSvc* detStore = StoreGate::pointer("DetectorStore"); - if (detStore->retrieve(hecManager)!=StatusCode::SUCCESS){ - throw std::runtime_error("HEC::HECGeometry Can't find HECDetectorManager!"); - } - } - if (!hecManager){ - throw std::runtime_error("HEC::HECGeometry Can't find HECDetectorManager!"); + if (!m_hecManager){ + throw std::runtime_error("HEC::HECGeometry Can't find HECDetectorManager!"); } - + // Get the pre-step point; Get global (atlas) and local (HEC mother) Positions G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - Point3D<double> globalPosition = pre_step_point->GetPosition(); + Point3D<double> globalPosition = pre_step_point->GetPosition(); G4TouchableHistory* theTouchable = (G4TouchableHistory*) (pre_step_point->GetTouchable()); G4String volumeName = theTouchable->GetVolume()->GetName() ; - // Do the following only once - to determine the G4 history-depth of the wheel coordinates + // Do the following only once - to determine the G4 history-depth of the wheel coordinates // We also want to know whether the Wheels are imbedded in a HEC Mother or whether // the Front and Rear Wheels have been placed (independently) directly into the - // Cryostat Liquid Argon - - int g4Depth = theTouchable->GetHistoryDepth(); - if (!m_depthHist) - { - MsgStream log(Athena::getMessageSvc(),"LArG4HEC::HECGeometry" ); - log << MSG::INFO << " This should be done once only: " ; - for (int myVol=g4Depth; myVol>0; myVol--) - { - if ((theTouchable->GetHistory()->GetVolume(myVol)->GetName())== "LArMgr::LAr::HEC::LiquidArgon") - { m_g4historyDepth=myVol; - m_depthHist=true; - log << MSG::INFO << " G4Depth of HEC::LiquidArgon " << m_g4historyDepth << endreq; - if ((theTouchable->GetHistory()->GetVolume(m_g4historyDepth-1)->GetName())== "LArMgr::LAr::HEC::Mother") - {m_withMother=true; log << MSG::INFO << "The HEC Wheel is embedded in a HEC Mother" << endreq; } - else {m_withMother=false; log << MSG::INFO << "The HEC Wheel is independent (no Mother)" << endreq; } - break;} - else if ((theTouchable->GetHistory()->GetVolume(myVol)->GetName())== "LArMgr::LAr::HEC::Mother") - { m_g4historyDepth=myVol+1; - m_depthHist=true; - m_withMother=true; - log << MSG::INFO << " G4Depth of HEC::LiquidArgon " << m_g4historyDepth - << " The HEC Wheel is embedded in a HEC Mother" << endreq; - break;} - } - } + // Cryostat Liquid Argon // Now we know that no matter how the HEC is nested (ie with or without overall Mother); // m_g4historyDepth is the G4 history depth of the HEC Wheel coordinates (ie: LAr::HEC::LiquidArgon) @@ -226,335 +248,334 @@ HECGeometry* HECGeometry::GetInstance() // Next we need to be able to handle things regardless whether the Wheels are // imbedded in a HEC Mother or whether they are placed independently into the cryostat: - m_inMother = false; - if (volumeName == "LArMgr::LAr::HEC::Mother") m_inMother = true; + bool inMother = false; + if (volumeName == "LArMgr::LAr::HEC::Mother") inMother = true; // This will give us the hit-position in the Wheel coordinates (ie in LAr::HEC::LiquidArgon): // But we have to be careful: We COULD be in a mother, in which case the wheel coord. is meaningless. G4AffineTransform wheelTransform; G4ThreeVector wheelPosition ; - if (!m_inMother){ - wheelTransform = pre_step_point->GetTouchable()->GetHistory()->GetTransform(m_g4historyDepth); - wheelPosition = wheelTransform.TransformPoint(pre_step_point->GetPosition()); + if (!inMother){ + wheelTransform = pre_step_point->GetTouchable()->GetHistory()->GetTransform(m_g4historyDepth); + wheelPosition = wheelTransform.TransformPoint(pre_step_point->GetPosition()); } // In case there IS a mother and the hit is actually IN this mother, we need those coordinates as well: G4AffineTransform motherTransform; G4ThreeVector motherPosition ; - if (m_inMother){ - motherTransform = pre_step_point->GetTouchable()->GetHistory()->GetTransform(m_g4historyDepth-1); - motherPosition = motherTransform.TransformPoint(pre_step_point->GetPosition()); + if (inMother){ + motherTransform = pre_step_point->GetTouchable()->GetHistory()->GetTransform(m_g4historyDepth-1); + motherPosition = motherTransform.TransformPoint(pre_step_point->GetPosition()); } - + // z-side sign int zSide = globalPosition.z()<0. ? -1:1; // ------- ACTIVE and INACTIVE volumes ----------------------- - // (They are all inside a Depth (and some DM, too)) + // (They are all inside a Depth (and some DM, too)) if ( volumeName.contains("LArMgr::LAr::HEC::Module::Depth") ) - - { - - int modVol = m_g4historyDepth+1 ; // geant depth of the HEC::Module - int depthVol= m_g4historyDepth+2 ; // geant depth of the HEC::Module::Depth - - int depthIndex = theTouchable->GetHistory()->GetVolume(depthVol)->GetCopyNo(); - int moduleIndex = theTouchable->GetHistory()->GetVolume(modVol)->GetCopyNo(); - - const G4AffineTransform moduleTransform= theTouchable->GetHistory()->GetTransform(modVol); - - G4ThreeVector modulePosition = moduleTransform.TransformPoint(pre_step_point->GetPosition()); - double moduleY = (sqrt)(modulePosition.y()/CLHEP::mm*modulePosition.y()/CLHEP::mm) ; - - if (subgap) { - - int sliceVol= m_g4historyDepth+3 ; // geant depth of the slice - //int sliceIndex = theTouchable->GetHistory()->GetVolume(sliceVol)->GetCopyNo(); - - const G4AffineTransform sliceTransform=theTouchable->GetHistory()->GetTransform(sliceVol); - G4ThreeVector slicePosition = sliceTransform.TransformPoint(pre_step_point->GetPosition()); - G4VSolid *sliceSolid = theTouchable->GetHistory()->GetVolume(sliceVol)->GetLogicalVolume()->GetSolid(); - double sliceZ = slicePosition.z()/CLHEP::mm ; - - G4Tubs *tubs = dynamic_cast<G4Tubs *> (sliceSolid); - if (tubs) { - double dz = tubs->GetDz()/CLHEP::mm; - if (sliceZ > 0) { - if (fabs(sliceZ)>dz/2.0) { - (*subgap) = 0; - } - else { - dz=1; - (*subgap) = 1; - } - } - else { - if (fabs(sliceZ)>dz/2.0) { - (*subgap) = 3; - dz=3; - } - else { - (*subgap) = 2; - } - } - } - } - - - - // Get: sampling, region, eta and phi: - - //--- SAMPLING --- - // initialize value to something invalid, so we won't accidentally mis-assign something: - int sampling=-1; - sampling = (depthIndex==0 ? 0 : (depthIndex<3 ? 1 : (depthIndex<5 ? 2 : 3))); - - - //---REGION, ETA --- - int ieta = -1; - int iregion = ( moduleY>= maxval[depthIndex][1][0] ) ? 0 : 1 ; - for (int ie=0; ie<10; ie++) { - if ( moduleY > minval[depthIndex][iregion][ie] && - moduleY<= maxval[depthIndex][iregion][ie] ) - { - ieta = ie; - break; - } - } - - - // Take care of very outside eta identifiers of hits that can - // sometimes be a wee bit outside the boundaries - if (ieta<0){ - int ietaMin[7] = {3,2,2,2,2,3,3}; - int ietaMax[7] = {0,0,1,1,2,2,3}; - if (moduleY>=rOuter) ieta = ietaMax[depthIndex]; - else if ((depthIndex==0 && moduleY<rInner1 ) || - (depthIndex>0 && moduleY<rInner2 )) ieta = ietaMin[depthIndex]; - } - - - - //--- PHI --- - int iphi=-1; - if(iregion == 1) iphi = moduleIndex; - else - { - iphi = 2*moduleIndex; - if(zSide * modulePosition.x() > 0) iphi++; - } - - - //--- Assign identifier according the the volumes we are in: - - if ( g_type==kWheelActive || g_type==kWheelInactive ) - { - LArG4Identifier result = LArG4Identifier(); - - result << 4 // LAr - << 2 // HEC - << 2*zSide // z-side - << sampling // sampling - << iregion // region - << ieta // ieta - << iphi ; // iphi - - return result; - } - - else // (has to be dead) - { - int itype = 2; - if ( volumeName.contains("LArMgr::LAr::HEC::Module::Depth::FirstAbsorber") ) { - itype = 1; - sampling = 2; - iphi = moduleIndex; - if(iregion==1) { - ieta += 10; - } - iphi = 2*moduleIndex; - if(zSide * modulePosition.x() > 0) iphi++; - if(ieta<0) ieta = 0; - if(ieta>17) ieta = 17; - if(depthIndex < 3) iregion = 3; else iregion = 4; - } else { - if(iregion==0) { - iregion=2; iphi /= 2; - } else { iregion=3; }// diference in regions and phi for DM - } + + { + + int modVol = m_g4historyDepth+1 ; // geant depth of the HEC::Module + int depthVol= m_g4historyDepth+2 ; // geant depth of the HEC::Module::Depth + + int depthIndex = theTouchable->GetHistory()->GetVolume(depthVol)->GetCopyNo(); + int moduleIndex = theTouchable->GetHistory()->GetVolume(modVol)->GetCopyNo(); + + const G4AffineTransform moduleTransform= theTouchable->GetHistory()->GetTransform(modVol); + + G4ThreeVector modulePosition = moduleTransform.TransformPoint(pre_step_point->GetPosition()); + double moduleY = (sqrt)(modulePosition.y()/Units::mm*modulePosition.y()/Units::mm) ; + + if (subgap) { + + int sliceVol= m_g4historyDepth+3 ; // geant depth of the slice + //int sliceIndex = theTouchable->GetHistory()->GetVolume(sliceVol)->GetCopyNo(); + + const G4AffineTransform sliceTransform=theTouchable->GetHistory()->GetTransform(sliceVol); + G4ThreeVector slicePosition = sliceTransform.TransformPoint(pre_step_point->GetPosition()); + G4VSolid *sliceSolid = theTouchable->GetHistory()->GetVolume(sliceVol)->GetLogicalVolume()->GetSolid(); + double sliceZ = slicePosition.z()/Units::mm ; + + G4Tubs *tubs = dynamic_cast<G4Tubs *> (sliceSolid); + if (tubs) { + double dz = tubs->GetDz()/Units::mm; + if (sliceZ > 0) { + if (fabs(sliceZ)>dz/2.0) { + (*subgap) = 0; + } + else { + dz=1; + (*subgap) = 1; + } + } + else { + if (fabs(sliceZ)>dz/2.0) { + (*subgap) = 3; + dz=3; + } + else { + (*subgap) = 2; + } + } + } + } + + + + // Get: sampling, region, eta and phi: + + //--- SAMPLING --- + // initialize value to something invalid, so we won't accidentally mis-assign something: + int sampling=-1; + sampling = (depthIndex==0 ? 0 : (depthIndex<3 ? 1 : (depthIndex<5 ? 2 : 3))); + + + //---REGION, ETA --- + int ieta = -1; + int iregion = ( moduleY>= m_maxval[depthIndex][1][0] ) ? 0 : 1 ; + for (int ie=0; ie<10; ie++) { + if ( moduleY > m_minval[depthIndex][iregion][ie] && + moduleY<= m_maxval[depthIndex][iregion][ie] ) + { + ieta = ie; + break; + } + } + + + // Take care of very outside eta identifiers of hits that can + // sometimes be a wee bit outside the boundaries + if (ieta<0){ + int ietaMin[7] = {3,2,2,2,2,3,3}; + int ietaMax[7] = {0,0,1,1,2,2,3}; + if (moduleY>=m_rOuter) ieta = ietaMax[depthIndex]; + else if ((depthIndex==0 && moduleY<m_rInner1 ) || + (depthIndex>0 && moduleY<m_rInner2 )) ieta = ietaMin[depthIndex]; + } + + + + //--- PHI --- + int iphi=-1; + if(iregion == 1) iphi = moduleIndex; + else + { + iphi = 2*moduleIndex; + if(zSide * modulePosition.x() > 0) iphi++; + } + + + //--- Assign identifier according the the volumes we are in: + + if ( g_type==kWheelActive || g_type==kWheelInactive ) + { + LArG4Identifier result = LArG4Identifier(); + + result << 4 // LAr + << 2 // HEC + << 2*zSide // z-side + << sampling // sampling + << iregion // region + << ieta // ieta + << iphi ; // iphi + + return result; + } + + else // (has to be dead) + { + int itype = 2; + if ( volumeName.contains("LArMgr::LAr::HEC::Module::Depth::FirstAbsorber") ) { + itype = 1; + sampling = 2; + iphi = moduleIndex; + if(iregion==1) { + ieta += 10; + } + iphi = 2*moduleIndex; + if(zSide * modulePosition.x() > 0) iphi++; + if(ieta<0) ieta = 0; + if(ieta>17) ieta = 17; + if(depthIndex < 3) iregion = 3; else iregion = 4; + } else { + if(iregion==0) { + iregion=2; iphi /= 2; + } else { iregion=3; }// diference in regions and phi for DM + } #ifdef DEBUG_DEAD - std::cout<<"Dead phi: "<<globalPosition.getPhi() <<" index: " - <<iphi<<" eta: "<<globalPosition.getEta() <<" ieta: " - <<ieta<<" itype: "<<itype<<" iregion: "<<iregion<<std::endl; - std::cout<<"Name: "<<volumeName<<std::endl; + std::cout<<"Dead phi: "<<globalPosition.getPhi() <<" index: " + <<iphi<<" eta: "<<globalPosition.getEta() <<" ieta: " + <<ieta<<" itype: "<<itype<<" iregion: "<<iregion<<std::endl; + std::cout<<"Name: "<<volumeName<<std::endl; #endif - LArG4Identifier result = LArG4Identifier(); - result << 10 // Calo - << 4*zSide // LAr - << itype // DM type - << sampling // sampling - << iregion // region - << ieta // ieta - << iphi ; // iphi - - return result; - } - - } // End of if we are in a Depth - + LArG4Identifier result = LArG4Identifier(); + result << 10 // Calo + << 4*zSide // LAr + << itype // DM type + << sampling // sampling + << iregion // region + << ieta // ieta + << iphi ; // iphi + + return result; + } + + } // End of if we are in a Depth + //======================================================== //---------- All that's left are DEAD Volumes ------------------------------- else - { - - // If we are not in a Depth, we have to make use of either - // Wheel Coordinates (in case the Wheels are independent without a Mother) - // or Mother Coordinates (only in case there is a Mother and the hit is actually in it) - - - // For z, r and PHI , use either mother or wheel coordinates: - // For ETA: - // Get the ideal HEC eta for the inter-moduel crack: - // hecManager->getFocalToRef() = 4270 ...that's the start of the ideal HEC envelope - // (no database access to this: 4277 ...is the start of the actual ideal HEC - // in any case; this number is only used to get some ideal eta assignment. - // it is NOT geometry- or alignmnet-dependent! - double zed =0. ; - double radius =0. ; - double phi =0. ; - int hecCopy = -1; - double idealEta = -1.; - double idealZ = 0.; - - if (m_inMother) { - zed = motherPosition.z(); - radius = motherPosition.perp(); - phi = ( (zSide<0.) ? - ((motherPosition.getPhi() > 0.0) ? (M_PI-motherPosition.getPhi()) : (-M_PI-motherPosition.getPhi())) - : motherPosition.getPhi()); - idealZ = zed + 4277.; - idealEta = -log ( tan( atan(radius/idealZ) / 2.)); - } - else { - hecCopy= theTouchable->GetHistory()->GetVolume(m_g4historyDepth)->GetCopyNo(); - zed = wheelPosition.z(); - radius = wheelPosition.perp(); - phi = ( (zSide<0.) ? - ((wheelPosition.getPhi() > 0.0) ? (M_PI-wheelPosition.getPhi()) : (-M_PI-wheelPosition.getPhi())) - : wheelPosition.getPhi()); - // See whether we are in Front or Rear wheel: - zed = (hecCopy<1) ? (zed ) : (zed+wheel1+betweenWheels); - idealZ = zed + 4277.; - idealEta = -log ( tan( atan(radius/idealZ) / 2.)); - - } - - // --- PHI --- - // For phi need to consider opposite sense for the negative z-side (that's the same for mother/wheel): - phi = (phi<0) ? (phi+2.*M_PI) : phi; - int iphi = int(32*phi/(M_PI)); + { + + // If we are not in a Depth, we have to make use of either + // Wheel Coordinates (in case the Wheels are independent without a Mother) + // or Mother Coordinates (only in case there is a Mother and the hit is actually in it) + + + // For z, r and PHI , use either mother or wheel coordinates: + // For ETA: + // Get the ideal HEC eta for the inter-moduel crack: + // m_hecManager->getFocalToRef() = 4270 ...that's the start of the ideal HEC envelope + // (no database access to this: 4277 ...is the start of the actual ideal HEC + // in any case; this number is only used to get some ideal eta assignment. + // it is NOT geometry- or alignmnet-dependent! + double zed =0. ; + double radius =0. ; + double phi =0. ; + int hecCopy = -1; + double idealEta = -1.; + double idealZ = 0.; + + if (inMother) { + zed = motherPosition.z(); + radius = motherPosition.perp(); + phi = ( (zSide<0.) ? + ((motherPosition.getPhi() > 0.0) ? (M_PI-motherPosition.getPhi()) : (-M_PI-motherPosition.getPhi())) + : motherPosition.getPhi()); + idealZ = zed + 4277.; + idealEta = -log ( tan( atan(radius/idealZ) / 2.)); + } + else { + hecCopy= theTouchable->GetHistory()->GetVolume(m_g4historyDepth)->GetCopyNo(); + zed = wheelPosition.z(); + radius = wheelPosition.perp(); + phi = ( (zSide<0.) ? + ((wheelPosition.getPhi() > 0.0) ? (M_PI-wheelPosition.getPhi()) : (-M_PI-wheelPosition.getPhi())) + : wheelPosition.getPhi()); + // See whether we are in Front or Rear wheel: + zed = (hecCopy<1) ? (zed ) : (zed+m_wheel1+m_betweenWheels); + idealZ = zed + 4277.; + idealEta = -log ( tan( atan(radius/idealZ) / 2.)); + + } + + // --- PHI --- + // For phi need to consider opposite sense for the negative z-side (that's the same for mother/wheel): + phi = (phi<0) ? (phi+2.*M_PI) : phi; + int iphi = int(phi*(32/M_PI)); #ifdef DEBUG_DEAD - std::cout<<"Dead global phi: "<<globalPosition.getPhi() - <<" mother phi: " << motherPosition.getPhi() - <<" wheel phi: " << wheelPosition.getPhi() - <<" phi: "<<phi<<" index: "<<iphi<<std::endl; + std::cout<<"Dead global phi: "<<globalPosition.getPhi() + <<" mother phi: " << motherPosition.getPhi() + <<" wheel phi: " << wheelPosition.getPhi() + <<" phi: "<<phi<<" index: "<<iphi<<std::endl; #endif - - - //=========================================================================== - // Now we have to be careful again, because zed is diffrent, depending - // on if we are inside a mother or not! - int type = -1; - int sampling= -1; - int region = -1; + //=========================================================================== + + // Now we have to be careful again, because zed is diffrent, depending + // on if we are inside a mother or not! + + int type = -1; + int sampling= -1; + int region = -1; int ieta = -1; - // --- TYPE, SAMPLING, REGION --- + // --- TYPE, SAMPLING, REGION --- + - //--- outside or behind HEC: - if ( radius >= rOuter ) { - if(idealEta < 1.7) { - ieta = int((idealEta - 1.0)/0.1); - type=1 ; sampling=2; region=5; - } - else { - ieta = int((idealEta - 1.7)/0.1); - type=1 ; sampling=3; region=0; - } + if ( radius >= m_rOuter ) { + if(idealEta < 1.7) { + ieta = int((idealEta - 1.0)/0.1); + type=1 ; sampling=2; region=5; + } + else { + ieta = int((idealEta - 1.7)/0.1); + type=1 ; sampling=3; region=0; + } + } + //--- behind HEC: + else if ( zed >= m_hecLength ) { + ieta = int((idealEta - 1.7)/0.1); + type=1 ; sampling=3; region=0; } - //--- behind HEC: - else if ( zed >= hecLength ) { - ieta = int((idealEta - 1.7)/0.1); - type=1 ; sampling=3; region=0; - } //--- in front of HEC: - else if ( zed <= firstAbsThickness[0] && radius >rInner1 ) { - ieta = int((idealEta - 1.5)/0.1); - type=1 ; sampling=2; region=3; - } + else if ( zed <= m_firstAbsThickness[0] && radius >m_rInner1 ) { + ieta = int((idealEta - 1.5)/0.1); + type=1 ; sampling=2; region=3; + } //--- in bewteen the two HECs: - else if ( zed >= wheel1 && zed <=startHec2 && radius<rOuter && radius >rInner2 ) { - ieta = int((idealEta - 1.5)/0.1); - type=1 ; sampling=2; region=4; - } + else if ( zed >= m_wheel1 && zed <=m_startHec2 && radius<m_rOuter && radius >m_rInner2 ) { + ieta = int((idealEta - 1.5)/0.1); + type=1 ; sampling=2; region=4; + } //--- inside the HEC or between HEC and FCAL: - else - { - type=2; - - int iDepth =-1; - for (int depthIndex=0; depthIndex<7; depthIndex++) { - if (zed <= depthSum[depthIndex]) { iDepth = depthIndex; break; } - } + else + { + type=2; + + int iDepth =-1; + for (int depthIndex=0; depthIndex<7; depthIndex++) { + if (zed <= m_depthSum[depthIndex]) { iDepth = depthIndex; break; } + } if(iDepth < 0) { // this should not happen (previous tests on zed should guarantee, but to make Coverity happy - iDepth = 6; + iDepth = 6; } - // for inner HEC region or HEC/FCAL region: - sampling = (iDepth==0 ? 0 : (iDepth<3 ? 1 : (iDepth<5 ? 2 : 3))); - iphi = int(32*phi/(2.*M_PI)); - region = (( radius>= maxval[iDepth][1][0] ) ? 2 : 3 ); - if (region==3) ieta = int((idealEta-2.5)/0.2) ; - else ieta = int((idealEta-1.5)/0.2) ; - if (iDepth>0 && radius <= rInner2 ) { region = 4 ; ieta=0; iphi = int(32*phi/(M_PI));} // between HEC and FCAL - else if (iDepth==0 && radius <= rInner1 ) { region = 4 ; ieta=0; iphi = int(32*phi/(M_PI));} // between HEC and FCAL + // for inner HEC region or HEC/FCAL region: + sampling = (iDepth==0 ? 0 : (iDepth<3 ? 1 : (iDepth<5 ? 2 : 3))); + iphi = int(32*phi/(2.*M_PI)); + region = (( radius>= m_maxval[iDepth][1][0] ) ? 2 : 3 ); + if (region==3) ieta = int((idealEta-2.5)/0.2) ; + else ieta = int((idealEta-1.5)/0.2) ; + if (iDepth>0 && radius <= m_rInner2 ) { region = 4 ; ieta=0; iphi = int(phi*(32/M_PI));} // between HEC and FCAL + else if (iDepth==0 && radius <= m_rInner1 ) { region = 4 ; ieta=0; iphi = int(phi*(32/M_PI));} // between HEC and FCAL + + } - } - - if(ieta<0) ieta = 0; // stupid hack, until we solve everything + if(ieta<0) ieta = 0; // FIXME stupid hack, until we solve everything if(iphi>63) iphi = 63; - - LArG4Identifier result = LArG4Identifier(); - result << 10 // Calo - << 4*zSide // LAr - << type // type - << sampling // sampling - << region // region - << ieta // ieta - << iphi ; // iphi - - return result; - - } - + + LArG4Identifier result = LArG4Identifier(); + result << 10 // Calo + << 4*zSide // LAr + << type // type + << sampling // sampling + << region // region + << ieta // ieta + << iphi ; // iphi + + return result; + + } + } // end calculateIdentifier } // namespace HEC } // namespace LArG4 - diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalculator.cc deleted file mode 100755 index cc399d571c09..000000000000 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalculator.cc +++ /dev/null @@ -1,146 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// LArHECCalculator -// Revision history: - -// 31-May-2002 : Karapetian Gaiane - -// 13-Jan-2004 WGS: Now uses LArG4::HEC::Geometry for the Identifier calculations. - -#undef DEBUG_HITS - -#include "LArG4HEC/LArHECCalculator.h" -#include "LArG4HEC/Geometry.h" - -#include "LArG4Code/LArG4Identifier.h" - -#include "G4ThreeVector.hh" -#include "G4StepPoint.hh" -#include "G4Step.hh" - -#include "RDBAccessSvc/IRDBAccessSvc.h" -#include "RDBAccessSvc/IRDBRecord.h" -#include "RDBAccessSvc/IRDBRecordset.h" -#include "GeoModelInterfaces/IGeoModelSvc.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" -// Standard implementation of a singleton pattern. - -LArHECCalculator* LArHECCalculator::m_instance = 0; - -LArHECCalculator* LArHECCalculator::GetCalculator() -{ - if (m_instance == 0) - { - m_instance = new LArHECCalculator(); - } - return m_instance; -} - - -LArHECCalculator::LArHECCalculator() -{ - - - StatusCode status; - // Access the GeoModelSvc: - ISvcLocator *svcLocator = Gaudi::svcLocator(); - IGeoModelSvc *geoModel; - status = svcLocator->service ("GeoModelSvc",geoModel); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); - } - - // Access the geometry database: - IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); - } - - // Obtain the geometry version information: - - std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); - - std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; - std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; - - - IRDBRecordset *emecGeometry = const_cast<IRDBRecordset*> (pAccessSvc->getRecordset("EmecGeometry",detectorKey, detectorNode)); - if (emecGeometry->size()==0) { - throw std::runtime_error("Cannot find the EmecGeometry Table"); - } - - // Constructor initializes the geometry. - - // Make sure we don't have any undefined values. - //m_identifier = LArG4Identifier(); - //m_time = 0.; - //m_energy = 0.; - m_isInTime = false; - - // Initialize the geometry calculator. - m_geometry = LArG4::HEC::Geometry::GetInstance(); - - // By default, assume no charge-collection. - m_chargeCollection = false; - - // Get the endcap shift and out-of-time cut from the detector - // description routine. - //get the endcap shift - m_zShift = (*emecGeometry)[0]->getDouble("ZSHIFT")*CLHEP::cm; - m_OOTcut = 2.5*CLHEP::ns; -} - -G4bool LArHECCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) -{ - // Given a G4Step, find the sampling, region, eta bin, and phi bin - // in the LAr HEC associated with that point. - - // Note that we don't do any range checking; it is assumed that p - // lies within the LAr endcap. But we do have debug checks via asserts. - - // 29-Mar-2002 WGS: this method now returns a boolean. If it's - // true, the hit is valid; if it's false, there was some problem - // with the hit and it should be ignored. - - // Make sure that vector is cleared - hdata.clear(); - // First, get the energy. - hdata[0].energy = a_step->GetTotalEnergyDeposit(); - - // Find out how long it took the energy to get here. - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); - G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4double timeOfFlight = (pre_step_point->GetGlobalTime() + - post_step_point->GetGlobalTime()) * 0.5; - G4ThreeVector startPoint = pre_step_point->GetPosition(); - G4ThreeVector endPoint = post_step_point->GetPosition(); - G4ThreeVector p = (startPoint + endPoint) * 0.5; - - hdata[0].time = timeOfFlight/CLHEP::ns - p.mag()/CLHEP::c_light/CLHEP::ns; - if (hdata[0].time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; - - // Calculate the identifier. - hdata[0].id = m_geometry->CalculateIdentifier( a_step ); - -#ifdef DEBUG_HITS - std::cout << "LArHECCalculator::Process " - << " ID=" << std::string(m_identifier) - << " energy=" << m_energy - << std::endl; -#endif - - // Check for any problems. - if ( hdata[0].id == LArG4Identifier() ) - return false; - - return true; -} diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.cc old mode 100755 new mode 100644 index 7fb593aa14d7..8a3a014d7904 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.cc @@ -2,12 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4HEC/LArHECCalibrationWheelCalculator.h" +#include "LArHECCalibrationWheelCalculator.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" -#include "AthenaKernel/getMessageSvc.h" +#include "LArG4HEC/IHECGeometry.h" #include "G4Step.hh" #include "G4TouchableHistory.hh" @@ -20,49 +17,66 @@ namespace LArG4 { namespace HEC { - LArHECCalibrationWheelCalculator::LArHECCalibrationWheelCalculator(const eHECGeometryType type) { - - StoreGateSvc* detStore; - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StatusCode status = svcLocator->service("DetectorStore", detStore); - MsgStream log(Athena::getMessageSvc(),"LArHECWheelCalculator" ); - if(status != StatusCode::SUCCESS ) { - log << MSG::ERROR << "No DetStore available !!" << endreq; - } + LArHECCalibrationWheelCalculator::LArHECCalibrationWheelCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_geometryCalculator("HECGeometry",name) //FIXME LArG4::HEC::HECGeometry + , m_geometryTypeProp(0) + , m_geometryType(kWheelActive) + { + declareProperty("GeometryCalculator",m_geometryCalculator); + declareProperty("GeometryType",m_geometryTypeProp); + m_geometryTypeProp.declareUpdateHandler(&LArHECCalibrationWheelCalculator::GeometryTypeUpdateHandler, this); + } - log << MSG::INFO << "Use the LArHECCalibrationWheelCalculator for the HEC" << endreq; + void LArHECCalibrationWheelCalculator::GeometryTypeUpdateHandler(Property&) + { + switch(m_geometryTypeProp.value()) + { + case 0: m_geometryType = kWheelActive; break; + case 1: m_geometryType = kWheelInactive; break; + case 2: m_geometryType = kWheelDead; break; + default: + std::ostringstream merr; + merr << + "LArHECCalibrationWheelCalculator::GeometryTypeUpdateHandler FATAL: invalid eHECGeometryType specified " + << m_geometryTypeProp.value(); + std::cerr << merr.str() << std::endl; + throw GaudiException(merr.str(), "LArHECCalibrationWheelCalculator::GeometryTypeUpdateHandler", StatusCode::FAILURE); + } - // Initialize the geometry calculator. - m_geometryCalculator = HECGeometry::GetInstance(); - m_geometryType = type; } + StatusCode LArHECCalibrationWheelCalculator::initialize() { - LArHECCalibrationWheelCalculator::~LArHECCalibrationWheelCalculator() { + ATH_MSG_INFO("Use the LArHECCalibrationWheelCalculator for the HEC"); + ATH_CHECK(m_geometryCalculator.retrieve()); + return StatusCode::SUCCESS; } + LArHECCalibrationWheelCalculator::~LArHECCalibrationWheelCalculator() { + } - G4bool LArHECCalibrationWheelCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) { - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } + G4bool LArHECCalibrationWheelCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + if ( process == kEnergyAndID || process == kOnlyEnergy ) + { + m_energyCalculator.Energies( step, energies ); + } else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, m_geometryType ); - + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + + + + if ( process == kEnergyAndID || process == kOnlyID ) + { + // Calculate the identifier. + + identifier = m_geometryCalculator->CalculateIdentifier(step, m_geometryType ); + // Check for bad result. - if ( m_identifier == LArG4Identifier() ) return false; + if ( identifier == LArG4Identifier() ) return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.h new file mode 100644 index 000000000000..a9e5562d453f --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECCalibrationWheelCalculator.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// Jan-2008: (M.Fincke) To be used for new Module-Geometry + +#ifndef LArG4_HEC_LArHECCalibrationWheelCalculator_H +#define LArG4_HEC_LArHECCalibrationWheelCalculator_H + +#include "LArG4HEC/IHECGeometry.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" +#include "LArG4Code/LArG4Identifier.h" +#include "CaloG4Sim/SimulationEnergies.h" + +#include "globals.hh" + +#include <vector> + +// Forward declaractions: +class G4Step; + +namespace LArG4 { + + namespace HEC { + + class LArHECCalibrationWheelCalculator : public LArCalibCalculatorSvcImp { + public: + + LArHECCalibrationWheelCalculator(const std::string& name, ISvcLocator *pSvcLocator); + void GeometryTypeUpdateHandler(Property&); + StatusCode initialize() override final; + virtual ~LArHECCalibrationWheelCalculator(); + + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + private: + + ServiceHandle<IHECGeometry> m_geometryCalculator; + UnsignedShortProperty m_geometryTypeProp; + eHECGeometryType m_geometryType; + //std::string m_strgeometryType; + + CaloG4::SimulationEnergies m_energyCalculator; + + }; + + } // namespace HEC + +} // namespace LArG4 + +#endif // LArG4_HEC_LArHECCalibrationWheelCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc old mode 100755 new mode 100644 index 79c40269f190..5380a3ffd207 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.cc @@ -2,13 +2,10 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4HEC/LArHECLocalCalculator.h" +#include "LArHECLocalCalculator.h" #include "LArG4HEC/LocalGeometry.h" -#include "LArG4RunControl/LArG4GlobalOptions.h" -#include "LArG4RunControl/LArG4HECOptions.h" - #include "G4ThreeVector.hh" #include "G4StepPoint.hh" #include "G4Step.hh" @@ -18,87 +15,54 @@ #include "G4TouchableHistory.hh" #include "LArG4Code/LArG4BirksLaw.h" -#include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/Units.h" #include "globals.hh" #include <cmath> +namespace Units = Athena::Units; + #undef DEBUG_HITS -// Standard implementation of a singleton pattern. -LArHECLocalCalculator* LArHECLocalCalculator::m_instance = 0; -G4bool LArHECLocalCalculator::m_isX = false; -LArHECLocalCalculator* LArHECLocalCalculator::GetCalculator() +LArHECLocalCalculator::LArHECLocalCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_Geometry("LocalHECGeometry", name) + , m_birksLaw(nullptr) + , m_isX(false) { - if (m_instance == 0) - { - m_instance = new LArHECLocalCalculator(); - } - return m_instance; + declareProperty("GeometryCalculator", m_Geometry); + declareProperty("IsX", m_isX); } - -LArHECLocalCalculator::LArHECLocalCalculator() - ://m_identifier(),m_time(0),m_energy(0), - m_isInTime(false),m_birksLaw(NULL) +StatusCode LArHECLocalCalculator::initialize() { - StoreGateSvc* detStore; - LArG4GlobalOptions *globalOptions=NULL; - LArG4HECOptions *hecOptions=NULL; - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StatusCode status = svcLocator->service("DetectorStore", detStore); - - if(status.isSuccess()){ - status = detStore->retrieve(globalOptions, "LArG4GlobalOptions"); - if(status.isFailure()){ - throw std::runtime_error("LArHECLocalCalculator: cannot retrieve LArG4GlobalOptions"); - } - status = detStore->retrieve(hecOptions, "LArG4HECOptions"); - if(status.isFailure()){ - // throw std::runtime_error("LArHECLocalCalculator: cannot retrieve LArG4HECOptions"); - } - } else { - throw std::runtime_error("LArHECLocalCalculator: cannot initialize StoreGate interface"); - } - status = svcLocator->service("MessageSvc", m_msgSvc); - if(status.isFailure()) m_msgSvc = 0; - if(m_msgSvc) { - MsgStream log(m_msgSvc,"LArHECLocalCalculator"); - log << MSG::INFO << "Constructing Calculator " << endreq; - } - - m_OOTcut = globalOptions->OutOfTimeCut(); - - m_isX = false; - - m_Geometry = LArG4::HEC::LocalGeometry::GetInstance(); - m_Geometry->SetX(m_isX); - - if (hecOptions) { - if (hecOptions->HECBirksLaw()) { - const double Birks_LAr_density = 1.396; - const double Birks_k = hecOptions->HECBirksk(); - m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); - } - } -} + StoreGateSvc* detStore(nullptr); + ATH_CHECK(svcLocator->service("DetectorStore", detStore)); + ATH_MSG_DEBUG("Constructing LArHECLocalCalculator"); -LArHECLocalCalculator::~LArHECLocalCalculator() -{ - delete m_birksLaw; + ATH_CHECK(m_Geometry.retrieve()); + + if (m_BirksLaw) + { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); + } + + return StatusCode::SUCCESS; } -void LArHECLocalCalculator::SetX(bool x){ - m_Geometry->SetX(x); - m_isX = x; +StatusCode LArHECLocalCalculator::finalize() +{ + if(m_birksLaw) delete m_birksLaw; + return StatusCode::SUCCESS; } -G4bool LArHECLocalCalculator::Process(const G4Step* a_step, int depthadd, double deadzone, std::vector<LArHitData>& hdata) +G4bool LArHECLocalCalculator::Process(const G4Step* a_step, int depthadd, double deadzone, std::vector<LArHitData>& hdata) const { // make sure vector is clear @@ -107,7 +71,7 @@ G4bool LArHECLocalCalculator::Process(const G4Step* a_step, int depthadd, double hdata[0].energy = a_step->GetTotalEnergyDeposit(); // apply BirksLaw if we want to: - G4double stepLengthCm = a_step->GetStepLength() / CLHEP::cm; + G4double stepLengthCm = a_step->GetStepLength() / Units::cm; if(hdata[0].energy <= 0. || stepLengthCm <= 0.) return false; if(m_birksLaw) hdata[0].energy = (*m_birksLaw)(hdata[0].energy, stepLengthCm, 10.0 /*KeV/cm*/); @@ -115,21 +79,16 @@ G4bool LArHECLocalCalculator::Process(const G4Step* a_step, int depthadd, double // Find out how long it took the energy to get here. G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); G4StepPoint* post_step_point = a_step->GetPostStepPoint(); - G4double timeOfFlight = (pre_step_point->GetGlobalTime() + + G4double timeOfFlight = (pre_step_point->GetGlobalTime() + post_step_point->GetGlobalTime()) * 0.5; G4ThreeVector startPoint = pre_step_point->GetPosition(); G4ThreeVector endPoint = post_step_point->GetPosition(); G4ThreeVector p = (startPoint + endPoint) * 0.5; - - hdata[0].time = timeOfFlight/CLHEP::ns - p.mag()/CLHEP::c_light/CLHEP::ns; - if (hdata[0].time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; + + hdata[0].time = (timeOfFlight - p.mag()/CLHEP::c_light)/Units::ns; // Calculate the identifier. hdata[0].id = m_Geometry->CalculateIdentifier( a_step, LArG4::HEC::kLocActive, depthadd, deadzone); // std::cout<<"LArHECLocalCalculator::Process "<<depthadd<<std::endl; return true; } - diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.h new file mode 100644 index 000000000000..3c754d9aed8a --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECLocalCalculator.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4HECLocalCalculator.hh + +// Revision history: + +// 17-Feb-2006 : Pavol Strizenec + +#ifndef __LArG4HECLocalCalculator_H__ +#define __LArG4HECLocalCalculator_H__ + +//#include "globals.hh" +//#include "G4ThreeVector.hh" +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include <stdexcept> +#include "CLHEP/Units/SystemOfUnits.h" + + +// Forward declarations. +class G4Step; +class LArG4BirksLaw; + +namespace LArG4 { + namespace HEC { + class ILocalGeometry; + } +} + +class LArHECLocalCalculator : virtual public LArCalculatorSvcImp { + +public: + + LArHECLocalCalculator(const std::string& name, ISvcLocator * pSvcLocator); + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + virtual ~LArHECLocalCalculator(){}; + + virtual G4float OOTcut() const override final { return m_OOTcut; } + + virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const override final { return this->Process(a_step,0, 4.*CLHEP::mm, hdata);} + virtual G4bool Process(const G4Step* a_step, int depthadd, double deadzone, std::vector<LArHitData>& hdata) const final; //FIXME not part of interface... + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); //FIXME should we be checking the absolute value of hitTime here? + } + + +private: + + ServiceHandle<LArG4::HEC::ILocalGeometry> m_Geometry; + + LArG4BirksLaw *m_birksLaw; + G4bool m_isX; + + LArHECLocalCalculator (const LArHECLocalCalculator&); + LArHECLocalCalculator operator= (const LArHECLocalCalculator&); +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc old mode 100755 new mode 100644 index ac58b6137bc2..e23a5bcb6546 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.cc @@ -2,14 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4HEC/LArHECWheelCalculator.h" -#include "LArG4HEC/HECGeometry.h" +#include "LArHECWheelCalculator.h" +#include "LArG4HEC/IHECGeometry.h" -#include "LArG4RunControl/LArG4GlobalOptions.h" -#include "LArG4RunControl/LArG4HECOptions.h" -#include "LArG4RunControl/LArG4HECOptions.h" - - #include "LArReadoutGeometry/LArDetectorManager.h" #include "LArReadoutGeometry/HECDetectorManager.h" #include "LArReadoutGeometry/HECDetectorRegion.h" @@ -25,113 +20,79 @@ #include "G4AffineTransform.hh" #include "G4TouchableHistory.hh" #include "LArG4Code/LArG4BirksLaw.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" -#include "AthenaKernel/getMessageSvc.h" +#include "StoreGate/StoreGate.h" +#include "AthenaKernel/Units.h" #include "globals.hh" #include <cmath> -#undef DEBUG_HITS +namespace Units = Athena::Units; -// Standard implementation of a singleton pattern. +#undef DEBUG_HITS -LArHECWheelCalculator* LArHECWheelCalculator::m_instance = 0; -LArHECWheelCalculator* LArHECWheelCalculator::GetCalculator() +LArHECWheelCalculator::LArHECWheelCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalculatorSvcImp(name, pSvcLocator) + , m_Geometry("HECGeometry",name) //FIXME LArG4::HEC::HECGeometry + , m_DetectorManager(nullptr) + , m_birksLaw(nullptr) + , m_doHV(false) { - if (m_instance == 0) - { - m_instance = new LArHECWheelCalculator(); - } - return m_instance; + declareProperty("GeometryCalculator",m_Geometry); + declareProperty("HECHVEnable",m_doHV); } -LArHECWheelCalculator::~LArHECWheelCalculator() { - delete m_birksLaw; +LArHECWheelCalculator::~LArHECWheelCalculator() +{ + if(m_birksLaw) delete m_birksLaw; } -LArHECWheelCalculator::LArHECWheelCalculator() - :m_msgSvc(0), - //m_identifier(),m_time(0),m_energy(0), - m_isInTime(false), m_birksLaw(NULL) +StatusCode LArHECWheelCalculator::initialize() { - StoreGateSvc* detStore; - LArG4GlobalOptions *globalOptions=NULL; - LArG4HECOptions *hecOptions=NULL; - - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StatusCode status = svcLocator->service("DetectorStore", detStore); - - if(status.isSuccess()){ - status = detStore->retrieve(globalOptions, "LArG4GlobalOptions"); - if(status.isFailure()){ - throw std::runtime_error("LArHECWheelCalculator: cannot retrieve LArG4GlobalOptions"); - } - status = detStore->retrieve(hecOptions, "LArG4HECOptions"); - if(status.isFailure()){ - // throw std::runtime_error("LArHECWheelCalculator: cannot retrieve LArG4HECOptions"); - } - } else { - throw std::runtime_error("LArHECWheelCalculator: cannot initialize StoreGate interface"); - } - - MsgStream log(Athena::getMessageSvc(),"LArHECWheelCalculator" ); - log << MSG::INFO << "Use the LArHECWheelCalculator for the HEC" << endreq; - - m_OOTcut = globalOptions->OutOfTimeCut(); - - m_Geometry = LArG4::HEC::HECGeometry::GetInstance(); - m_DetectorManager=NULL; - - if (hecOptions) { - if (hecOptions->HECBirksLaw()) { - const double Birks_LAr_density = 1.396; - const double Birks_k = hecOptions->HECBirksk(); - m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,Birks_k); - - if (hecOptions->HECHVEnable()) { - const LArDetectorManager *manager=NULL; - if (detStore->retrieve(manager)!=StatusCode::SUCCESS) { - throw std::runtime_error("Cannot locate HEC Manager"); - } - else { - m_DetectorManager=manager->getHecManager(); - } - } - } - } + ATH_MSG_DEBUG("Use the LArHECWheelCalculator for the HEC"); + + ATH_CHECK(m_Geometry.retrieve()); + if (m_BirksLaw) + { + const double Birks_LAr_density = 1.396; + m_birksLaw = new LArG4BirksLaw(Birks_LAr_density,m_Birksk); + } + + if(m_doHV) + { + const LArDetectorManager *manager=nullptr; + StoreGateSvc *detStore = StoreGate::pointer("DetectorStore"); + ATH_CHECK(detStore->retrieve(manager)); + m_DetectorManager=manager->getHecManager(); + } + + return StatusCode::SUCCESS; } -G4bool LArHECWheelCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) +G4bool LArHECWheelCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const { // make sure hdata is reset hdata.resize(1); // First, get the energy. hdata[0].energy = a_step->GetTotalEnergyDeposit(); - + // apply BirksLaw if we want to: - G4double stepLengthCm = a_step->GetStepLength() / CLHEP::cm; + G4double stepLengthCm = a_step->GetStepLength() / Units::cm; if(hdata[0].energy <= 0. || stepLengthCm <= 0.) return false; if(m_birksLaw) hdata[0].energy = (*m_birksLaw)(hdata[0].energy, stepLengthCm, 10.0 /*KeV/cm*/); // Find out how long it took the energy to get here. G4double timeOfFlight = 0.5* ( a_step->GetPreStepPoint()->GetGlobalTime() - + a_step->GetPostStepPoint()->GetGlobalTime() ); + + a_step->GetPostStepPoint()->GetGlobalTime() ); G4ThreeVector point = 0.5* ( a_step->GetPreStepPoint()->GetPosition() - + a_step->GetPostStepPoint()->GetPosition() ); - - hdata[0].time = timeOfFlight/CLHEP::ns - point.mag()/CLHEP::c_light/CLHEP::ns; + + a_step->GetPostStepPoint()->GetPosition() ); - if (hdata[0].time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; + hdata[0].time = (timeOfFlight - point.mag()/CLHEP::c_light)/Units::ns; // Calculate the identifier. int subgapIndex=0; @@ -145,7 +106,7 @@ G4bool LArHECWheelCalculator::Process(const G4Step* a_step, std::vector<LArHitDa int eta = hdata[0].id[5]; int phi = hdata[0].id[6]; - + if (m_DetectorManager) { const HECDetectorRegion *hecRegion=m_DetectorManager->getDetectorRegion(zSide<0? 0: 1, sampling, region); @@ -157,3 +118,7 @@ G4bool LArHECWheelCalculator::Process(const G4Step* a_step, std::vector<LArHitDa return true; } +StatusCode LArHECWheelCalculator::finalize() { + if(m_birksLaw) delete m_birksLaw; + return StatusCode::SUCCESS; +} diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h new file mode 100644 index 000000000000..9d017e3d9162 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LArHECWheelCalculator.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArHECWheelCalculator.hh + +// Revision history: + +// Jan-2008: (M.Fincke) To be used for new Module-Geometry + +#ifndef __LArG4HECWheelCalculator_H__ +#define __LArG4HECWheelCalculator_H__ + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include <stdexcept> + +// Forward declarations. + +class G4Step; +class HECGeometry; +class LArG4BirksLaw; +class HECDetectorManager; + +namespace LArG4 { + namespace HEC { + class IHECGeometry; + } +} + + +class LArHECWheelCalculator : virtual public LArCalculatorSvcImp { +public: + + LArHECWheelCalculator(const std::string& name, ISvcLocator * pSvcLocator); + virtual StatusCode initialize() override final; + virtual StatusCode finalize() override final; + ~LArHECWheelCalculator(); + ///////////////////////////////////////////// + + virtual G4float OOTcut() const override final { return m_OOTcut; } + + virtual G4bool Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const override final; + + // Check if the current hitTime is in-time + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); //FIXME should we be checking the absolute value of hitTime here? + } + + +private: + ServiceHandle<LArG4::HEC::IHECGeometry> m_Geometry; + const HECDetectorManager *m_DetectorManager; + + + LArG4BirksLaw *m_birksLaw; + bool m_doHV; + + LArHECWheelCalculator (const LArHECWheelCalculator&); + LArHECWheelCalculator& operator= (const LArHECWheelCalculator&); +}; + +#endif diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc old mode 100755 new mode 100644 index 3a4ac515624d..fb867593ca75 --- a/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.cc @@ -2,7 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4HEC/LocalCalibrationCalculator.h" +#include "LocalCalibrationCalculator.h" #include "G4Step.hh" #include "G4TouchableHistory.hh" @@ -15,42 +15,83 @@ namespace LArG4 { namespace HEC { - LocalCalibrationCalculator::LocalCalibrationCalculator(const eLocalGeometryType type) { + LocalCalibrationCalculator::LocalCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + , m_geometryCalculator("LocalHECGeometry",name) + , m_geometryType(kLocActive) + { + declareProperty("GeometryCalculator", m_geometryCalculator); + declareProperty("GeometryType",m_strgeometryType="ACTIVE"); + m_strgeometryType.declareUpdateHandler(&LocalCalibrationCalculator::GeometryTypeUpdateHandler, this); #ifdef DEBUG_HITS - std::cout << "LArG4::HEC::LocalCalibrationCalculator constructed" << std::endl; + std::cout << "LArG4::HEC::LocalCalibrationCalculator constructed" << std::endl; #endif - // Initialize the geometry calculator. - m_geometryCalculator = LocalGeometry::GetInstance(); - m_geometryType = type; + } + + void LocalCalibrationCalculator::GeometryTypeUpdateHandler(Property&) + { + std::string geoTypeString = m_strgeometryType.value(); + std::transform(geoTypeString.begin(), geoTypeString.end(),geoTypeString.begin(), ::toupper); + if(geoTypeString.find("DEAD") != std::string::npos) + { + m_geometryType=kLocDead; + } + else if (geoTypeString.find("INACTIVE") != std::string::npos) + { + m_geometryType=kLocInactive; + } + else if (geoTypeString.find("ACTIVE") != std::string::npos) + { + m_geometryType=kLocActive; + } + else + { + std::ostringstream merr; + merr << + "LArG4::HEC::LocalCalibrationCalculator::GeometryTypeUpdateHandler FATAL: invalid eHECGeometryType specified " + << geoTypeString; + std::cerr << merr.str() << std::endl; + throw GaudiException(merr.str(), "LArG4::HEC::LocalCalibrationCalculator::GeometryTypeUpdateHandler", StatusCode::FAILURE); + } + } + StatusCode LocalCalibrationCalculator::initialize() + { + // Initialize the geometry calculator. + ATH_CHECK(m_geometryCalculator.retrieve()); + + return StatusCode::SUCCESS; + } LocalCalibrationCalculator::~LocalCalibrationCalculator() { } - G4bool LocalCalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) { + G4bool LocalCalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { #ifdef DEBUG_HITS std::cout << "LArG4::HEC::LocalCalibrationCalculator::Process" << std::endl; #endif - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) + energies.clear(); + if ( process == kEnergyAndID || process == kOnlyEnergy ) { #ifdef DEBUG_HITS std::cout << " calling SimulationEnergies" << std::endl; #endif - m_energyCalculator.Energies( a_step, m_energies ); + m_energyCalculator.Energies( step, energies ); } else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); - if ( a_process == kEnergyAndID || a_process == kOnlyID ) + if ( process == kEnergyAndID || process == kOnlyID ) { // Calculate the identifier. - G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + G4StepPoint* pre_step_point = step->GetPreStepPoint(); G4TouchableHistory* theTouchable = (G4TouchableHistory*) (pre_step_point->GetTouchable()); // Volume name G4String hitVolume = theTouchable->GetVolume(0)->GetName(); @@ -63,32 +104,32 @@ namespace LArG4 { } if(m_geometryType != kLocDead) { if(hitVolume=="Slice" ) { - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, kLocInactive, 0, 4.*CLHEP::mm); + identifier = m_geometryCalculator->CalculateIdentifier(step, kLocInactive, 0, 4.*CLHEP::mm); } else if(hitVolume=="Absorber" ) { - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, kLocInactive, 0, 2.*CLHEP::mm, 1.02*CLHEP::mm); + identifier = m_geometryCalculator->CalculateIdentifier(step, kLocInactive, 0, 2.*CLHEP::mm, 1.02*CLHEP::mm); } else if(hitVolume=="Electrode") { - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, kLocInactive, 1, 4.*CLHEP::mm); + identifier = m_geometryCalculator->CalculateIdentifier(step, kLocInactive, 1, 4.*CLHEP::mm); } else if(hitVolume=="Copper") { - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, kLocInactive, 2, 4.*CLHEP::mm); + identifier = m_geometryCalculator->CalculateIdentifier(step, kLocInactive, 2, 4.*CLHEP::mm); } else if(hitVolume=="TieRod"){ // We should call another functions for TieRods - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, kLocActive, -1); - } else m_identifier = LArG4Identifier(); - } else m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, m_geometryType, 0, 4.*CLHEP::mm); + identifier = m_geometryCalculator->CalculateIdentifier(step, kLocActive, -1); + } else identifier = LArG4Identifier(); + } else identifier = m_geometryCalculator->CalculateIdentifier(step, m_geometryType, 0, 4.*CLHEP::mm); #ifdef DEBUG_HITS - G4double energy = accumulate(m_energies.begin(),m_energies.end(),0.); + G4double energy = accumulate(energies.begin(),energies.end(),0.); std::cout << "LArG4::HEC::LocalCalibrationCalculator::Process" - << " ID=" << std::string(m_identifier) + << " ID=" << std::string(identifier) << " energy=" << energy - << " energies=(" << m_energies[0] - << "," << m_energies[1] - << "," << m_energies[2] - << "," << m_energies[3] << ")" + << " energies=(" << energies[0] + << "," << energies[1] + << "," << energies[2] + << "," << energies[3] << ")" << std::endl; #endif // Check for bad result. - if ( m_identifier == LArG4Identifier() ) return false; + if ( identifier == LArG4Identifier() ) return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.h new file mode 100644 index 000000000000..1985b52903ab --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LocalCalibrationCalculator.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LArG4_HEC_LocalCalibrationCalculator_H +#define LArG4_HEC_LocalCalibrationCalculator_H + +#include "LArG4Code/LArCalibCalculatorSvcImp.h" +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4HEC/ILocalGeometry.h" +#include "CaloG4Sim/SimulationEnergies.h" + +#include "globals.hh" + +#include <vector> + +// Forward declaractions: +class G4Step; + +namespace LArG4 { + + namespace HEC { + + + class LocalCalibrationCalculator : public LArCalibCalculatorSvcImp { + public: + + LocalCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocatorconst); + void GeometryTypeUpdateHandler(Property&); + StatusCode initialize() override final; + virtual ~LocalCalibrationCalculator(); + + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + private: + + ServiceHandle<ILocalGeometry> m_geometryCalculator; + + eLocalGeometryType m_geometryType; + StringProperty m_strgeometryType; + + CaloG4::SimulationEnergies m_energyCalculator; + + }; + + } // namespace HEC + +} // namespace LArG4 + +#endif // LArG4_HEC_LocalCalibrationCalculator_H diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc b/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc old mode 100755 new mode 100644 index c9f4df8fe321..b194c69729af --- a/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc +++ b/LArCalorimeter/LArG4/LArG4HEC/src/LocalGeometry.cc @@ -6,7 +6,7 @@ #include "LArG4HEC/LocalGeometry.h" #include "LArG4Code/LArG4Identifier.h" -#include "LArG4HEC/Geometry.h" +//#include "LArG4HEC/Geometry.h" #include "G4ThreeVector.hh" #include "G4StepPoint.hh" @@ -20,186 +20,185 @@ #include "RDBAccessSvc/IRDBRecord.h" #include "RDBAccessSvc/IRDBRecordset.h" #include "GeoModelInterfaces/IGeoModelSvc.h" -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" +#include "AthenaKernel/Units.h" #include "globals.hh" #include <cmath> #include <stdexcept> + +namespace Units = Athena::Units; + + #undef DEBUG_HEC #undef DEBUG_HEC_OLD_DIAGNOSTIC -#define NUM_ETABIN 15 +//#define NUM_ETABIN 15 namespace LArG4 { namespace HEC { -static double pads[7][NUM_ETABIN]; - -static G4double depthSize[7]; -static G4double firstAbsorber[7]; -static G4double betweenWheel; - -LocalGeometry* LocalGeometry::m_instance = 0; -bool LocalGeometry::m_isX = false; - - -G4int binSearch(G4double ly, G4int depth, G4int reg) -{ - static G4int xl,xh; - static G4int ires; - - if(reg == 1) { xl = 0; xh = 4; - } else { xl = 4; xh = NUM_ETABIN-1; } - -// std::cout<<"binSearch::ly "<<ly<<" depth: "<<depth<<" reg: "<<reg<<std::endl; -// if(ly < pads[depth][xl] || ly > pads[depth][xh] ) return -1; - if(ly < pads[depth][xl]) return xl; - if(ly > pads[depth][xh] ) return xh-1; - while( xl < xh - 1 ) { - ires = xl + (xh - xl)/2; -// G4cout<<"xl: "<<xl<<" xh: "<<xh<<" ires: "<<ires<<" pads[depth][ires]: "<< pads[depth][ires]<<endl; - if (ly == pads[depth][ires]) return ires - 1; - if (ly < pads[depth][ires]) - xh = ires; - else - xl = ires; - } -// std::cout<<xl<<std::endl; - - return xl; -} - -G4int binSearchAll(G4double ly, G4int depth, bool regular=false) -{ - static G4int xl,xh; - static G4int ires; - - xl = 0; xh = NUM_ETABIN-1; - -// std::cout<<"binSearchAll::ly "<<ly<<" depth: "<<depth<<" regular: "<<regular<<std::endl; -// if(ly < pads[depth][xl] || ly > pads[depth][xh] ) return -1; - if(ly < pads[depth][xl]) return xl; - if(ly > pads[depth][xh] ) return xh-1; - while( xl < xh - 1 ) { - ires = xl + (xh - xl)/2; -// G4cout<<"xl: "<<xl<<" xh: "<<xh<<" ires: "<<ires<<" pads[depth][ires]: "<< pads[depth][ires]<<endl; - if (ly == pads[depth][ires]) return ires - 1; - if (ly < pads[depth][ires]) - xh = ires; - else - xl = ires; - } -// std::cout<<xl<<" "<<pads[depth][xl]<<" "<<pads[depth][xl+1]<<std::endl; - if(regular) { // we should recompute to 0.1 eta binning overall numbering - if(xl < 4) { - ires = xl; - xl *= 2; - if(ly > pads[depth][ires] + (pads[depth][ires+1]-pads[depth][ires])/2.) ++xl; - } else { - xl += 4; - } - } -// std::cout<<"After recomput.: "<<xl<<std::endl; - return xl; -} -double deadZone(double locx, double locy, double /*rot*/=0) -{ - double r = sqrt(locx*locx + locy*locy); - double alpha = atan(locx/locy); - double dalpha = 2*M_PI/64 - alpha; - return r*sin(dalpha); -} - - - // Standard implementation of a singleton pattern. - - LocalGeometry* LocalGeometry::GetInstance() + int LocalGeometry::binSearch(double ly, int depth, int reg) const { - static LocalGeometry instance; - return &instance; + int xl(4); + int xh(14); // = NUM_ETABIN-1 + if(reg == 1) + { + xl = 0; + xh = 4; + } + + // std::cout<<"binSearch::ly "<<ly<<" depth: "<<depth<<" reg: "<<reg<<std::endl; + // if(ly < m_pads[depth][xl] || ly > m_pads[depth][xh] ) return -1; + if(ly < m_pads[depth][xl]) return xl; + if(ly > m_pads[depth][xh] ) return xh-1; + while( xl < xh - 1 ) { + const int ires(xl + (xh - xl)/2); + // G4cout<<"xl: "<<xl<<" xh: "<<xh<<" ires: "<<ires<<" m_pads[depth][ires]: "<< m_pads[depth][ires]<<endl; + if (ly == m_pads[depth][ires]) return ires - 1; + if (ly < m_pads[depth][ires]) + xh = ires; + else + xl = ires; + } + // std::cout<<xl<<std::endl; + + return xl; } + int LocalGeometry::binSearchAll(double ly, int depth, bool regular) const + { + int xl(0); + int xh(14); // = NUM_ETABIN-1 + int ires(0); + + // std::cout<<"binSearchAll::ly "<<ly<<" depth: "<<depth<<" regular: "<<regular<<std::endl; + // if(ly < m_pads[depth][xl] || ly > m_pads[depth][xh] ) return -1; + if(ly < m_pads[depth][xl]) return xl; + if(ly > m_pads[depth][xh] ) return xh-1; + while( xl < xh - 1 ) { + ires = xl + (xh - xl)/2; + // G4cout<<"xl: "<<xl<<" xh: "<<xh<<" ires: "<<ires<<" m_pads[depth][ires]: "<< m_pads[depth][ires]<<endl; + if (ly == m_pads[depth][ires]) return ires - 1; + if (ly < m_pads[depth][ires]) + xh = ires; + else + xl = ires; + } + // std::cout<<xl<<" "<<m_pads[depth][xl]<<" "<<m_pads[depth][xl+1]<<std::endl; + if(regular) { // we should recompute to 0.1 eta binning overall numbering + if(xl < 4) { + ires = xl; + xl *= 2; + if(ly > m_pads[depth][ires] + (m_pads[depth][ires+1]-m_pads[depth][ires])/2.) ++xl; + } else { + xl += 4; + } + } + // std::cout<<"After recomput.: "<<xl<<std::endl; + return xl; + } - LocalGeometry::LocalGeometry() { + double LocalGeometry::deadZone(double locx, double locy) const + { + double r = sqrt(locx*locx + locy*locy); + double alpha = atan(locx/locy); + double dalpha = 2*M_PI/64 - alpha; + return r*sin(dalpha); + } -// std::cout<<"LArG4::HEC::LocalGeometry called !"<<std::endl; - StatusCode status; - // Access the GeoModelSvc: - ISvcLocator *svcLocator = Gaudi::svcLocator(); + LocalGeometry::LocalGeometry(const std::string& name, ISvcLocator * pSvcLocator) + : AthService(name, pSvcLocator) + , m_geoModel("GeoModelSvc", name) + , m_AccessSvc("RDBAccessSvc", name) + , m_isX(false) + { + declareProperty("GeoModelSvc",m_geoModel); + declareProperty("RDBAccessSvc", m_AccessSvc); + declareProperty("isX", m_isX); + } - IMessageSvc *msgSvc; - status = svcLocator->service("MessageSvc", msgSvc); - if(!status.isFailure()) m_log = new MsgStream(msgSvc,"HEC::LocalGeometry");; + StatusCode LocalGeometry::initialize() + { - IGeoModelSvc *geoModel; - status = svcLocator->service ("GeoModelSvc",geoModel); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate GeoModelSvc!!"); - } + // Access the GeoModelSvc: + ATH_CHECK(m_geoModel.retrieve()); // Access the geometry database: - IRDBAccessSvc *pAccessSvc; - status=svcLocator->service("RDBAccessSvc",pAccessSvc); - if (status != StatusCode::SUCCESS) { - throw std::runtime_error ("Cannot locate RDBAccessSvc!!"); - } + ATH_CHECK(m_AccessSvc.retrieve()); // Obtain the geometry version information: - pAccessSvc->connect(); + m_AccessSvc->connect(); - std::string AtlasVersion = geoModel->atlasVersion(); - std::string LArVersion = geoModel->LAr_VersionOverride(); + std::string AtlasVersion = m_geoModel->atlasVersion(); + std::string LArVersion = m_geoModel->LAr_VersionOverride(); std::string detectorKey = LArVersion.empty() ? AtlasVersion : LArVersion; std::string detectorNode = LArVersion.empty() ? "ATLAS" : "LAr"; - const IRDBRecordset *hecPad = pAccessSvc->getRecordset("HecPad",detectorKey, detectorNode); - if (hecPad->size()==0) { - hecPad = pAccessSvc->getRecordset("HecPad","HecPad-00", "HecPad"); - } - - if(m_log) { - *m_log << MSG::INFO << "Constructing local HEC geometry helper " << endreq; - *m_log << MSG::DEBUG<< " detectorKey: "<<detectorKey<<" detectorNode: "<<detectorNode<<std::endl; - } - - - if (hecPad->size()==0) { throw std::runtime_error("Cannot find the HECPAD Table"); } - - const IRDBRecord *rowPad; - for(unsigned int i=0; i<hecPad->size(); ++i) { - rowPad = (*hecPad)[i]; - for(int j=0; j<NUM_ETABIN; ++j) { - pads[i][j] = rowPad->getDouble("ETA",j); - } - } - - const IRDBRecordset *hecLongitudinalBlock = pAccessSvc->getRecordset("HecLongitudinalBlock",detectorKey,detectorNode); - if (hecLongitudinalBlock->size()==0) { - throw std::runtime_error("Cannot find the HecLongitinalBlock Table"); - } - - const IRDBRecordset *hadronicEndcap = pAccessSvc->getRecordset("HadronicEndcap",detectorKey,detectorNode); - if (hadronicEndcap->size()==0) { - throw std::runtime_error("Cannot find the HadronicEndcap Table"); - } - for (int indexloop=0; indexloop < 7; ++indexloop){ + ATH_MSG_INFO("Constructing local HEC geometry helper "); + ATH_MSG_DEBUG(" detectorKey: "<<detectorKey<<" detectorNode: "<<detectorNode); + + const IRDBRecordset *hecPad = m_AccessSvc->getRecordset("HecPad",detectorKey, detectorNode); + if (hecPad->size()==0) + { + hecPad = m_AccessSvc->getRecordset("HecPad","HecPad-00", "HecPad"); + } + if (hecPad->size()==0) + { + ATH_MSG_ERROR("Cannot find the HECPAD Table"); + return StatusCode::FAILURE; + } + const IRDBRecord *rowPad(nullptr); + for(unsigned int i=0; i<hecPad->size(); ++i) + { + rowPad = (*hecPad)[i]; + for(int j=0; j<15; ++j) //NUM_ETABIN=15 + { + m_pads[i][j] = rowPad->getDouble("ETA",j); // FIXME Setting static global variables + } + } + + const IRDBRecordset *hecLongitudinalBlock = m_AccessSvc->getRecordset("HecLongitudinalBlock",detectorKey,detectorNode); + if (hecLongitudinalBlock->size()==0) + { + ATH_MSG_ERROR("Cannot find the HecLongitinalBlock Table"); + return StatusCode::FAILURE; + } + for (int indexloop=0; indexloop < 7; ++indexloop) + { + m_depthSize[indexloop] = (*hecLongitudinalBlock)[indexloop]->getDouble("BLDPTH")*Units::cm; + m_firstAbsorber[indexloop]= (*hecLongitudinalBlock)[indexloop]->getDouble("PLATE0")*Units::cm; + } + + const IRDBRecordset *hadronicEndcap = m_AccessSvc->getRecordset("HadronicEndcap",detectorKey,detectorNode); + if (hadronicEndcap->size()==0) + { + ATH_MSG_ERROR("Cannot find the HadronicEndcap Table"); + return StatusCode::FAILURE; + } + m_betweenWheel = (*hadronicEndcap)[0]->getDouble("GAPWHL")*Units::cm-0.001*Units::cm; //40.5*mm + + m_AccessSvc->shutdown(); + + return StatusCode::SUCCESS; + } - depthSize[indexloop] = (*hecLongitudinalBlock)[indexloop]->getDouble("BLDPTH")*CLHEP::cm; - firstAbsorber[indexloop]= (*hecLongitudinalBlock)[indexloop]->getDouble("PLATE0")*CLHEP::cm; + StatusCode LocalGeometry::queryInterface( const InterfaceID & riid, void** ppvInterface ) + { + if ( ILocalGeometry::interfaceID().versionMatch(riid) ) { + *ppvInterface = dynamic_cast<ILocalGeometry*>(this); + } else { + // Interface is not directly available : try out a base class + return AthService::queryInterface(riid, ppvInterface); } - betweenWheel = (*hadronicEndcap)[0]->getDouble("GAPWHL")*CLHEP::cm-0.001*CLHEP::cm; //40.5*mm - - - pAccessSvc->shutdown(); - + addRef(); + return StatusCode::SUCCESS; } - LArG4Identifier LocalGeometry::CalculateIdentifier(const G4Step* a_step, const eLocalGeometryType g_type, int depthadd, double deadzone, double locyadd) { + LArG4Identifier LocalGeometry::CalculateIdentifier(const G4Step* a_step, const eLocalGeometryType g_type, int depthadd, double deadzone, double locyadd) const { // Find out how long it took the energy to get here. G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); @@ -208,16 +207,16 @@ double deadZone(double locx, double locy, double /*rot*/=0) G4ThreeVector endPoint = post_step_point->GetPosition(); G4ThreeVector p = (startPoint + endPoint) * 0.5; - + // We can extract our position from the copy number of depth and module G4TouchableHistory* theTouchable = (G4TouchableHistory*) (pre_step_point->GetTouchable()); // Get local coordinates of the step, independently of how it was positioned in World G4AffineTransform transformation; if(depthadd >=0) { - transformation = pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); + transformation = pre_step_point->GetTouchable()->GetHistory()->GetTopTransform(); } else { - transformation = pre_step_point->GetTouchable()->GetHistory()->GetTransform(pre_step_point->GetTouchable()->GetHistoryDepth() + abs(depthadd)); + transformation = pre_step_point->GetTouchable()->GetHistory()->GetTransform(pre_step_point->GetTouchable()->GetHistoryDepth() + abs(depthadd)); } G4ThreeVector startPointinLocal = transformation.TransformPoint(startPoint); G4ThreeVector endPointinLocal = transformation.TransformPoint (endPoint); @@ -225,442 +224,442 @@ double deadZone(double locx, double locy, double /*rot*/=0) #ifdef DEBUG_HEC -// if(g_type == kLocDead) { - if(deadzone == 0.) { - // The hitted volume's identier is possible to get by the name of his "mother" volume. - // G4cout <<" hitLogiVolume->GetNoDaughters= " <<hitLogiVolume->GetNoDaughters()<<G4endl; - // G4cout <<"+++++"<<hitLogiVolume->GetDaughter(1)->GetLogicalVolume()->GetMaterial()->GetName()<<G4endl; - // G4cout <<"+++++"<<hitLogiVolume->GetName()<<G4endl; + // if(g_type == kLocDead) { + if(deadzone == 0.) { + // The hitted volume's identier is possible to get by the name of his "mother" volume. + // G4cout <<" hitLogiVolume->GetNoDaughters= " <<hitLogiVolume->GetNoDaughters()<<G4endl; + // G4cout <<"+++++"<<hitLogiVolume->GetDaughter(1)->GetLogicalVolume()->GetMaterial()->GetName()<<G4endl; + // G4cout <<"+++++"<<hitLogiVolume->GetName()<<G4endl; - G4String hitVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); + G4String hitVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); - G4int copyN=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); + int copyN=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetCopyNo(); - // 16-Oct-2003 WGS: Due to a revision in Geant4, - // G4VPhysicalVolume::GetMother() no longer exists. If we want to - // find a mother volume, we have to do so in a more complex way: + // 16-Oct-2003 WGS: Due to a revision in Geant4, + // G4VPhysicalVolume::GetMother() no longer exists. If we want to + // find a mother volume, we have to do so in a more complex way: - G4TouchableHistory* touchHist = - (G4TouchableHistory*) a_step->GetPreStepPoint()->GetTouchable(); - G4int volDepth = touchHist->GetHistoryDepth(); + G4TouchableHistory* touchHist = + (G4TouchableHistory*) a_step->GetPreStepPoint()->GetTouchable(); + int volDepth = touchHist->GetHistoryDepth(); - // If the volume depth is 0, then this is the mother volume of the - // simulation. (I know that's not likely, but let's be sure.) - // Otherwise, we want to go up one level in depth to get the mother - // volume. + // If the volume depth is 0, then this is the mother volume of the + // simulation. (I know that's not likely, but let's be sure.) + // Otherwise, we want to go up one level in depth to get the mother + // volume. - //if ( volDepth != 0 ) volDepth--; - //G4VPhysicalVolume *motherPhysical = touchHist->GetVolume(volDepth); - G4VPhysicalVolume *motherPhysical = touchHist->GetVolume(1); + //if ( volDepth != 0 ) volDepth--; + //G4VPhysicalVolume *motherPhysical = touchHist->GetVolume(volDepth); + G4VPhysicalVolume *motherPhysical = touchHist->GetVolume(1); - // G4String motherVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetMother()->GetName(); - G4String motherVolume=motherPhysical->GetName(); + // G4String motherVolume=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetMother()->GetName(); + G4String motherVolume=motherPhysical->GetName(); - G4String material=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName(); + G4String material=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName(); - // G4int copyN1=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetMother()->GetCopyNo(); - G4int copyN1=motherPhysical->GetCopyNo(); + // int copyN1=a_step->GetPreStepPoint()->GetPhysicalVolume()->GetMother()->GetCopyNo(); + int copyN1=motherPhysical->GetCopyNo(); - std::cout <<"HEC::LocalGeometry +++++hitVolume="<<hitVolume<<" , his material="<<material<<", copyNumber="<<copyN<<", motherVolume="<<motherVolume <<", copy1="<< copyN1<< std::endl; - std::cout <<"Coordinates: "<<p<<" Local coordinates: "<<pinLocal<<std::endl; - G4int copyDepth = theTouchable->GetVolume(1 + abs(depthadd))->GetCopyNo() - 100; - // As well as module - G4int copyModule = theTouchable->GetVolume(2 + abs(depthadd))->GetCopyNo(); - std::cout <<"g_type: "<<g_type<<" depthadd: "<<depthadd<<std::endl; - std::cout <<"copyModule = "<<copyModule<<" copyDepth = "<<copyDepth<<std::endl; + std::cout <<"HEC::LocalGeometry +++++hitVolume="<<hitVolume<<" , his material="<<material<<", copyNumber="<<copyN<<", motherVolume="<<motherVolume <<", copy1="<< copyN1<< std::endl; + std::cout <<"Coordinates: "<<p<<" Local coordinates: "<<pinLocal<<std::endl; + int copyDepth = theTouchable->GetVolume(1 + abs(depthadd))->GetCopyNo() - 100; + // As well as module + int copyModule = theTouchable->GetVolume(2 + abs(depthadd))->GetCopyNo(); + std::cout <<"g_type: "<<g_type<<" depthadd: "<<depthadd<<std::endl; + std::cout <<"copyModule = "<<copyModule<<" copyDepth = "<<copyDepth<<std::endl; } -#endif +#endif + + int zSide; + int sampling = 0; + int region; + int etaBin = 0; + int phiBin; - G4int zSide; - G4int sampling = 0; - G4int region; - G4int etaBin = 0; - G4int phiBin; + int copyModule; - G4int copyModule; - zSide = 2; - if( p.z()<0.) zSide =-2; + if( p.z()<0.) zSide =-2; if(g_type != kLocDead) { // Calculate the active or inactive ID - // Volume name - // G4String hitVolume = theTouchable->GetVolume(0)->GetName(); - // We need also copy number of depth - G4int copyDepth = theTouchable->GetVolume(1 + abs(depthadd))->GetCopyNo() - 100; - // As well as module - copyModule = theTouchable->GetVolume(2 + abs(depthadd))->GetCopyNo() - 1; - if(zSide<0) { - if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; - } - - // Sampling Identifier - switch(copyDepth) { - case 0: { sampling = 0; break; } - case 1: case 2: { sampling = 1; break; } - case 3: case 4: { sampling = 2; break; } - case 5: case 6: { sampling = 3; break; } - default: { // Something wrong, should not be -// return CalculateIdentifier(a_step, kLocDead, depthadd); - assert(0<1); - break; } - } - - double locy, locx; - if(m_isX) { - locy = fabs(pinLocal.x()/CLHEP::mm); - locx = pinLocal.y()/CLHEP::mm; - } else { - locy = fabs(pinLocal.y()/CLHEP::mm); - locx = pinLocal.x()/CLHEP::mm; - } - // Add shift is needed (absorber) - locy += locyadd; - // Region Identifier - // This will be computed from local Y coordinate - if( locy < pads[copyDepth][4] ) region = 1; - else region = 0; - - // eta_Bin Identifier - // Needs a table of coordinates of pad boundaries - switch(region) { - case 1: { etaBin = 3 - binSearch(locy, copyDepth, region); break; } - case 0: { etaBin = 13 - binSearch(locy, copyDepth, region); break; } - default: { assert(0<1); break; } - } - - LArG4Identifier result = LArG4Identifier(); - - // Check, if we are not in dead zone - double distance = deadZone(fabs(locx),locy); - if(depthadd < 0 || distance < deadzone) { // we return the dead identifier -#ifdef DEBUG_HEC - std::cout<<" In active copyModule = "<< copyModule<<std::endl; + // Volume name + // G4String hitVolume = theTouchable->GetVolume(0)->GetName(); + // We need also copy number of depth + int copyDepth = theTouchable->GetVolume(1 + abs(depthadd))->GetCopyNo() - 100; + // As well as module + copyModule = theTouchable->GetVolume(2 + abs(depthadd))->GetCopyNo() - 1; + if(zSide<0) { + if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; + } + + // Sampling Identifier + switch(copyDepth) { + case 0: { sampling = 0; break; } + case 1: case 2: { sampling = 1; break; } + case 3: case 4: { sampling = 2; break; } + case 5: case 6: { sampling = 3; break; } + default: { // Something wrong, should not be + // return CalculateIdentifier(a_step, kLocDead, depthadd); + assert(0<1); + break; } + } + + double locy, locx; + if(m_isX) { + locy = fabs(pinLocal.x()/Units::mm); + locx = pinLocal.y()/Units::mm; + } else { + locy = fabs(pinLocal.y()/Units::mm); + locx = pinLocal.x()/Units::mm; + } + // Add shift is needed (absorber) + locy += locyadd; + // Region Identifier + // This will be computed from local Y coordinate + if( locy < m_pads[copyDepth][4] ) region = 1; + else region = 0; + + // eta_Bin Identifier + // Needs a table of coordinates of pad boundaries + switch(region) { + case 1: { etaBin = 3 - binSearch(locy, copyDepth, region); break; } + case 0: { etaBin = 13 - binSearch(locy, copyDepth, region); break; } + default: { assert(0<1); break; } + } + + LArG4Identifier result = LArG4Identifier(); + + // Check, if we are not in dead zone + double distance = deadZone(fabs(locx),locy); + if(depthadd < 0 || distance < deadzone) { // we return the dead identifier +#ifdef DEBUG_HEC + std::cout<<" In active copyModule = "<< copyModule<<std::endl; #endif - if(zSide * locx < 0) phiBin = copyModule; - else { - if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; - } - if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; - result << 10 // DeadM - << 2*zSide // LAr - << 2 // DM type - << sampling - << region+2 - << etaBin - << phiBin; -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry ++Dead in active zSide = "<<zSide<<" type = 2"<<" , sampling = "<<sampling - <<" , region="<<region+2 << " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; + if(zSide * locx < 0) phiBin = copyModule; + else { + if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; + } + if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; + result << 10 // DeadM + << 2*zSide // LAr + << 2 // DM type + << sampling + << region+2 + << etaBin + << phiBin; +#ifdef DEBUG_HEC + std::cout <<"HEC::LocalGeometry ++Dead in active zSide = "<<zSide<<" type = 2"<<" , sampling = "<<sampling + <<" , region="<<region+2 << " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; #endif - } else { // we return regular ID - - // Phi Identifier - if(region == 1) { phiBin = copyModule; - } else { - phiBin = 2*copyModule; - if(zSide * locx > 0) ++phiBin; - /* - if(m_isX) { - if(zSide * pinLocal.y() > 0) ++phiBin; - } else { - if(zSide * pinLocal.x() > 0) ++phiBin; - } - */ - } - if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; - if(region==0 && etaBin == 0 && sampling == 2) etaBin = 1; - if(region==0 && etaBin < 2 && sampling == 3) etaBin = 2; - result << 4 // LArCalorimeter - << 2 // LArHEC - << zSide - << sampling - << region - << etaBin - << phiBin; -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry ++Active zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << - " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; + } else { // we return regular ID + + // Phi Identifier + if(region == 1) { phiBin = copyModule; + } else { + phiBin = 2*copyModule; + if(zSide * locx > 0) ++phiBin; + /* + if(m_isX) { + if(zSide * pinLocal.y() > 0) ++phiBin; + } else { + if(zSide * pinLocal.x() > 0) ++phiBin; + } + */ + } + if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; + if(region==0 && etaBin == 0 && sampling == 2) etaBin = 1; + if(region==0 && etaBin < 2 && sampling == 3) etaBin = 2; + result << 4 // LArCalorimeter + << 2 // LArHEC + << zSide + << sampling + << region + << etaBin + << phiBin; +#ifdef DEBUG_HEC + std::cout <<"HEC::LocalGeometry ++Active zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << + " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; #endif - } - - return result; + } + + return result; } else { // Calculate dead ID -// if(m_log) *m_log << MSG::DEBUG << "Local geometry DM Id " << endreq; + // ATH_MSG_DEBUG("Local geometry DM Id "); - LArG4Identifier result = LArG4Identifier(); + LArG4Identifier result = LArG4Identifier(); - G4int type=1; - sampling=region=phiBin = 0; - etaBin = 25; + int type=1; + sampling=region=phiBin = 0; + etaBin = 25; // Copy number - G4int copyN = theTouchable->GetVolume(0)->GetCopyNo(); + int copyN = theTouchable->GetVolume(0)->GetCopyNo(); double locy, locx, locz, abslocz; - locz = pinLocal.z()/CLHEP::mm; - abslocz = fabs(locz); + locz = pinLocal.z()/Units::mm; + abslocz = fabs(locz); if(m_isX) { - locy = fabs(pinLocal.x()/CLHEP::mm); - locx = pinLocal.y()/CLHEP::mm; - } else { - locy = fabs(pinLocal.y()/CLHEP::mm); - locx = pinLocal.x()/CLHEP::mm; - } - - if(copyN == 16969) { // Mother volume (should not be) - if(m_log) *m_log << MSG::WARNING << "Wrong Local geometry DM volume: HEC mother, default ID used" <<endreq; - G4double phi = p.phi(); - if (phi < 0) phi += 2*M_PI; - phiBin = int(32*phi/(2*M_PI)); - G4double eta = fabs( p.pseudoRapidity() ); - etaBin = int(eta/0.1); - } else if (copyN <= 32) { // HEC::Module -// double locz = fabs(pinLocal.z()/CLHEP::mm); -// double locy = fabs(pinLocal.y()/CLHEP::mm); - if(zSide<0) { - if(copyN-1<16) copyModule = abs(copyN - 1 - 15); else copyModule = 47 - (copyN - 1); - } else { - copyModule = copyN -1; - } - phiBin = 2*copyModule; - if(zSide * locx > 0) ++phiBin; - /* - if(m_isX) { - if(zSide * pinLocal.y() > 0) ++phiBin; - } else { - if(zSide * pinLocal.x() > 0) ++phiBin; - } - */ + locy = fabs(pinLocal.x()/Units::mm); + locx = pinLocal.y()/Units::mm; + } else { + locy = fabs(pinLocal.y()/Units::mm); + locx = pinLocal.x()/Units::mm; + } + + if(copyN == 16969) { // Mother volume (should not be) + ATH_MSG_WARNING("Wrong Local geometry DM volume: HEC mother, default ID used"); + double phi = p.phi(); + if (phi < 0) phi += 2*M_PI; + phiBin = int(phi*(32/(2*M_PI))); + double eta = fabs( p.pseudoRapidity() ); + etaBin = int(eta/0.1); + } else if (copyN <= 32) { // HEC::Module + // double locz = fabs(pinLocal.z()/Units::mm); + // double locy = fabs(pinLocal.y()/Units::mm); + if(zSide<0) { + if(copyN-1<16) copyModule = abs(copyN - 1 - 15); else copyModule = 47 - (copyN - 1); + } else { + copyModule = copyN -1; + } + phiBin = 2*copyModule; + if(zSide * locx > 0) ++phiBin; + /* + if(m_isX) { + if(zSide * pinLocal.y() > 0) ++phiBin; + } else { + if(zSide * pinLocal.x() > 0) ++phiBin; + } + */ #ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"HEC::LocalGeometry Module locy: "<<locy<<" locz: "<<locz<<std::endl; + std::cout<<"HEC::LocalGeometry Module locy: "<<locy<<" locz: "<<locz<<std::endl; #endif - if(abslocz < firstAbsorber[0]) { // in front of HEC + if(abslocz < m_firstAbsorber[0]) { // in front of HEC #ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"In front of HEC"<<std::endl; + std::cout<<"In front of HEC"<<std::endl; #endif - type = 1; - sampling = 2; - region = 3; -// etaBin = 13 - binSearchAll(locy, 0); - etaBin = 16 - binSearchAll(locy, 0, true); - if( etaBin < 0 ) etaBin = 0; - } else if(abslocz > depthSize[0] + depthSize[1] + depthSize[2] && abslocz < depthSize[0] + depthSize[1] + depthSize[2] + betweenWheel + firstAbsorber[3]) { // interwheel gap + type = 1; + sampling = 2; + region = 3; + // etaBin = 13 - binSearchAll(locy, 0); + etaBin = 16 - binSearchAll(locy, 0, true); + if( etaBin < 0 ) etaBin = 0; + } else if(abslocz > m_depthSize[0] + m_depthSize[1] + m_depthSize[2] && abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2] + m_betweenWheel + m_firstAbsorber[3]) { // interwheel gap #ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"interwheel gap"<<std::endl; + std::cout<<"interwheel gap"<<std::endl; #endif - type = 1; - sampling = 2; - region = 4; -// etaBin = 13 - binSearchAll(locy, 0); - etaBin = 16 - binSearchAll(locy, 3, true); - } else { -// sampling = localSampling(pinLocal.z()/CLHEP::mm); - double distance = deadZone(fabs(pinLocal.x()/CLHEP::mm),locy); - if(distance > deadzone) { // We should return the inactive Id !!!! + type = 1; + sampling = 2; + region = 4; + // etaBin = 13 - binSearchAll(locy, 0); + etaBin = 16 - binSearchAll(locy, 3, true); + } else { + // sampling = localSampling(pinLocal.z()/Units::mm); + double distance = deadZone(fabs(pinLocal.x()/Units::mm),locy); + if(distance > deadzone) { // We should return the inactive Id !!!! #ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"inactive Id"<<std::endl; + std::cout<<"inactive Id"<<std::endl; #endif - int depthNum; - if(abslocz < depthSize[0]) { - sampling = 0; depthNum=0; - } else if(abslocz < depthSize[0] + depthSize[1] + depthSize[2]) { - sampling = 1; - if(abslocz < depthSize[0] + depthSize[1]) depthNum = 1; else depthNum = 2; - } else if(abslocz < depthSize[0] + depthSize[1] - + depthSize[2] + betweenWheel + depthSize[3] + depthSize[4] ) { - sampling = 2; - if(abslocz < depthSize[0] + depthSize[1] - + depthSize[2] + betweenWheel + depthSize[3]) depthNum = 3; else depthNum = 4; - } else { - sampling = 3; - if(abslocz < depthSize[0] + depthSize[1] - + depthSize[2] + betweenWheel + depthSize[3] + depthSize[4] + depthSize[5]) - depthNum = 5; - else - depthNum = 6; - } - if( locy < pads[depthNum][4] ) region = 1; else region = 0; - switch(region) { - case 1: { etaBin = 3 - binSearch(locy, depthNum, region); phiBin /= 2; break; } - case 0: { etaBin = 13 - binSearch(locy, depthNum, region); break; } - default: { assert(0<1); break; } - } -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << - " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; + int depthNum; + if(abslocz < m_depthSize[0]) { + sampling = 0; depthNum=0; + } else if(abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2]) { + sampling = 1; + if(abslocz < m_depthSize[0] + m_depthSize[1]) depthNum = 1; else depthNum = 2; + } else if(abslocz < m_depthSize[0] + m_depthSize[1] + + m_depthSize[2] + m_betweenWheel + m_depthSize[3] + m_depthSize[4] ) { + sampling = 2; + if(abslocz < m_depthSize[0] + m_depthSize[1] + + m_depthSize[2] + m_betweenWheel + m_depthSize[3]) depthNum = 3; else depthNum = 4; + } else { + sampling = 3; + if(abslocz < m_depthSize[0] + m_depthSize[1] + + m_depthSize[2] + m_betweenWheel + m_depthSize[3] + m_depthSize[4] + m_depthSize[5]) + depthNum = 5; + else + depthNum = 6; + } + if( locy < m_pads[depthNum][4] ) region = 1; else region = 0; + switch(region) { + case 1: { etaBin = 3 - binSearch(locy, depthNum, region); phiBin /= 2; break; } + case 0: { etaBin = 13 - binSearch(locy, depthNum, region); break; } + default: { assert(0<1); break; } + } +#ifdef DEBUG_HEC + std::cout <<"HEC::LocalGeometry zSide = "<<zSide<<" , sampling = "<<sampling<<" , region="<<region << + " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; #endif - if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; - if(region==0 && etaBin == 0 && sampling == 2) etaBin = 1; - if(region==0 && etaBin < 2 && sampling == 3) etaBin = 2; - result << 4 // LArCalorimeter - << 2 // LArHEC - << zSide - << sampling - << region - << etaBin - << phiBin; - return result; - } // intermodule cracks otherwise + if(region==1 && etaBin == 3 && (sampling == 1 || sampling == 2)) etaBin = 2; + if(region==0 && etaBin == 0 && sampling == 2) etaBin = 1; + if(region==0 && etaBin < 2 && sampling == 3) etaBin = 2; + result << 4 // LArCalorimeter + << 2 // LArHEC + << zSide + << sampling + << region + << etaBin + << phiBin; + return result; + } // intermodule cracks otherwise #ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<"intermodule crack"<<std::endl; + std::cout<<"intermodule crack"<<std::endl; #endif - if(zSide<0) { - if(copyN-1<16) copyModule = abs(copyN - 1 - 15); else copyModule = 47 - (copyN - 1); - } else { - copyModule = copyN - 1; - } - if(zSide * locx < 0) phiBin = copyModule; - else { - if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; - } - type = 2; - int depthNum; - if(abslocz < depthSize[0]) { - sampling = 0; depthNum=0; - } else if(abslocz < depthSize[0] + depthSize[1] + depthSize[2]) { - sampling = 1; - if(abslocz < depthSize[0] + depthSize[1]) depthNum = 1; else depthNum = 2; - } else if(abslocz < depthSize[0] + depthSize[1] + depthSize[2] + betweenWheel + depthSize[3] + depthSize[4] ) { - sampling = 2; - if(abslocz < depthSize[0] + depthSize[1] + depthSize[2] + betweenWheel + depthSize[3]) depthNum = 3; else depthNum = 4; - } else { - sampling = 3; - if(abslocz < depthSize[0] + depthSize[1] + depthSize[2] + betweenWheel + depthSize[3] + depthSize[4] + depthSize[5]) - depthNum = 5; - else - depthNum = 6; - } - if( locy < pads[depthNum][4] ) region = 3; else region = 2; + if(zSide<0) { + if(copyN-1<16) copyModule = abs(copyN - 1 - 15); else copyModule = 47 - (copyN - 1); + } else { + copyModule = copyN - 1; + } + if(zSide * locx < 0) phiBin = copyModule; + else { + if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; + } + type = 2; + int depthNum; + if(abslocz < m_depthSize[0]) { + sampling = 0; depthNum=0; + } else if(abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2]) { + sampling = 1; + if(abslocz < m_depthSize[0] + m_depthSize[1]) depthNum = 1; else depthNum = 2; + } else if(abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2] + m_betweenWheel + m_depthSize[3] + m_depthSize[4] ) { + sampling = 2; + if(abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2] + m_betweenWheel + m_depthSize[3]) depthNum = 3; else depthNum = 4; + } else { + sampling = 3; + if(abslocz < m_depthSize[0] + m_depthSize[1] + m_depthSize[2] + m_betweenWheel + m_depthSize[3] + m_depthSize[4] + m_depthSize[5]) + depthNum = 5; + else + depthNum = 6; + } + if( locy < m_pads[depthNum][4] ) region = 3; else region = 2; #ifdef DEBUG_HEC_OLD_DIAGNOSTIC - std::cout<<locy<<" "<<pads[depthNum][4]<<" "<<region<<std::endl; + std::cout<<locy<<" "<<m_pads[depthNum][4]<<" "<<region<<std::endl; #endif - switch(region) { - case 3: { etaBin = 3 - binSearch(locy, depthNum, region-2); break; } - case 2: { etaBin = 13 - binSearch(locy, depthNum, region-2); break; } - default: { assert(0<1); break; } - } - } - } else if (copyN==50 ) { // First Absorber - in front of HEC - copyModule = theTouchable->GetVolume(2)->GetCopyNo() - 1; - if(zSide<0) { - if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; - } - phiBin = 2*copyModule; - if(zSide * locx > 0) ++phiBin; - /* - if(m_isX) { - if(zSide * pinLocal.y() > 0) ++phiBin; - } else { - if(zSide * pinLocal.x() > 0) ++phiBin; - } - */ - type = 1; - sampling = 2; - region = 3; -// etaBin = 13 - binSearchAll(fabs(pinLocal.y()/CLHEP::mm), 0); -// etaBin = 16 - binSearchAll(fabs(pinLocal.y()/CLHEP::mm), 0, true); - etaBin = 16 - binSearchAll(locy, 0, true); - if( etaBin < 0 ) etaBin = 0; - } else if (copyN==51 ) { // First Absorber - interwheel gap - copyModule = theTouchable->GetVolume(2)->GetCopyNo() - 1; - if(zSide<0) { - if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; - } - phiBin = 2*copyModule; - if(zSide * locx > 0) ++phiBin; - /* - if(m_isX) { - if(zSide * pinLocal.y() > 0) ++phiBin; - } else { - if(zSide * pinLocal.x() > 0) ++phiBin; - } - */ - type = 1; - sampling = 2; - region = 4; -// etaBin = 13 - binSearchAll(fabs(pinLocal.y()/CLHEP::mm), 0); -// etaBin = 16 - binSearchAll(fabs(pinLocal.y()/CLHEP::mm), 3, true); - etaBin = 16 - binSearchAll(locy, 3, true); - } else if (copyN>=100 && copyN<= 106 ) { //Depth - copyModule = theTouchable->GetVolume(1)->GetCopyNo() - 1; - if(zSide<0) { - if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; - } - phiBin = 2*copyModule; - if(zSide * locx > 0) ++phiBin; - /* - if(m_isX) { - if(zSide * pinLocal.y() > 0) ++phiBin; - } else { - if(zSide * pinLocal.x() > 0) ++phiBin; - } - double locy = fabs(pinLocal.y()/CLHEP::mm); - */ - if(copyN==100 && locz < -depthSize[0]/2. + firstAbsorber[0]) { // in front of HEC - type = 1; - sampling = 2; + switch(region) { + case 3: { etaBin = 3 - binSearch(locy, depthNum, region-2); break; } + case 2: { etaBin = 13 - binSearch(locy, depthNum, region-2); break; } + default: { assert(0<1); break; } + } + } + } else if (copyN==50 ) { // First Absorber - in front of HEC + copyModule = theTouchable->GetVolume(2)->GetCopyNo() - 1; + if(zSide<0) { + if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; + } + phiBin = 2*copyModule; + if(zSide * locx > 0) ++phiBin; + /* + if(m_isX) { + if(zSide * pinLocal.y() > 0) ++phiBin; + } else { + if(zSide * pinLocal.x() > 0) ++phiBin; + } + */ + type = 1; + sampling = 2; + region = 3; + // etaBin = 13 - binSearchAll(fabs(pinLocal.y()/Units::mm), 0); + // etaBin = 16 - binSearchAll(fabs(pinLocal.y()/Units::mm), 0, true); + etaBin = 16 - binSearchAll(locy, 0, true); + if( etaBin < 0 ) etaBin = 0; + } else if (copyN==51 ) { // First Absorber - interwheel gap + copyModule = theTouchable->GetVolume(2)->GetCopyNo() - 1; + if(zSide<0) { + if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; + } + phiBin = 2*copyModule; + if(zSide * locx > 0) ++phiBin; + /* + if(m_isX) { + if(zSide * pinLocal.y() > 0) ++phiBin; + } else { + if(zSide * pinLocal.x() > 0) ++phiBin; + } + */ + type = 1; + sampling = 2; + region = 4; + // etaBin = 13 - binSearchAll(fabs(pinLocal.y()/Units::mm), 0); + // etaBin = 16 - binSearchAll(fabs(pinLocal.y()/Units::mm), 3, true); + etaBin = 16 - binSearchAll(locy, 3, true); + } else if (copyN>=100 && copyN<= 106 ) { //Depth + copyModule = theTouchable->GetVolume(1)->GetCopyNo() - 1; + if(zSide<0) { + if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; + } + phiBin = 2*copyModule; + if(zSide * locx > 0) ++phiBin; + /* + if(m_isX) { + if(zSide * pinLocal.y() > 0) ++phiBin; + } else { + if(zSide * pinLocal.x() > 0) ++phiBin; + } + double locy = fabs(pinLocal.y()/Units::mm); + */ + if(copyN==100 && locz < -m_depthSize[0]/2. + m_firstAbsorber[0]) { // in front of HEC + type = 1; + sampling = 2; + region = 3; + // etaBin = 13 - binSearchAll(locy, 0); + etaBin = 16 - binSearchAll(locy, 0, true); + if( etaBin < 0) etaBin = 0; + } else if(copyN==103 && locz < -m_depthSize[3]/2. + m_firstAbsorber[3]) { // interwheel gap + type = 1; + region = 4; + sampling = 2; + // etaBin = 13 - binSearchAll(locy, 0); + etaBin = 16 - binSearchAll(locy, 3, true); + } else { // intermodule cracks + double distance = deadZone(fabs(locx),locy); + if(distance > deadzone) { // We should return the inactive Id !!!! + // std::cout<<"Calling kLocInactive"<<std::endl; + return CalculateIdentifier(a_step, kLocInactive, -1, deadzone); + } + copyModule = theTouchable->GetVolume(1)->GetCopyNo() - 1; + if(zSide<0) { + if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; + } + if(zSide * locx < 0) phiBin = copyModule; + else { + if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; + } + type =2; + switch(copyN) { + case 100: {sampling = 0; break;} + case 101: case 102: {sampling=1; break;} + case 103: case 104: {sampling=2; break;} + case 105: case 106: {sampling=3; break;} + } + + if( locy < m_pads[copyN-100][4] ) { region = 3; -// etaBin = 13 - binSearchAll(locy, 0); - etaBin = 16 - binSearchAll(locy, 0, true); - if( etaBin < 0) etaBin = 0; - } else if(copyN==103 && locz < -depthSize[3]/2. + firstAbsorber[3]) { // interwheel gap - type = 1; - region = 4; - sampling = 2; -// etaBin = 13 - binSearchAll(locy, 0); - etaBin = 16 - binSearchAll(locy, 3, true); - } else { // intermodule cracks - double distance = deadZone(fabs(locx),locy); - if(distance > deadzone) { // We should return the inactive Id !!!! -// std::cout<<"Calling kLocInactive"<<std::endl; - return CalculateIdentifier(a_step, kLocInactive, -1, deadzone); - } - copyModule = theTouchable->GetVolume(1)->GetCopyNo() - 1; - if(zSide<0) { - if(copyModule<16) copyModule = abs(copyModule - 15); else copyModule = 47 - copyModule; - } - if(zSide * locx < 0) phiBin = copyModule; - else { - if(copyModule == 31) phiBin = 0; else phiBin=copyModule+1; - } - type =2; - switch(copyN) { - case 100: {sampling = 0; break;} - case 101: case 102: {sampling=1; break;} - case 103: case 104: {sampling=2; break;} - case 105: case 106: {sampling=3; break;} - } - - if( locy < pads[copyN-100][4] ) { - region = 3; - etaBin = 3 - binSearch(locy, copyN-100, region-2); - } - else { - region = 2; - etaBin = 13 - binSearch(locy, copyN-100, region-2); - } - } - } - -#ifdef DEBUG_HEC - std::cout <<"HEC::LocalGeometry ++Dead zSide = "<<zSide<<" type = "<<type<<" , sampling = "<<sampling - <<" , region="<<region << " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; + etaBin = 3 - binSearch(locy, copyN-100, region-2); + } + else { + region = 2; + etaBin = 13 - binSearch(locy, copyN-100, region-2); + } + } + } + +#ifdef DEBUG_HEC + std::cout <<"HEC::LocalGeometry ++Dead zSide = "<<zSide<<" type = "<<type<<" , sampling = "<<sampling + <<" , region="<<region << " , phiBin="<<phiBin<< " , etaBin="<<etaBin <<std::endl; #endif - result << 10 // DeadM - << 2*zSide // LAr - << type // DM type - << sampling - << region - << etaBin - << phiBin; - return result; + result << 10 // DeadM + << 2*zSide // LAr + << type // DM type + << sampling + << region + << etaBin + << phiBin; + return result; -// return Geometry::GetInstance()->CalculateIdentifier(a_step, kDead); + // return Geometry::GetInstance()->CalculateIdentifier(a_step, kDead); } } diff --git a/LArCalorimeter/LArG4/LArG4HEC/src/components/LArG4HEC_entries.cxx b/LArCalorimeter/LArG4/LArG4HEC/src/components/LArG4HEC_entries.cxx new file mode 100644 index 000000000000..75fd9aaf1ce7 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4HEC/src/components/LArG4HEC_entries.cxx @@ -0,0 +1,15 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" + +#include "../LArHECLocalCalculator.h" +#include "../LocalCalibrationCalculator.h" +#include "LArG4HEC/LocalGeometry.h" +#include "../LArHECWheelCalculator.h" +#include "../LArHECCalibrationWheelCalculator.h" +#include "LArG4HEC/HECGeometry.h" + +DECLARE_SERVICE_FACTORY(LArHECLocalCalculator) +DECLARE_SERVICE_FACTORY(LArG4::HEC::LocalCalibrationCalculator) +DECLARE_SERVICE_FACTORY(LArG4::HEC::LocalGeometry) +DECLARE_SERVICE_FACTORY(LArHECWheelCalculator) +DECLARE_SERVICE_FACTORY(LArG4::HEC::LArHECCalibrationWheelCalculator) +DECLARE_SERVICE_FACTORY(LArG4::HEC::HECGeometry) diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4MiniFCAL/CMakeLists.txt index 2de5df3c296d..3586173ef2c4 100644 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/CMakeLists.txt @@ -7,16 +7,15 @@ atlas_subdir( LArG4MiniFCAL ) # Declare the package's dependencies: atlas_depends_on_subdirs( PUBLIC - Calorimeter/CaloG4Sim Control/StoreGate GaudiKernel - LArCalorimeter/LArG4/LArG4Code PRIVATE + LArCalorimeter/LArG4/LArG4Code + Calorimeter/CaloG4Sim Control/AthenaKernel Database/AthenaPOOL/RDBAccessSvc DetectorDescription/GeoModel/GeoModelInterfaces - DetectorDescription/Identifier - LArCalorimeter/LArG4/LArG4RunControl ) + DetectorDescription/Identifier ) # External dependencies: find_package( Boost COMPONENTS filesystem thread system ) @@ -26,8 +25,9 @@ find_package( Geant4 ) find_package( XercesC ) # Component(s) in the package: -atlas_add_library( LArG4MiniFCAL +atlas_add_component( LArG4MiniFCAL src/*.cc + src/components.cxx PUBLIC_HEADERS LArG4MiniFCAL INCLUDE_DIRS ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CORAL_INCLUDE_DIRS} @@ -35,3 +35,4 @@ atlas_add_library( LArG4MiniFCAL LINK_LIBRARIES ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} GaudiKernel LArG4Code CaloG4SimLib StoreGateLib SGtests PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${CORAL_LIBRARIES} AthenaKernel Identifier LArG4RunControl ) +atlas_install_python_modules( python/*.py ) diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALAssignIdentifier.h b/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALAssignIdentifier.h old mode 100755 new mode 100644 index 04671854084c..e720cbbec4e1 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALAssignIdentifier.h +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALAssignIdentifier.h @@ -21,7 +21,6 @@ #include "G4ThreeVector.hh" #include "CLHEP/Geometry/Point3D.h" -#include "LArG4Code/LArVG4DetectorParameters.h" #include "globals.hh" #include <map> diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalculator.h b/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalculator.h deleted file mode 100755 index 7e0eb6f49f88..000000000000 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalculator.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -// MiniFCALCalculator.hh - -// Revision history: - -// Aug-2008: M.Fincke First implementation for SLHC MiniFCal - -#ifndef LARG4MINIFCAL_MINIFCALCALCULATOR_H -#define LARG4MINIFCAL_MINIFCALCALCULATOR_H - -#include "LArG4Code/LArG4Identifier.h" -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Code/LArVG4DetectorParameters.h" -#include <stdexcept> - -// Forward declarations. -class G4Step; -class MiniFCALAssignIdentifier; -class IMessageSvc; -namespace LArG4 { - namespace MiniFCAL { - class MiniFCALAssignIdentifier; - } -} - - -class MiniFCALCalculator : public LArVCalculator { -public: - - // Accessor for pointer to the singleton. - static MiniFCALCalculator* GetCalculator(); - - - ///////////////////////////////////////////// - // The interface for LArVCalculator. - - virtual G4float OOTcut() const { return m_OOTcut; } - virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } - - - virtual G4bool Process(const G4Step* a_step){return Process(a_step, m_hdata);} - virtual G4bool Process(const G4Step*, std::vector<LArHitData>&); - - virtual const LArG4Identifier& identifier(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].id; - } - - virtual G4double time(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].time; - } - virtual G4double energy(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - if(m_hdata.size()<1) throw std::range_error("No hit yet"); - return m_hdata[0].energy; - }; - virtual G4bool isInTime(int i=0) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return m_isInTime; - } - virtual G4bool isOutOfTime(int i) const { - if (i!=0) throw std::range_error("Multiple hits not yet implemented"); - return ( !m_isInTime ); - } - - -protected: - // The constructor is protected according to the singleton design - // pattern. - MiniFCALCalculator(); - -private: - static MiniFCALCalculator* m_instance; - - LArG4::MiniFCAL::MiniFCALAssignIdentifier *m_Geometry; - - //LArG4Identifier m_identifier; - //G4double m_time; - //G4double m_energy; - std::vector<LArHitData> m_hdata; - - G4float m_OOTcut; - G4bool m_isInTime; - -}; - -#endif // LARG4MINIFCAL_MINIFCALCALCULATOR_H - diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/cmt/requirements b/LArCalorimeter/LArG4/LArG4MiniFCAL/cmt/requirements index c58bbf503506..d995eb1eb791 100755 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/cmt/requirements @@ -5,22 +5,23 @@ author Margret Fincke-Keeler <mgf@uvic.ca> # G4 Hit processing for the Mini FCAL use AtlasPolicy AtlasPolicy-* -use LArG4Code LArG4Code-* LArCalorimeter/LArG4 use Geant4 Geant4-* External -use CaloG4Sim CaloG4Sim-* Calorimeter use GaudiInterface GaudiInterface-* External use StoreGate StoreGate-* Control use AtlasCLHEP AtlasCLHEP-* External # Build the library (and export the headers) -library LArG4MiniFCAL *.cc +library LArG4MiniFCAL *.cc -s=components *.cxx -apply_pattern installed_library +apply_pattern component_library +apply_pattern declare_python_modules files="*.py" private use AthenaKernel AthenaKernel-* Control use GeoModelInterfaces GeoModelInterfaces-* DetectorDescription/GeoModel use Identifier Identifier-* DetectorDescription use RDBAccessSvc RDBAccessSvc-* Database/AthenaPOOL -use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 +#use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 +use LArG4Code LArG4Code-* LArCalorimeter/LArG4 +use CaloG4Sim CaloG4Sim-* Calorimeter diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfig.py b/LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfig.py new file mode 100644 index 000000000000..c39adf376cc4 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfig.py @@ -0,0 +1,22 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon import CfgMgr + +def getMiniFCALCalibrationCalculator(name="MiniFCALCalibrationCalculator", **kwargs): + return CfgMgr.LArG4__MiniFCAL__MiniFCALCalibrationCalculator(name, **kwargs) + +def getMiniFCALActiveCalibrationCalculator(name="MiniFCALActiveCalibrationCalculator", **kwargs): + kwargs.setdefault("GeometryType", "ACTIVE") + return getMiniFCALCalibrationCalculator(name, **kwargs) + +def getMiniFCALInactiveCalibrationCalculator(name="MiniFCALInactiveCalibrationCalculator", **kwargs): + kwargs.setdefault("GeometryType", "INACTIVE") + return getMiniFCALCalibrationCalculator(name, **kwargs) + +def getMiniFCALDeadCalibrationCalculator(name="MiniFCALDeadCalibrationCalculator", **kwargs): + kwargs.setdefault("GeometryType", "DEAD") + return getMiniFCALCalibrationCalculator(name, **kwargs) + +def getMiniFCALCalculator(name="MiniFCALCalculator", **kwargs): + return CfgMgr.MiniFCALCalculator(name, **kwargs) + diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfigDb.py b/LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfigDb.py new file mode 100644 index 000000000000..e100117dd13c --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/python/LArG4MiniFCALConfigDb.py @@ -0,0 +1,9 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +from AthenaCommon.CfgGetter import addService + +addService("LArG4MiniFCAL.LArG4MiniFCALConfig.getMiniFCALCalculator","MiniFCALCalculator") +addService("LArG4MiniFCAL.LArG4MiniFCALConfig.getMiniFCALActiveCalibrationCalculator","MiniFCALActiveCalibrationCalculator") +addService("LArG4MiniFCAL.LArG4MiniFCALConfig.getMiniFCALInactiveCalibrationCalculator","MiniFCALInactiveCalibrationCalculator") +addService("LArG4MiniFCAL.LArG4MiniFCALConfig.getMiniFCALDeadCalibrationCalculator","MiniFCALDeadCalibrationCalculator") + diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc old mode 100755 new mode 100644 index 42090d97ce5b..1e2e3fc3978a --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALAssignIdentifier.cc @@ -71,18 +71,18 @@ namespace LArG4 { throw std::runtime_error("Error in MiniFcalAssingIdentifier, cannot access MessageSvc"); MsgStream log(m_msgsvc, "LArG4::MiniFcalAssignIdentifier"); - log << MSG::DEBUG << "In MiniFcalAssignIdentifier - constructor; access database" << endreq; + log << MSG::DEBUG << "In MiniFcalAssignIdentifier - constructor; access database" << endmsg; IRDBAccessSvc* pAccessSvc(0); sc=svcLocator->service("RDBAccessSvc",pAccessSvc); if(sc != StatusCode::SUCCESS) { - log << MSG::ERROR <<"Cannot locate RDBAccessSvc!!" << endreq; + log << MSG::ERROR <<"Cannot locate RDBAccessSvc!!" << endmsg; } IGeoModelSvc* geoModelSvc(0); sc = svcLocator->service ("GeoModelSvc",geoModelSvc); if (sc != StatusCode::SUCCESS) { - log << MSG::ERROR <<"Cannot locate GeoModelSvc!!" << endreq; + log << MSG::ERROR <<"Cannot locate GeoModelSvc!!" << endmsg; } @@ -104,17 +104,17 @@ namespace LArG4 { //--- Get geometry information from database: const IRDBRecordset* recEnvelope = pAccessSvc->getRecordset("MiniFcalEnvelope",detectorKey,detectorNode); if(recEnvelope->size()==0) { - log << MSG::ERROR << "Unable to get envelope parameters from the database" << endreq; + log << MSG::ERROR << "Unable to get envelope parameters from the database" << endmsg; } const IRDBRecordset* recCommon = pAccessSvc->getRecordset("MiniFcalCommon",detectorKey,detectorNode); if(recCommon->size()==0) { - log << MSG::ERROR << "Unable to get MiniFcalCommon from the database" << endreq; + log << MSG::ERROR << "Unable to get MiniFcalCommon from the database" << endmsg; } const IRDBRecordset* recRings = pAccessSvc->getRecordset("MiniFcalRings",detectorKey,detectorNode); if(recRings->size()==0) { - log << MSG::ERROR << "Unable to get MiniFcalRings from the database" << endreq; + log << MSG::ERROR << "Unable to get MiniFcalRings from the database" << endmsg; } m_halfLength = ((*recEnvelope)[0]->getDouble("DZ"))*CLHEP::mm; // half-length of MiniFcal module @@ -196,13 +196,13 @@ namespace LArG4 { loc2Transform = post_step_point->GetTouchable()->GetHistory()->GetTransform(g4depth); loc2Position = loc2Transform.TransformPoint(post_step_point->GetPosition()); - if (g4depth!=4) log << MSG::INFO << "MinFcal local Coordinates - BIG Error!: " << volumeName << " " << g4depth << " " << endreq; + if (g4depth!=4) log << MSG::INFO << "MinFcal local Coordinates - BIG Error!: " << volumeName << " " << g4depth << " " << endmsg; G4ThreeVector midPosition = (loc1Position + loc2Position) * 0.5; // local module coordinates double phigrad=0.; - phigrad = midPosition.getPhi()*180./(M_PI); + phigrad = midPosition.getPhi()*(180./M_PI); if (phigrad<0.) phigrad = 360. + phigrad; @@ -263,20 +263,20 @@ namespace LArG4 { //--- Check if there is anything unusual: if (iphi<0) log << MSG::INFO << "MiniFcal iphi problem: Z " << volumeName << " " << zSide << " " << phigrad << " " << iphi << " / ieta: " << ieta - << " " << m_nWafers[ieta] << endreq; + << " " << m_nWafers[ieta] << endmsg; if (ieta<0||ieta>(m_nRings-1)) log << MSG::INFO << " MiniFcal ieta problem - ieta=" - << volumeName << " " << ieta << endreq; + << volumeName << " " << ieta << endmsg; if (idepth<0 || idepth>10) log << MSG::INFO << idepth << "MiniFcal-wrong idepth! " << midPosition.z() - << " | " << volumeName << " -> " << volumeName2 << endreq; + << " | " << volumeName << " -> " << volumeName2 << endmsg; // adjust idepth fo 4 samplings max: if (idepth<2) idepth=0; else if (idepth<8 && idepth>=2) idepth=1; else if (idepth>=8) idepth=2; - else log << MSG::INFO << "Bad handling of the sampling! " << idepth <<endreq; + else log << MSG::INFO << "Bad handling of the sampling! " << idepth <<endmsg; minifcalID << 4 // LAr @@ -297,7 +297,7 @@ namespace LArG4 { // Provision for dead material - we shoud never get here!; // Use an ID that's close to the standard asignment for the moment with ieta/iphi=0 log << MSG::WARNING << " MiniFcalAssignIdentifier: Found dead material. This should NOT happen! Assign DM ID: 10-4-2-0-5-0-0 " - << volumeName << " " << volumeName2 << endreq; + << volumeName << " " << volumeName2 << endmsg; LArG4Identifier minifcalID = LArG4Identifier(); minifcalID << 10 // DM << 4 // +/-LAr diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.cc b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.cc old mode 100755 new mode 100644 index ba23f9bd7fb1..1d077a64f8cb --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.cc @@ -2,11 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4MiniFCAL/MiniFCALCalculator.h" +#include "MiniFCALCalculator.h" #include "LArG4MiniFCAL/MiniFCALAssignIdentifier.h" -#include "LArG4RunControl/LArG4GlobalOptions.h" - #include "G4ThreeVector.hh" #include "G4StepPoint.hh" #include "G4Step.hh" @@ -14,62 +12,33 @@ #include "G4LogicalVolumeStore.hh" #include "G4AffineTransform.hh" #include "G4TouchableHistory.hh" -#include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" #include "StoreGate/StoreGateSvc.h" #include "AthenaKernel/getMessageSvc.h" +#include "AthenaKernel/Units.h" #include "globals.hh" #include <cmath> -#undef DEBUG_HITS - -// Standard implementation of a singleton pattern. +namespace Units = Athena::Units; -MiniFCALCalculator* MiniFCALCalculator::m_instance = 0; +#undef DEBUG_HITS -MiniFCALCalculator* MiniFCALCalculator::GetCalculator() +MiniFCALCalculator::MiniFCALCalculator(const std::string& name, ISvcLocator *pSvcLocator):LArCalculatorSvcImp(name, pSvcLocator) { - if (m_instance == 0) - { - m_instance = new MiniFCALCalculator(); - } - return m_instance; } - -//MiniFCALCalculator::~MiniFCALCalculator() {} - -MiniFCALCalculator::MiniFCALCalculator() - :m_isInTime(false) +StatusCode MiniFCALCalculator::initialize() { - StoreGateSvc* detStore; - LArG4GlobalOptions *globalOptions=NULL; - - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StatusCode status = svcLocator->service("DetectorStore", detStore); - - if(status.isSuccess()){ - status = detStore->retrieve(globalOptions, "LArG4GlobalOptions"); - if(status.isFailure()){ - throw std::runtime_error("MiniFCALCalculator: cannot retrieve LArG4GlobalOptions"); - } - } - else { - throw std::runtime_error("MiniFCALCalculator: cannot initialize StoreGate interface"); - } - - MsgStream log(Athena::getMessageSvc(),"MiniFCALCalculator" ); - log << MSG::INFO << "Use the MiniFCALCalculator for the MiniFCAL" << endreq; - - m_OOTcut = globalOptions->OutOfTimeCut(); - m_Geometry = LArG4::MiniFCAL::MiniFCALAssignIdentifier::GetInstance(); + ATH_MSG_INFO("Use the MiniFCALCalculator for the MiniFCAL"); + m_Geometry = LArG4::MiniFCAL::MiniFCALAssignIdentifier::GetInstance(); + return StatusCode::SUCCESS; } -G4bool MiniFCALCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) +G4bool MiniFCALCalculator::Process(const G4Step* a_step, std::vector<LArHitData>& hdata) const { // make sure hdata is reset hdata.resize(1); @@ -80,21 +49,15 @@ G4bool MiniFCALCalculator::Process(const G4Step* a_step, std::vector<LArHitData> if(hdata[0].energy <= 0.) return false; // Find out how long it took the energy to get here. - G4double timeOfFlight = 0.5* ( a_step->GetPreStepPoint()->GetGlobalTime() - + a_step->GetPostStepPoint()->GetGlobalTime() ); - G4ThreeVector point = 0.5* ( a_step->GetPreStepPoint()->GetPosition() - + a_step->GetPostStepPoint()->GetPosition() ); + G4double timeOfFlight = 0.5* ( a_step->GetPreStepPoint()->GetGlobalTime() + + a_step->GetPostStepPoint()->GetGlobalTime() ); + G4ThreeVector point = 0.5* ( a_step->GetPreStepPoint()->GetPosition() + + a_step->GetPostStepPoint()->GetPosition() ); - hdata[0].time = timeOfFlight/CLHEP::ns - point.mag()/CLHEP::c_light/CLHEP::ns; - - if (hdata[0].time > m_OOTcut) - m_isInTime = false; - else - m_isInTime = true; + hdata[0].time = (timeOfFlight - point.mag()/CLHEP::c_light)/Units::ns; // Calculate the identifier. hdata[0].id = m_Geometry->CalculateIdentifier( a_step, LArG4::MiniFCAL::kActive); return true; } - diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.h b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.h new file mode 100644 index 000000000000..88c337387fde --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalculator.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// MiniFCALCalculator.hh + +// Revision history: + +// Aug-2008: M.Fincke First implementation for SLHC MiniFCal + +#ifndef LARG4MINIFCAL_MINIFCALCALCULATOR_H +#define LARG4MINIFCAL_MINIFCALCALCULATOR_H + +#include "LArG4Code/LArG4Identifier.h" +#include "LArG4Code/LArCalculatorSvcImp.h" +#include <stdexcept> + +// Forward declarations. +class G4Step; +class MiniFCALAssignIdentifier; +namespace LArG4 { + namespace MiniFCAL { + class MiniFCALAssignIdentifier; + } +} + + +class MiniFCALCalculator : public LArCalculatorSvcImp { +public: + + MiniFCALCalculator(const std::string& name, ISvcLocator * pSvcLocator); + StatusCode initialize(); + + ///////////////////////////////////////////// + + virtual G4float OOTcut() const override final { return m_OOTcut; } + virtual void SetOutOfTimeCut(G4double c) { m_OOTcut = c; } //FIXME public but not part of interface class + + + virtual G4bool Process(const G4Step*, std::vector<LArHitData>&) const override final; + + virtual G4bool isInTime(G4double hitTime) const override final + { + return !(hitTime > m_OOTcut); //FIXME should we be checking the absolute value of hdata[0].time here? + } + +private: + + LArG4::MiniFCAL::MiniFCALAssignIdentifier *m_Geometry; + + G4float m_OOTcut; +}; + +#endif // LARG4MINIFCAL_MINIFCALCALCULATOR_H diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.cc b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.cc old mode 100755 new mode 100644 index 1fe9db2a4a88..458912acec23 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.cc +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.cc @@ -2,7 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4MiniFCAL/MiniFCALCalibrationCalculator.h" +#include "MiniFCALCalibrationCalculator.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/Bootstrap.h" @@ -20,26 +20,26 @@ namespace LArG4 { namespace MiniFCAL { - MiniFCALCalibrationCalculator::MiniFCALCalibrationCalculator(const eMiniFCALAssignIdentifierType type) { + MiniFCALCalibrationCalculator::MiniFCALCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator) : LArCalibCalculatorSvcImp(name, pSvcLocator), + m_geometryType(kActive) { + declareProperty("GeometryType",m_strgeometryType="ACTIVE"); + } - StoreGateSvc* detStore; - ISvcLocator *svcLocator = Gaudi::svcLocator(); - StatusCode status = svcLocator->service("DetectorStore", detStore); - MsgStream log(Athena::getMessageSvc(),"MiniFCALCalculator" ); - if(status != StatusCode::SUCCESS ) { - log << MSG::ERROR << "No DetStore available !!" << endreq; - } + StatusCode MiniFCALCalibrationCalculator::initialize() { - log << MSG::INFO << "Use the MiniFCALCalibrationCalculator for the MiniFCAL" << endreq; + if(m_strgeometryType.find("DEAD") != std::string::npos){ + m_geometryType=kDead; + } else if (m_strgeometryType.find("INACTIVE") != std::string::npos){ + m_geometryType=kInactive; + } else {m_geometryType=kActive;} - // Make sure there are no uninitialized variables. - m_identifier = LArG4Identifier(); - m_energies.clear(); + ATH_MSG_INFO("Use the MiniFCALCalibrationCalculator for the MiniFCAL"); // Initialize the geometry and energy calculators. m_geometryCalculator = MiniFCALAssignIdentifier::GetInstance(); //m_energyCalculator = new CaloG4::SimulationEnergies(); - m_geometryType = type; + + return StatusCode::SUCCESS; } @@ -48,27 +48,22 @@ namespace LArG4 { //delete m_energyCalculator; } + G4bool MiniFCALCalibrationCalculator::Process(const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process) const + { + if ( process == kEnergyAndID || process == kOnlyEnergy ) { + m_energyCalculator.Energies( step, energies ); + } else { + for (unsigned int i=0; i != 4; i++) energies.push_back( 0. ); + } + - G4bool MiniFCALCalibrationCalculator::Process( const G4Step* a_step, - const eCalculatorProcessing a_process ) { - - m_energies.clear(); - if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) - { - m_energyCalculator.Energies( a_step, m_energies ); - } - else - for (unsigned int i=0; i != 4; i++) m_energies.push_back( 0. ); - - - - if ( a_process == kEnergyAndID || a_process == kOnlyID ) - { - // Calculate the identifier. - - m_identifier = m_geometryCalculator->CalculateIdentifier(a_step, m_geometryType ); + if ( process == kEnergyAndID || process == kOnlyID ) { + // Calculate the identifier. + identifier = m_geometryCalculator->CalculateIdentifier(step, m_geometryType ); // Check for bad result. - if ( m_identifier == LArG4Identifier() ) return false; + if ( identifier == LArG4Identifier() ) return false; return true; } diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalibrationCalculator.h b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.h old mode 100755 new mode 100644 similarity index 60% rename from LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalibrationCalculator.h rename to LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.h index 2697f34d1170..1e7d6b42eef5 --- a/LArCalorimeter/LArG4/LArG4MiniFCAL/LArG4MiniFCAL/MiniFCALCalibrationCalculator.h +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/MiniFCALCalibrationCalculator.h @@ -8,7 +8,7 @@ #define MiniFCALCalibrationCalculator_H #include "CaloG4Sim/SimulationEnergies.h" -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "LArG4MiniFCAL/MiniFCALAssignIdentifier.h" @@ -28,27 +28,23 @@ namespace LArG4 { namespace MiniFCAL { - class MiniFCALCalibrationCalculator : public VCalibrationCalculator { + class MiniFCALCalibrationCalculator : public LArCalibCalculatorSvcImp { public: - - MiniFCALCalibrationCalculator(const eMiniFCALAssignIdentifierType type = kActive); - virtual ~MiniFCALCalibrationCalculator(); - - virtual G4bool Process (const G4Step* step, - const eCalculatorProcessing p = kEnergyAndID); - - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - virtual const std::vector<G4double>& energies() const { return m_energies; } - private: - LArG4Identifier m_identifier; + MiniFCALCalibrationCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize(); + StatusCode finalize() {return StatusCode::SUCCESS;} + virtual ~MiniFCALCalibrationCalculator(); - std::vector<G4double> m_energies; + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing process = kEnergyAndID) const override final; + private: MiniFCALAssignIdentifier* m_geometryCalculator; eMiniFCALAssignIdentifierType m_geometryType; + std::string m_strgeometryType; CaloG4::SimulationEnergies m_energyCalculator; diff --git a/LArCalorimeter/LArG4/LArG4MiniFCAL/src/components/LArG4MiniFCAL_entries.cxx b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/components/LArG4MiniFCAL_entries.cxx new file mode 100644 index 000000000000..c230b209fdbd --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4MiniFCAL/src/components/LArG4MiniFCAL_entries.cxx @@ -0,0 +1,7 @@ +#include "GaudiKernel/DeclareFactoryEntries.h" + +#include "../MiniFCALCalculator.h" +#include "../MiniFCALCalibrationCalculator.h" + +DECLARE_SERVICE_FACTORY(LArG4::MiniFCAL::MiniFCALCalibrationCalculator) +DECLARE_SERVICE_FACTORY(MiniFCALCalculator) diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4BarrelOptions.h b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4BarrelOptions.h deleted file mode 100755 index 3924b277a730..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4BarrelOptions.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _LArG4BarrelOptions_h_ -#define _LArG4BarrelOptions_h_ -#include "CLHEP/Units/SystemOfUnits.h" - -// ----------------------------------------------------------------------// -// // -// This class defines options for the EMB part of the Liquid Argon // -// simulation. A constructor sets the default values. This class is // -// supposed to be exported to python, configured through python commands // -// then stored in storegate and ultimately writted to the data stream. // -// Similar structures exist for the other subcomponents. // -// // -//-----------------------------------------------------------------------// - -class LArG4BarrelOptions { - - public: - // A constructor to insure that the data starts up with a reasonable set - // of defaults: - - inline LArG4BarrelOptions() : - m_EMBCurr (true), - m_EMBEtaTrans (true), - m_EMBXtalk (true), - m_EMBTimeCurr (false), - m_EMBTimeShower (false), - m_EMBTimeProp (false), - m_EMBdstep (0.2*CLHEP::mm), - m_EMBBirksLaw (false), - m_EMBBirksk (0.0486), - m_EMBHVEnable (false) {} - - void saveMe(); - void printMe(); - - // Set methods - inline void EMBCurr(bool value) { m_EMBCurr = value; } - inline void EMBEtaTrans(bool value) { m_EMBEtaTrans = value; } - inline void EMBXtalk(bool value) { m_EMBXtalk = value; } - inline void EMBTimeCurr(bool value) { m_EMBTimeCurr = value; } - inline void EMBTimeShower(bool value) { m_EMBTimeShower = value; } - inline void EMBTimeProp(bool value) { m_EMBTimeProp = value; } - inline void EMBdstep(double value) { m_EMBdstep = value; } - inline void EMBBirksLaw(bool value) { m_EMBBirksLaw = value; } - inline void EMBBirksk(double value) { m_EMBBirksk = value; } - inline void EMBHVEnable(bool value) { m_EMBHVEnable = value; } - - // Get methods - inline bool EMBCurr(void) const { return m_EMBCurr; } - inline bool EMBEtaTrans(void) const { return m_EMBEtaTrans; } - inline bool EMBXtalk(void) const { return m_EMBXtalk; } - inline bool EMBTimeCurr(void) const { return m_EMBTimeCurr; } - inline bool EMBTimeShower(void) const { return m_EMBTimeShower; } - inline bool EMBTimeProp(void) const { return m_EMBTimeProp; } - inline double EMBdstep(void) const { return m_EMBdstep; } - inline bool EMBBirksLaw(void) const { return m_EMBBirksLaw; } - inline double EMBBirksk(void) const { return m_EMBBirksk; } - inline bool EMBHVEnable(void) const { return m_EMBHVEnable; } - - private: - // Switch for energy-current computation. - bool m_EMBCurr; - - // Switch for transition effect at eta=0.8 - bool m_EMBEtaTrans; - - // Switch for crosstalk effect in the strips: - bool m_EMBXtalk; - - // Switch for effect of current maps on time - bool m_EMBTimeCurr; - - // Switch to simulation effect of shower propagation with a cell, on time. - bool m_EMBTimeShower; - - // Switch to simulate the effect of signal propagation in the electrode, on time. - bool m_EMBTimeProp; - - // Value of the substep length in the current simulation - double m_EMBdstep; - - // Birks' law - bool m_EMBBirksLaw; - - // Birks' law, constant k - double m_EMBBirksk; - - // Enable HV imperfections in simulation - bool m_EMBHVEnable; - -}; - -#ifndef GAUDI_NEUTRAL -#include "CLIDSvc/CLASS_DEF.h" -CLASS_DEF(LArG4BarrelOptions, 321345322, 1) -#endif - -#endif diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4EMECOptions.h b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4EMECOptions.h deleted file mode 100755 index 84306c9ceb30..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4EMECOptions.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _LArG4EMECOptions_h_ -#define _LArG4EMECOptions_h_ -#include "CLHEP/Units/SystemOfUnits.h" - -// ----------------------------------------------------------------------// -// // -// This class defines options for the EMEC part of the Liquid Argon // -// simulation. A constructor sets the default values. This class is // -// supposed to be exported to python, configured through python commands // -// then stored in storegate and ultimately writted to the data stream. // -// Similar structures exist for the other subcomponents. // -// // -//-----------------------------------------------------------------------// - -// uncomment this to turn on runtime selection -// of the method for LArWheelCalculator::parameterized_slant_angle -//#define LARWHEELCALCULATOR_PSA_DEVELOPMENT - -#include <string> - -class LArG4EMECOptions -{ - public: - - enum ECORRTYPE {NONE, CHCOLL, GAPOLD, GAPADJ, GAP_E, GAP_S, GAP_SE, CHCOLL1}; - - inline LArG4EMECOptions() : - - m_EMECECorrType(CHCOLL1), - m_EMECGapPower(1.4), - m_EMECChMap("v03"), - m_EMECEsr(0.2*CLHEP::mm), - m_EMECHVMap("v02"), -#ifdef LARWHEELCALCULATOR_PSA_DEVELOPMENT - m_EMECFoldA("param"), //"param" "table" "iter" -#endif - m_EMECBirksLaw (false), - m_EMECBirksk (0.0486), - m_EMECHVEnable (false){} - - // m_EMECPhiRotation("off"), // or "g3" - // m_EMECSagging("off"), // or "" or "a b c d" - // m_EMECInnerSlantParam("default"), // or "" or "a b c d e" - // m_EMECOuterSlantParam("default") {} // -- " --- - - void saveMe(); - void printMe(); - - // Set methods - inline void EMECECorrType(ECORRTYPE value) { m_EMECECorrType = value; } - inline void EMECGapPower(double value) { m_EMECGapPower = value; } - inline void EMECChMap(std::string value) { m_EMECChMap = value; } - inline void EMECEsr(double value) { m_EMECEsr = value; } - inline void EMECHVMap(std::string value) { m_EMECHVMap = value; } -#ifdef LARWHEELCALCULATOR_PSA_DEVELOPMENT - inline void EMECFoldA(std::string value) { m_EMECFoldA = value; } -#endif - inline void EMECBirksLaw(bool value) { m_EMECBirksLaw = value; } - inline void EMECBirksk(double value) { m_EMECBirksk = value; } - inline void EMECHVEnable (bool value) { m_EMECHVEnable = value; } - - //inline void EMECPhiRotation(std::string value) {m_EMECPhiRotation = value;} - //inline void EMECSagging(std::string value) {m_EMECSagging = value;} - //inline void EMECInnerSlantParam(std::string value) {m_EMECInnerSlantParam = value;} - //inline void EMECOuterSlantParam(std::string value) {m_EMECOuterSlantParam = value;} - - // Get methods - inline ECORRTYPE EMECECorrType(void) { return m_EMECECorrType; } - inline double EMECGapPower(void) { return m_EMECGapPower; } - inline std::string EMECChMap(void) { return m_EMECChMap; } - inline double EMECEsr(void) { return m_EMECEsr; } - inline std::string EMECHVMap(void) { return m_EMECHVMap; } -#ifdef LARWHEELCALCULATOR_PSA_DEVELOPMENT - inline std::string EMECFoldA(void) { return m_EMECFoldA; } -#endif - inline bool EMECBirksLaw(void) const { return m_EMECBirksLaw; } - inline double EMECBirksk(void) const { return m_EMECBirksk; } - inline bool EMECHVEnable(void) const { return m_EMECHVEnable; } - //inline std::string EMECPhiRotation(void) { return m_EMECPhiRotation; } - //inline std::string EMECSagging(void) { return m_EMECSagging; } - //inline std::string EMECInnerSlantParam(void) { return m_EMECInnerSlantParam;} - //inline std::string EMECOuterSlantParam(void) { return m_EMECOuterSlantParam;} - - - private: - - // Type of energy correction. - ECORRTYPE m_EMECECorrType; - - // Gap adjustment power - double m_EMECGapPower; - - // Field Map Version - std::string m_EMECChMap; - - // Signal suppression - double m_EMECEsr; - - // High Voltage file version - std::string m_EMECHVMap; - - // method for folding angle calculation; - // "table": based on interpolation of the official table(ref:ABS.YYY.00.DR.2) - // "param": based on parametrization - // "iter": some iterational technique - // NOTE: this option has no effect unless - // LARWHEELCALCULATOR_PSA_DEVELOPMENT is defined in - // GeoSpecialShapes/LArWheelCalculator.h - -#ifdef LARWHEELCALCULATOR_PSA_DEVELOPMENT - std::string m_EMECFoldA; -#endif - // for G3 compatibility - //std::string m_EMECPhiRotation; - - // Sagging of fans - //std::string m_EMECSagging; - - // - //std::string m_EMECInnerSlantParam; - //std::string m_EMECOuterSlantParam; - - // Birks' law - bool m_EMECBirksLaw; - - // Birks' law, constant k - double m_EMECBirksk; - - // HV imperfections - bool m_EMECHVEnable; - - - -}; - -#ifndef GAUDI_NEUTRAL -#include "CLIDSvc/CLASS_DEF.h" -CLASS_DEF(LArG4EMECOptions, 321345323, 1) -#endif - -#endif diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4FCALOptions.h b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4FCALOptions.h deleted file mode 100644 index 8ecd0560f863..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4FCALOptions.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _LArG4FCALOptions_h_ -#define _LArG4FCALOptions_h_ -#include "CLHEP/Units/SystemOfUnits.h" - -// ----------------------------------------------------------------------// -// // -// This class defines options for the FCAL part of the Liquid Argon // -// simulation. A constructor sets the default values. This class is // -// supposed to be exported to python, configured through python commands // -// then stored in storegate and ultimately writted to the data stream. // -// Similar structures exist for the other subcomponents. // -// // -//-----------------------------------------------------------------------// - -class LArG4FCALOptions { - - public: - // A constructor to insure that the data starts up with a reasonable set - // of defaults: - - inline LArG4FCALOptions() : - m_FCALBirksLaw (false), - m_FCALBirksk (0.0486), - m_FCALHVEnable(false){} - - void saveMe(); - void printMe(); - - // Set methods - inline void FCALBirksLaw(bool value) { m_FCALBirksLaw = value; } - inline void FCALBirksk(double value) { m_FCALBirksk = value; } - inline void FCALEnableHV(bool value) { m_FCALHVEnable = value; } - // Get methods - inline bool FCALBirksLaw(void) const { return m_FCALBirksLaw; } - inline double FCALBirksk(void) const { return m_FCALBirksk; } - inline bool FCALHVEnable(void ) const { return m_FCALHVEnable; } - private: - - // Birks' law - bool m_FCALBirksLaw; - - // Birks' law, constant k - double m_FCALBirksk; - - // Enable HV - bool m_FCALHVEnable; - -}; - -#include "CLIDSvc/CLASS_DEF.h" -CLASS_DEF(LArG4FCALOptions, 190061068, 1) - -#endif diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4GlobalOptions.h b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4GlobalOptions.h deleted file mode 100755 index a350ec98aa92..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4GlobalOptions.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _LArG4GlobalOptions_h_ -#define _LArG4GlobalOptions_h_ -#include "CLHEP/Units/SystemOfUnits.h" - -// ----------------------------------------------------------------------// -// // -// This class defines options for the Global part of the Liquid Argon // -// simulation. A constructor sets the default values. This class is // -// supposed to be exported to python, configured through python commands // -// then stored in storegate and ultimately writted to the data stream. // -// Similar structures exist for the other subcomponents. // -// // -//-----------------------------------------------------------------------// - -#include <string> - -class LArG4GlobalOptions { - - public: - // A constructor to insure that the data starts up with a reasonable set - // of defaults: - - inline LArG4GlobalOptions() : - m_OutOfTimeCut (300*CLHEP::ns) {} - - void saveMe(); - void printMe(); - - // Set methods - inline void OutOfTimeCut(double value) { m_OutOfTimeCut = value; } - - // Get methods - inline double OutOfTimeCut(void) const { return m_OutOfTimeCut; } - - private: - // Value of the substep length in the current simulation - double m_OutOfTimeCut; - -}; - -#ifndef GAUDI_NEUTRAL -#include "CLIDSvc/CLASS_DEF.h" -CLASS_DEF(LArG4GlobalOptions, 321345321, 1) -#endif - -#endif diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4HECOptions.h b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4HECOptions.h deleted file mode 100755 index 11426e7cf38e..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4HECOptions.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef _LArG4HECOptions_h_ -#define _LArG4HECOptions_h_ -#include "CLHEP/Units/SystemOfUnits.h" - -// ----------------------------------------------------------------------// -// // -// This class defines options for the HEC part of the Liquid Argon // -// simulation. A constructor sets the default values. This class is // -// supposed to be exported to python, configured through python commands // -// then stored in storegate and ultimately writted to the data stream. // -// Similar structures exist for the other subcomponents. // -// // -//-----------------------------------------------------------------------// - -class LArG4HECOptions { - - public: - // A constructor to insure that the data starts up with a reasonable set - // of defaults: - - inline LArG4HECOptions() : - m_HECBirksLaw (false), - m_HECBirksk (0.0486), - m_HECHVEnable (false) {} - - void saveMe(); - void printMe(); - - // Set methods - inline void HECBirksLaw(bool value) { m_HECBirksLaw = value; } - inline void HECBirksk(double value) { m_HECBirksk = value; } - inline void HECHVEnable(bool value) { m_HECHVEnable = value; } - - // Get methods - inline bool HECBirksLaw(void) const { return m_HECBirksLaw; } - inline double HECBirksk(void) const { return m_HECBirksk; } - inline bool HECHVEnable(void) const { return m_HECHVEnable; } - - private: - - // Birks' law - bool m_HECBirksLaw; - - // Birks' law, constant k - double m_HECBirksk; - - // HV Imperfections: - bool m_HECHVEnable; - -}; - -#include "CLIDSvc/CLASS_DEF.h" -CLASS_DEF(LArG4HECOptions, 207610189, 1) - -#endif diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4RunControlDict.h b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4RunControlDict.h index 11d20f6a8e2b..acb931407e64 100755 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4RunControlDict.h +++ b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/LArG4RunControlDict.h @@ -2,11 +2,6 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#include "LArG4RunControl/LArG4GlobalOptions.h" -#include "LArG4RunControl/LArG4BarrelOptions.h" -#include "LArG4RunControl/LArG4EMECOptions.h" -#include "LArG4RunControl/LArG4HECOptions.h" -#include "LArG4RunControl/LArG4FCALOptions.h" #include "LArG4RunControl/LArG4TBPosOptions.h" #include "LArG4RunControl/LArGeoTBGeometricOptions.h" #include "LArG4RunControl/LArGeoTBH1GeoOptions.h" diff --git a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/selection.xml b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/selection.xml index cfc38b6bcd8b..723bf7e34bd0 100755 --- a/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/selection.xml +++ b/LArCalorimeter/LArG4/LArG4RunControl/LArG4RunControl/selection.xml @@ -1,9 +1,4 @@ <lcgdict> - <class name="LArG4GlobalOptions"/> - <class name="LArG4BarrelOptions"/> - <class name="LArG4EMECOptions"/> - <class name="LArG4HECOptions"/> - <class name="LArG4FCALOptions"/> <class name="LArG4TBPosOptions"/> <class name="LArGeoTBGeometricOptions"/> <class name="LArGeoTBH1GeoOptions"/> diff --git a/LArCalorimeter/LArG4/LArG4RunControl/cmt/requirements b/LArCalorimeter/LArG4/LArG4RunControl/cmt/requirements deleted file mode 100755 index e4cb89f74adc..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/cmt/requirements +++ /dev/null @@ -1,30 +0,0 @@ -package LArG4RunControl - -author Joe Boudreau - -use AtlasPolicy AtlasPolicy-* -use AtlasCLHEP AtlasCLHEP-* External -use CLIDSvc CLIDSvc-* Control - -private -use AtlasReflex AtlasReflex-* External -use GaudiInterface GaudiInterface-* External -use StoreGate StoreGate-* Control -end_private - - -library LArG4RunControl *.cxx -apply_pattern installed_library - -private - -use AtlasReflex AtlasReflex-* External - -apply_pattern lcgdict dict=LArG4RunControl \ - headerfiles="../LArG4RunControl/LArG4RunControlDict.h" \ - selectionfile=selection.xml -macro_prepend LArG4RunControlDict_shlibflags " -lLArG4RunControl " - -# Disable the usage of --as-needed in the linking of the package's libraries: -apply_pattern cmake_add_command \ - command='string(REPLACE "-Wl,--as-needed" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")' diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4BarrelOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4BarrelOptions.cxx deleted file mode 100755 index dbbd22fc44d9..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4BarrelOptions.cxx +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4RunControl/LArG4BarrelOptions.h" - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" - - -void LArG4BarrelOptions::saveMe() -{ - IService* pSvc; - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode result = svcLocator->service("DetectorStore",pSvc); - - if(result.isSuccess()) - { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArG4BarrelOptions"); - - if(!result.isSuccess()) - std::cout << "Can not record LArG4BarrelOptions" << std::endl; - - } -} - -void LArG4BarrelOptions::printMe() -{ - std::cout << " *** *** This is the object of type LArG4BarrelOptions *** *** \n"; - std::cout << " ** EMBCurr = " << (m_EMBCurr ? "true" : "false") << "\n"; - std::cout << " ** EMBEtaTrans = " << (m_EMBEtaTrans ? "true" : "false") << "\n"; - std::cout << " ** EMBXtalk = " << (m_EMBXtalk ? "true" : "false") << "\n"; - std::cout << " ** EMBTimeCurr = " << (m_EMBTimeCurr ? "true" : "false") << "\n"; - std::cout << " ** EMBTimeShower = " << (m_EMBTimeShower ? "true" : "false") << "\n"; - std::cout << " ** EMBTimeProp = " << (m_EMBTimeProp ? "true" : "false") << "\n"; - std::cout << " ** EMBdstep = " << m_EMBdstep << "\n *** *** \n"; - std::cout << " ** EMBBirksLaw = " << (m_EMBBirksLaw ? "true" : "false") << "\n"; - std::cout << "** EMBBirksk = " << m_EMBBirksk << "\n *** *** \n"; - std::cout << "** EMBHVEnable = " << m_EMBHVEnable << "\n *** *** \n"; -} diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4EMECOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4EMECOptions.cxx deleted file mode 100755 index 3b07ff987ca5..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4EMECOptions.cxx +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4RunControl/LArG4EMECOptions.h" - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" - -void LArG4EMECOptions::saveMe() -{ - IService* pSvc; - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode result = svcLocator->service("DetectorStore",pSvc); - - if(result.isSuccess()) - { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArG4EMECOptions"); - - if(!result.isSuccess()) - std::cout << "Can not record LArG4EMECOptions" << std::endl; - } -} - -void LArG4EMECOptions::printMe() -{ - std::cout << " *** *** This is the object of type LArG4EMECOptions *** *** \n"; - std::string x; - if(m_EMECECorrType == NONE) x="NONE(=0)"; - if(m_EMECECorrType == CHCOLL) x="CHCOLL(=1)"; - if(m_EMECECorrType == GAPADJ) x="GAPADJ(=3)"; - if(m_EMECECorrType == GAPOLD) x="GAPOLD(=2"; - if(m_EMECECorrType == GAP_E) x="GAP_E(=4)"; - if(m_EMECECorrType == GAP_S) x="GAP_S(=5)"; - if(m_EMECECorrType == GAP_SE) x="GAP_SE(6)"; - if(m_EMECECorrType == CHCOLL1) x="CHCOLL1(7)"; - std::cout << " ** EMECECorrType = " << x << "\n"; - std::cout << " ** EMECGapPower = " << m_EMECGapPower << "\n"; - std::cout << " ** EMECChMap = " << m_EMECChMap << "\n"; - std::cout << " ** EMECHVMap = " << m_EMECHVMap << "\n"; - std::cout << " ** EMECEsr = " << m_EMECEsr << "\n"; -#ifdef LARWHEELCALCULATOR_PSA_DEVELOPMENT - std::cout << " ** EMECFoldA = " << m_EMECFoldA << "\n"; -#endif - std::cout << " ** EMECBirksLaw = " << (m_EMECBirksLaw ? "true" : "false") << "\n"; - std::cout << "** EMECBirksk = " << m_EMECBirksk << "\n *** *** \n"; - std::cout << "** EMECHVEnable = " << m_EMECHVEnable << "\n *** *** \n"; - - - // std::cout << " ** EMECPhiRotation = " << m_EMECPhiRotation << "\n"; - //std::cout << " ** EMECSagging = " << m_EMECSagging << "\n"; - //std::cout << " ** EMECInnerSlantParam = " << m_EMECInnerSlantParam << "\n"; - //std::cout << " ** EMECOuterSlantParam = " << m_EMECOuterSlantParam << "\n *** *** \n"; -} diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4FCALOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4FCALOptions.cxx deleted file mode 100644 index 66b26b40b9d6..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4FCALOptions.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4RunControl/LArG4FCALOptions.h" - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" - - -void LArG4FCALOptions::saveMe() -{ - IService* pSvc; - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode result = svcLocator->service("DetectorStore",pSvc); - - if(result.isSuccess()) - { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArG4FCALOptions"); - - if(!result.isSuccess()) - std::cout << "Can not record LArG4FCALOptions" << std::endl; - - } -} - -void LArG4FCALOptions::printMe() -{ - std::cout << " ** FCALBirksLaw = " << (m_FCALBirksLaw ? "true" : "false") << "\n"; - std::cout << " ** FCALBirksk = " << m_FCALBirksk << "\n *** *** \n"; - std::cout << " ** FCALHVEnable = " << m_FCALHVEnable << "\n *** *** \n"; -} diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4GlobalOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4GlobalOptions.cxx deleted file mode 100755 index d502e8db6f90..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4GlobalOptions.cxx +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4RunControl/LArG4GlobalOptions.h" - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" - - -void LArG4GlobalOptions::saveMe() -{ - IService* pSvc; - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode result = svcLocator->service("DetectorStore",pSvc); - - if(result.isSuccess()) - { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArG4GlobalOptions"); - if(!result.isSuccess()) - std::cout << "Can not record LArG4BarrelOptions" << std::endl; - - } -} - -void LArG4GlobalOptions::printMe() -{ - std::cout << " *** *** This is the object of type LArG4GlobalOptions *** *** \n"; - std::cout << " ** OutOfTimeCut = " << m_OutOfTimeCut << "\n *** *** \n"; -} diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4HECOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4HECOptions.cxx deleted file mode 100755 index c93d574c4837..000000000000 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4HECOptions.cxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4RunControl/LArG4HECOptions.h" - -#include "GaudiKernel/ISvcLocator.h" -#include "GaudiKernel/Bootstrap.h" -#include "StoreGate/StoreGateSvc.h" - - -void LArG4HECOptions::saveMe() -{ - IService* pSvc; - ISvcLocator* svcLocator = Gaudi::svcLocator(); - StatusCode result = svcLocator->service("DetectorStore",pSvc); - - if(result.isSuccess()) - { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArG4HECOptions"); - - if(!result.isSuccess()) - std::cout << "Can not record LArG4HECOptions" << std::endl; - - } -} - -void LArG4HECOptions::printMe() -{ - std::cout << " ** HECBirksLaw = " << (m_HECBirksLaw ? "true" : "false") << "\n"; - std::cout << " ** HECBirksk = " << m_HECBirksk << "\n *** *** \n"; - std::cout << " ** HECHVEnable = " << m_HECHVEnable << "\n *** *** \n"; -} diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4TBPosOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4TBPosOptions.cxx index 1ad6a0c1948b..6ceca25f1616 100755 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4TBPosOptions.cxx +++ b/LArCalorimeter/LArG4/LArG4RunControl/src/LArG4TBPosOptions.cxx @@ -16,10 +16,14 @@ void LArG4TBPosOptions::saveMe() if(result.isSuccess()) { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArG4TBPosOptions"); + StoreGateSvc* detStore = dynamic_cast<StoreGateSvc*>(pSvc); + if (!detStore){ + std::cout << "LArG4TBPosOptions::saveMe ERROR Could not dynamic cast det store" << std::endl; + return; + } + result=detStore->record(this,"LArG4TBPosOptions"); if(!result.isSuccess()) - std::cout << "Can not record LArG4BarrelOptions" << std::endl; + std::cout << "Can not record LArG4TBPosOptions" << std::endl; } } diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTB2004Options.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTB2004Options.cxx index c61db7772cb9..e3d3b5c34024 100644 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTB2004Options.cxx +++ b/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTB2004Options.cxx @@ -16,8 +16,12 @@ void LArGeoTB2004Options::saveMe() if(result.isSuccess()) { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArGeoTB2004Options"); + StoreGateSvc* detStore = dynamic_cast<StoreGateSvc*>(pSvc); + if (!detStore){ + std::cout << "LArGeoTB2004Options::saveMe ERROR Could not dynamic cast det store" << std::endl; + return; + } + result=detStore->record(this,"LArGeoTB2004Options"); if(!result.isSuccess()) std::cout << "Can not record LArGeoTB2004Options" << std::endl; } diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBGeometricOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBGeometricOptions.cxx index 514c6a7fec93..4cf779a0d596 100755 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBGeometricOptions.cxx +++ b/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBGeometricOptions.cxx @@ -16,8 +16,12 @@ void LArGeoTBGeometricOptions::saveMe() if(result.isSuccess()) { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArGeoTBGeometricOptions"); + StoreGateSvc* detStore = dynamic_cast<StoreGateSvc*>(pSvc); + if (!detStore){ + std::cout << "LArGeoTBGeometricOptions::saveMe ERROR Could not dynamic cast det store" << std::endl; + return; + } + result=detStore->record(this,"LArGeoTBGeometricOptions"); if(!result.isSuccess()) std::cout << "Can not record LArGeoTBGeometricOptions" << std::endl; } diff --git a/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBH1GeoOptions.cxx b/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBH1GeoOptions.cxx index ca5fc9bd2c7f..952ad5b69b5e 100755 --- a/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBH1GeoOptions.cxx +++ b/LArCalorimeter/LArG4/LArG4RunControl/src/LArGeoTBH1GeoOptions.cxx @@ -16,8 +16,12 @@ void LArGeoTBH1GeoOptions::saveMe() if(result.isSuccess()) { - StoreGateSvc* m_detStore = dynamic_cast<StoreGateSvc*>(pSvc); - result=m_detStore->record(this,"LArGeoTBH1GeoOptions"); + StoreGateSvc* detStore = dynamic_cast<StoreGateSvc*>(pSvc); + if (!detStore){ + std::cout << "LArGeoTBH1GeoOptions::saveMe ERROR Could not dynamic cast det store" << std::endl; + return; + } + result=detStore->record(this,"LArGeoTBH1GeoOptions"); if(!result.isSuccess()) std::cout << "Can not record LArGeoTBH1GeoOptions" << std::endl; } diff --git a/LArCalorimeter/LArG4/LArG4SD/CMakeLists.txt b/LArCalorimeter/LArG4/LArG4SD/CMakeLists.txt index d5499d64e51f..a0e41afc27a9 100644 --- a/LArCalorimeter/LArG4/LArG4SD/CMakeLists.txt +++ b/LArCalorimeter/LArG4/LArG4SD/CMakeLists.txt @@ -8,17 +8,8 @@ atlas_subdir( LArG4SD ) # Declare the package's dependencies: atlas_depends_on_subdirs( PRIVATE Calorimeter/CaloG4Sim - Calorimeter/CaloSimEvent - Control/CxxUtils - Control/StoreGate GaudiKernel - LArCalorimeter/LArG4/LArG4Barrel - LArCalorimeter/LArG4/LArG4Code - LArCalorimeter/LArG4/LArG4EC - LArCalorimeter/LArG4/LArG4FCAL - LArCalorimeter/LArG4/LArG4HEC - LArCalorimeter/LArG4/LArG4MiniFCAL - LArCalorimeter/LArSimEvent ) + LArCalorimeter/LArG4/LArG4Code ) # External dependencies: find_package( CLHEP ) @@ -30,9 +21,8 @@ atlas_add_component( LArG4SD src/*.cc src/components/*.cxx INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} CaloG4SimLib CaloSimEvent CxxUtils StoreGateLib SGtests GaudiKernel LArG4Barrel LArG4Code LArG4EC LArG4FCAL LArG4HEC LArG4MiniFCAL LArSimEvent ) + LINK_LIBRARIES ${GEANT4_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} CaloG4SimLib GaudiKernel LArG4Code ) # Install files from the package: -atlas_install_headers( LArG4SD ) +#atlas_install_headers( LArG4SD ) atlas_install_python_modules( python/*.py ) - diff --git a/LArCalorimeter/LArG4/LArG4SD/cmt/requirements b/LArCalorimeter/LArG4/LArG4SD/cmt/requirements index 11b2470de8b9..07f677ee1f65 100644 --- a/LArCalorimeter/LArG4/LArG4SD/cmt/requirements +++ b/LArCalorimeter/LArG4/LArG4SD/cmt/requirements @@ -6,34 +6,13 @@ use AtlasPolicy AtlasPolicy-* private use GaudiInterface GaudiInterface-* External - -use LArG4Barrel LArG4Barrel-* LArCalorimeter/LArG4 -use LArG4EC LArG4EC-* LArCalorimeter/LArG4 -use LArG4FCAL LArG4FCAL-* LArCalorimeter/LArG4 -use LArG4HEC LArG4HEC-* LArCalorimeter/LArG4 -use LArG4MiniFCAL LArG4MiniFCAL-* LArCalorimeter/LArG4 -#use LArG4RunControl LArG4RunControl-* LArCalorimeter/LArG4 -#use MCTruth MCTruth-* Simulation/G4Sim -#use CaloIdentifier CaloIdentifier-* Calorimeter use CaloG4Sim CaloG4Sim-* Calorimeter -#use G4AtlasTools G4AtlasTools-* Simulation/G4Atlas -#use Geant4 Geant4-* External use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -#use AtlasCLHEP AtlasCLHEP-* External - -# Needed to create hit collections. -use LArSimEvent LArSimEvent-* LArCalorimeter -use CaloSimEvent CaloSimEvent-* Calorimeter -use StoreGate StoreGate-* Control -use CxxUtils CxxUtils-* Control +use AtlasCLHEP AtlasCLHEP-* External use Geant4 Geant4-* External -public - -apply_pattern declare_python_modules files="*.py" +public library LArG4SD *.cc components/*.cxx apply_pattern component_library -#library LArG4SD *.cc -#apply_pattern installed_library - +apply_pattern declare_python_modules files="*.py" diff --git a/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfig.py b/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfig.py index 704078df253e..4d6c37e8067d 100644 --- a/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfig.py +++ b/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfig.py @@ -24,7 +24,7 @@ def getLArActiveSensitiveDetector(name="LArActiveSensitiveDetector", **kwargs): kwargs.setdefault("ParticleID",simFlags.ParticleID()) # No effect currently kwargs.setdefault("OutputCollectionNames", ["LArCalibrationHitActive"]) - return CfgMgr.LArG4ActiveSDTool(name, **kwargs) + return CfgMgr.LArG4__ActiveSDTool(name, **kwargs) def getLArDeadSensitiveDetector(name="LArDeadSensitiveDetector", **kwargs): ## Main configuration @@ -112,7 +112,7 @@ def getLArDeadSensitiveDetector(name="LArDeadSensitiveDetector", **kwargs): kwargs.setdefault("doEscapedEnergy",simFlags.CalibrationRun.get_Value()!='DeadLAr') # No effect currently kwargs.setdefault("OutputCollectionNames", ["LArCalibrationHitDeadMaterial"]) - return CfgMgr.LArG4DeadSDTool(name, **kwargs) + return CfgMgr.LArG4__DeadSDTool(name, **kwargs) def getLArEMBSensitiveDetector(name="LArEMBSensitiveDetector", **kwargs): ## Main configuration @@ -123,7 +123,7 @@ def getLArEMBSensitiveDetector(name="LArEMBSensitiveDetector", **kwargs): # Hook for fast simulation from G4AtlasApps.SimFlags import simFlags kwargs.setdefault("UseFrozenShowers", simFlags.LArParameterization()>0) - return CfgMgr.LArG4EMBSDTool(name, **kwargs) + return CfgMgr.LArG4__EMBSDTool(name, **kwargs) def getLArEMECSensitiveDetector(name="LArEMECSensitiveDetector", **kwargs): from G4AtlasApps.SimFlags import simFlags @@ -139,7 +139,7 @@ def getLArEMECSensitiveDetector(name="LArEMECSensitiveDetector", **kwargs): kwargs.setdefault("OutputCollectionNames", ["LArHitEMEC"]) # Hook for fast simulation kwargs.setdefault("UseFrozenShowers", simFlags.LArParameterization()>0) - return CfgMgr.LArG4EMECSDTool(name, **kwargs) + return CfgMgr.LArG4__EMECSDTool(name, **kwargs) def getLArFCALSensitiveDetector(name="LArFCALSensitiveDetector", **kwargs): kwargs.setdefault("FCAL1Volumes",["LArMgr::LAr::FCAL::Module1::Gap"]) @@ -150,7 +150,7 @@ def getLArFCALSensitiveDetector(name="LArFCALSensitiveDetector", **kwargs): # Hook for fast simulation from G4AtlasApps.SimFlags import simFlags kwargs.setdefault("UseFrozenShowers", simFlags.LArParameterization()>0) - return CfgMgr.LArG4FCALSDTool(name, **kwargs) + return CfgMgr.LArG4__FCALSDTool(name, **kwargs) def getLArHECSensitiveDetector(name="LArHECSensitiveDetector", **kwargs): #kwargs.setdefault("SliceVolumes",["LAr::HEC::Module::Depth::Slice"]) @@ -159,7 +159,7 @@ def getLArHECSensitiveDetector(name="LArHECSensitiveDetector", **kwargs): # You might think this should go here, but we don't think so! LAr::HEC::Module::Depth::Slice::Wheel"]) # No effect currently kwargs.setdefault("OutputCollectionNames", ["LArHitHEC"]) - return CfgMgr.LArG4HECSDTool(name, **kwargs) + return CfgMgr.LArG4__HECSDTool(name, **kwargs) def getLArInactiveSensitiveDetector(name="LArInactiveSensitiveDetector", **kwargs): ## Main configuration @@ -220,11 +220,13 @@ def getLArInactiveSensitiveDetector(name="LArInactiveSensitiveDetector", **kwarg kwargs.setdefault("ParticleID",simFlags.ParticleID()) # No effect currently kwargs.setdefault("OutputCollectionNames", ["LArCalibrationHitInactive"]) - return CfgMgr.LArG4InactiveSDTool(name, **kwargs) + return CfgMgr.LArG4__InactiveSDTool(name, **kwargs) def getLArMiniFCALSensitiveDetector(name="LArMiniFCALSensitiveDetector", **kwargs): kwargs.setdefault("MiniVolumes",["LArMgr::MiniFCAL::Wafer"]) # No effect currently kwargs.setdefault("OutputCollectionNames", ["LArHitMiniFCAL"]) - return CfgMgr.LArG4MiniFCALSDTool(name, **kwargs) + return CfgMgr.LArG4__MiniFCALSDTool(name, **kwargs) +def getCalibrationDefaultCalculator(name="CalibrationDefaultCalculator", **kwargs): + return CfgMgr.LArG4__CalibrationDefaultCalculator(name, **kwargs) diff --git a/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfigDb.py b/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfigDb.py index a50d8e5565ba..952acf3bec8d 100644 --- a/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfigDb.py +++ b/LArCalorimeter/LArG4/LArG4SD/python/LArG4SDConfigDb.py @@ -1,6 +1,6 @@ # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -from AthenaCommon.CfgGetter import addTool +from AthenaCommon.CfgGetter import addTool, addService addTool("LArG4SD.LArG4SDConfig.getLArActiveSensitiveDetector","LArActiveSensitiveDetector") addTool("LArG4SD.LArG4SDConfig.getLArDeadSensitiveDetector","LArDeadSensitiveDetector") addTool("LArG4SD.LArG4SDConfig.getLArEMBSensitiveDetector","LArEMBSensitiveDetector") @@ -10,3 +10,4 @@ addTool("LArG4SD.LArG4SDConfig.getLArHECSensitiveDetector","LArHECSensitiveDetec addTool("LArG4SD.LArG4SDConfig.getLArInactiveSensitiveDetector","LArInactiveSensitiveDetector") addTool("LArG4SD.LArG4SDConfig.getLArMiniFCALSensitiveDetector","LArMiniFCALSensitiveDetector") +addService("LArG4SD.LArG4SDConfig.getCalibrationDefaultCalculator","CalibrationDefaultCalculator") diff --git a/LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.cc new file mode 100644 index 000000000000..0f6372e12c64 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.cc @@ -0,0 +1,113 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "ActiveSDTool.h" + +#include "LArG4Code/SDWrapper.h" + + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + ActiveSDTool::ActiveSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : CalibSDTool(type, name, parent) + , m_hitCollName("LArCalibrationHitActive") + , m_bpsmodcalc("BarrelPresamplerCalibrationCalculator", name) + , m_embcalc("BarrelCalibrationCalculator", name) + , m_emepiwcalc("EMECPosInnerWheelCalibrationCalculator", name) + , m_emeniwcalc("EMECNegInnerWheelCalibrationCalculator", name) + , m_emepowcalc("EMECPosOuterWheelCalibrationCalculator", name) + , m_emenowcalc("EMECNegOuterWheelCalibrationCalculator", name) + , m_emepscalc("EMECPresamplerCalibrationCalculator", name) + , m_emeobarcalc("EMECBackOuterBarretteCalibrationCalculator", name) + , m_heccalc("HECCalibrationWheelActiveCalculator", name) + , m_fcal1calc("FCAL1CalibCalculator", name) + , m_fcal2calc("FCAL2CalibCalculator", name) + , m_fcal3calc("FCAL3CalibCalculator", name) + , m_minfcalcalc("MiniFCALActiveCalibrationCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("StacVolumes", m_stacVolumes); + declareProperty("PresamplerVolumes", m_presBarVolumes); + declareProperty("PosIWVolumes", m_posIWVolumes); + declareProperty("NegIWVolumes", m_negIWVolumes); + declareProperty("PosOWVolumes", m_posOWVolumes); + declareProperty("NegOWVolumes", m_negOWVolumes); + declareProperty("PresVolumes", m_presECVolumes); + declareProperty("BOBarretteVolumes", m_bobVolumes); + declareProperty("FCAL1Volumes", m_fcal1Volumes); + declareProperty("FCAL2Volumes", m_fcal2Volumes); + declareProperty("FCAL3Volumes", m_fcal3Volumes); + declareProperty("SliceVolumes", m_sliceVolumes); + declareProperty("MiniVolumes", m_miniVolumes); + + declareProperty("EMBPSCalibrationCalculator",m_bpsmodcalc); + declareProperty("EMBCalibrationCalculator",m_embcalc); + declareProperty("EMECPosIWCalibrationCalculator",m_emepiwcalc); + declareProperty("EMECNegIWCalibrationCalculator",m_emeniwcalc); + declareProperty("EMECPosOWCalibrationCalculator",m_emepowcalc); + declareProperty("EMECNegOWCalibrationCalculator",m_emenowcalc); + declareProperty("EMECPSCalibrationCalculator",m_emepscalc); + declareProperty("EMECBOBCalibrationCalculator",m_emeobarcalc); + declareProperty("HECWActiveCalculator",m_heccalc); + declareProperty("FCAL1CalibCalculator",m_fcal1calc); + declareProperty("FCAL2CalibCalculator",m_fcal2calc); + declareProperty("FCAL3CalibCalculator",m_fcal3calc); + declareProperty("MiniFCALActiveCalibrationCalculator",m_minfcalcalc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode ActiveSDTool::initializeCalculators() + { + // Lots of calculators !!! + ATH_CHECK(m_bpsmodcalc.retrieve()); + ATH_CHECK(m_embcalc.retrieve()); + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_emeniwcalc.retrieve()); + ATH_CHECK(m_emepowcalc.retrieve()); + ATH_CHECK(m_emenowcalc.retrieve()); + ATH_CHECK(m_emepscalc.retrieve()); + ATH_CHECK(m_emeobarcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcal3calc.retrieve()); + ATH_CHECK(m_minfcalcalc.retrieve()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create SD wrapper for current thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* ActiveSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("LArActiveSDWrapper", m_hitCollName); + + // Create the SDs. + sdWrapper->addSD( makeOneSD( "Barrel::Presampler::Module::Calibration", &*m_bpsmodcalc, m_presBarVolumes ) ); + sdWrapper->addSD( makeOneSD( "EMB::STAC::Calibration", &*m_embcalc, m_stacVolumes ) ); + sdWrapper->addSD( makeOneSD( "EMEC::Pos::InnerWheel::Calibration", &*m_emepiwcalc, m_posIWVolumes ) ); + sdWrapper->addSD( makeOneSD( "EMEC::Neg::InnerWheel::Calibration", &*m_emeniwcalc, m_negIWVolumes ) ); + sdWrapper->addSD( makeOneSD( "EMEC::Pos::OuterWheel::Calibration", &*m_emepowcalc, m_posOWVolumes ) ); + sdWrapper->addSD( makeOneSD( "EMEC::Neg::OuterWheel::Calibration", &*m_emenowcalc, m_negOWVolumes ) ); + sdWrapper->addSD( makeOneSD( "Endcap::Presampler::LiquidArgon::Calibration", &*m_emepscalc, m_presECVolumes ) ); + sdWrapper->addSD( makeOneSD( "EMEC::BackOuterBarrette::Calibration", &*m_emeobarcalc, m_bobVolumes ) ); + sdWrapper->addSD( makeOneSD( "FCAL::Module1::Gap::Calibration", &*m_fcal1calc, m_fcal1Volumes ) ); + sdWrapper->addSD( makeOneSD( "FCAL::Module2::Gap::Calibration", &*m_fcal2calc, m_fcal2Volumes ) ); + sdWrapper->addSD( makeOneSD( "FCAL::Module3::Gap::Calibration", &*m_fcal3calc, m_fcal3Volumes ) ); + sdWrapper->addSD( makeOneSD( "HEC::Module::Depth::Slice::Wheel::Calibration", &*m_heccalc, m_sliceVolumes ) ); + sdWrapper->addSD( makeOneSD( "MiniFCAL::Wafer", &*m_minfcalcalc, m_miniVolumes ) ); + + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.h new file mode 100644 index 000000000000..2c0bd8b827e7 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/ActiveSDTool.h @@ -0,0 +1,78 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_ACTIVESDTOOL_H +#define LARG4SD_ACTIVESDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/CalibSDTool.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class ActiveSDTool + /// @brief Sensitive detector tool which manages activate-area LAr calib SDs. + /// + /// Design is in flux. + /// + class ActiveSDTool : public CalibSDTool + { + + public: + + /// Constructor + ActiveSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// @name SD volumes + /// @{ + std::vector<std::string> m_stacVolumes; + std::vector<std::string> m_presBarVolumes; + std::vector<std::string> m_posIWVolumes; + std::vector<std::string> m_negIWVolumes; + std::vector<std::string> m_posOWVolumes; + std::vector<std::string> m_negOWVolumes; + std::vector<std::string> m_presECVolumes; + std::vector<std::string> m_bobVolumes; + std::vector<std::string> m_fcal1Volumes; + std::vector<std::string> m_fcal2Volumes; + std::vector<std::string> m_fcal3Volumes; + std::vector<std::string> m_sliceVolumes; + std::vector<std::string> m_miniVolumes; + /// @} + + ServiceHandle<ILArCalibCalculatorSvc> m_bpsmodcalc; //LArG4::BarrelPresampler::CalibrationCalculator + ServiceHandle<ILArCalibCalculatorSvc> m_embcalc; //LArG4::Barrel::CalibrationCalculator + ServiceHandle<ILArCalibCalculatorSvc> m_emepiwcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, 1) + ServiceHandle<ILArCalibCalculatorSvc> m_emeniwcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, -1) + ServiceHandle<ILArCalibCalculatorSvc> m_emepowcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, 1) + ServiceHandle<ILArCalibCalculatorSvc> m_emenowcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, -1) + ServiceHandle<ILArCalibCalculatorSvc> m_emepscalc; //LArG4::EC::PresamplerCalibrationCalculator + ServiceHandle<ILArCalibCalculatorSvc> m_emeobarcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::BackOuterBarretteWheelCalib, 1) + ServiceHandle<ILArCalibCalculatorSvc> m_heccalc; //LArG4::HEC::LArHECCalibrationWheelCalculator(LArG4::HEC::kWheelActive) + ServiceHandle<ILArCalibCalculatorSvc> m_fcal1calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal2calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal3calc; + ServiceHandle<ILArCalibCalculatorSvc> m_minfcalcalc; //LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kActive) + }; // class ActiveSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.cc b/LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.cc new file mode 100644 index 000000000000..738b8927d8b1 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.cc @@ -0,0 +1,309 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// LArG4::CalibrationDefaultCalculator +// Prepared 04-Mar-2004 Bill Seligman +// Modified 22-Sep-2004 Mikhail Leltchouk + +// The calibration studies rely on every volume in the simulation +// being made into a sensitive detector. There is a practical +// problem: What if we're still in the middle of developing code, and +// not every volume has been made sensitive yet? What if we've +// overlooked a volume? Or (the most common case), what if we have an +// energy deposit in a volume that is not being directly calibrated? + +// This class provides a "default behavior" for all energy deposits +// that are not made in a volume that's been made sensitive for +// calibration studies. + +// This class calculates the values needed for calibration hits in the +// simulation. + +#undef DEBUG_HITS +#undef DEBUG_VOLUMES + +#include "CalibrationDefaultCalculator.h" +#include "LArG4Code/LArG4Identifier.h" + +#include "G4ThreeVector.hh" +#include "G4Step.hh" +#include "globals.hh" +#include "CLHEP/Units/PhysicalConstants.h" + +#include <cmath> +#include <string> +#include <climits> +#include <algorithm> +#include <set> +#include <numeric> + +#undef DEBUG_DMXYZ + +namespace LArG4 { + + CalibrationDefaultCalculator::CalibrationDefaultCalculator(const std::string& name, ISvcLocator *pSvcLocator) + : LArCalibCalculatorSvcImp(name, pSvcLocator) + { + } + + + CalibrationDefaultCalculator::~CalibrationDefaultCalculator() + { + } + + G4bool CalibrationDefaultCalculator::Process (const G4Step* a_step, + LArG4Identifier & _identifier, + std::vector<G4double> & _energies, + const eCalculatorProcessing a_process) const + { + // Use the calculators to determine the energies and the + // identifier associated with this G4Step. Note that the + // default is to process both the energy and the ID. + + _energies.clear(); + if ( a_process == kEnergyAndID || a_process == kOnlyEnergy ) + { + m_energyCalculator.Energies( a_step, _energies ); + } + else { + for (unsigned int i=0; i != 4; i++) _energies.push_back(0.); + } + + _identifier.clear(); + if ( a_process == kEnergyAndID || a_process == kOnlyID ) + { + // Call after volume-by-volume calls only if none of these calls assigned + // the SimulationEnergies::Energies of current step to identifier and one + // of the existing hit collections. + + // Calculate the mid-point of the step, and the simple geometry variables. + + const G4StepPoint* pre_step_point = a_step->GetPreStepPoint(); + const G4StepPoint* post_step_point = a_step->GetPostStepPoint(); + + const G4ThreeVector startPoint = pre_step_point->GetPosition(); + const G4ThreeVector endPoint = post_step_point->GetPosition(); + const G4ThreeVector p = (startPoint + endPoint) * 0.5; + + const G4double rho = p.perp(); + const G4double eta = fabs( p.pseudoRapidity() ); + G4double phi = p.phi(); + if ( phi<0. ) { phi += 2.*M_PI; } // Normalize for phiBin calculation + + const G4int detector = 10; // calorimeter "dead" materials + + // Initialize identifier variables with (invalid) default + // values (INT_MIN is defined in <climits>). + G4int subdet = INT_MIN; + G4int type = INT_MIN; + G4int sampling = INT_MIN; + G4int region = INT_MIN; + G4int etaBin = INT_MIN; + G4int phiBin = INT_MIN; + + if ( eta > 5. ) // "forward" leakage + { + // subdet = +/-4, "+" or " -" according to sign of Z in World coorinate + subdet = ( p.z() > 0.) ? 4 : -4; + // type = 1, sampling = 3 leakage outside calorimeters: + type = 1; + sampling = 3; + if ( eta < 8.) // leakage between eta = 5 and 8 + { + region = 1; + etaBin = (int) ( ( eta - 5. ) * 0.5 * m_oneOverDeta ); + phiBin = (int) ( phi * m_oneOverDphi ); + if (phiBin>m_phiBinMax) phiBin=m_phiBinMax; + } + else // "very forward" leakage eta >= 8. + { + region = 2; + etaBin = 0; // no eta-phi subdivision + phiBin = 0; + } + } + else if ( rho > m_rhoCalorOut || fabs( p.z() ) > m_zCalorOut ) + { + // type = 1, sampling = 3 leakage outside calorimeters: + type = 1; + sampling = 3; + region = 0; + phiBin = (int) ( phi * m_oneOverDphi ); + if (phiBin>m_phiBinMax) phiBin=m_phiBinMax; + + if ( eta < 1.7) // leakage outside Tile + { + // subdet = +/-5, "+" or " -" according to sign of Z in World coorinate + subdet = ( p.z() > 0.) ? 5 : -5; + etaBin = (int) ( eta * m_oneOverDeta ); + } + else // leakage outside LAr HEC + { + // subdet = +/-4, "+" or " -" according to sign of Z in World coorinate + subdet = ( p.z() > 0.) ? 4 : -4; + etaBin = (int) ( ( eta - 1.7 ) * m_oneOverDeta ); + } // outside at eta covered by Tile or by LAr HEC + + } // leakage outside calorimeters: + + else if ( rho < m_rhoInDetOut && fabs( p.z() ) < m_zInDetOut ) + + { + subdet = ( p.z() > 0.) ? 4 : -4; + // type = 1, sampling = 0, region = 1-5 => Inner Detector + type = 1; + sampling = 0; + region = 5; // TRT support, cables, services + if ( rho < 980.*CLHEP::mm ) region = 4; // TRT + if ( rho < 650.*CLHEP::mm ) region = 3; // support + if ( rho < 540.*CLHEP::mm ) region = 2; // SCT + if ( rho < 270.*CLHEP::mm ) region = 1; // Pixels with support, beam pipe + etaBin = (int) ( eta * m_oneOverDeta ); + phiBin = (int) ( phi * m_oneOverDphi ); + if (phiBin>m_phiBinMax) phiBin=m_phiBinMax; + + // g.p. 23.05.2011 beam pipe material outside of inner detector area close to FCal + } else if( fabs( p.z() ) >= m_zInDetOut) { + subdet = ( p.z() > 0.) ? 4 : -4; + phiBin = (int) ( phi * m_oneOverDphi ); + if (phiBin>m_phiBinMax) phiBin=m_phiBinMax; + if(eta>=2.9 && eta<5.0) { + if(fabs(p.z()) < m_z1BeforeFCal) { + type = 1; + sampling = 1; + region = 7; + etaBin = (int) ( (eta-3.2) * m_oneOverDeta ); + } else if (fabs(p.z()) < m_z2BeforeFCal){ + type = 2; + sampling = 0; + region = 5; + etaBin = (int) ( (eta-3.0) * m_oneOverDeta ); + } else if (fabs(p.z()) < m_startZFCal1) { + type = 2; + sampling = 1; + region = 5; + etaBin = (int) ( (eta-3.0) * m_oneOverDeta ); + } + // g.p. back leakages in beam pipe + } else if ( eta >= 5. && eta < 8.0) { + type = 1; + sampling = 3; + region = 1; + etaBin = (int) ( (eta-5.)* 0.5 * m_oneOverDeta ); + } else if (eta>8.) { + type = 1; + sampling = 3; + region = 2; + etaBin = 0; + phiBin = 0; + } + if(etaBin<0) etaBin=0; + } + + + // If the point falls outside any of the above "if" + // statements, use a "none-of-the-above" identifier. + + if + ( subdet == INT_MIN || + type == INT_MIN || + sampling == INT_MIN || + region == INT_MIN || + etaBin == INT_MIN || + phiBin == INT_MIN ) + { +#if defined (DEBUG_VOLUMES) || defined (DEBUG_HITS) + static std::set<G4String> volumeList; + const G4String namePhys = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetName(); + const G4String nameLog = a_step->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume()->GetName(); + + std::set<G4String>::iterator i = volumeList.find( nameLog ); + if ( i == volumeList.end() ) + { + volumeList.insert( nameLog ); + std::cout << "LArG4::CalibrationDefaultCalculator::Process" + << std::endl + << " default ID used in logical volume '" + << nameLog + << "'" + << std::endl + << " (each such volume is only listed once)" + << std::endl; + } + + static const G4int messageMax = 10; + static G4int messageCount = 0; + if ( messageCount++ < messageMax ) + { + std::cout << " detailed error (" << messageCount + << " of " << messageMax << " max displayed):" + << std::endl + << " G4Step at unexpected place: (x,y,z) [mm] = (" + << p.x()/mm << "," + << p.y()/mm << "," + << p.z()/mm + << "), eta=" << eta + << ", phi=" << phi + << ", rho=" << rho + << std::endl + << " in physical volume '" << namePhys << "'" + << std::endl + << " (subdet,type,sampling,region,etaBin,phiBin)=(" + << subdet << "," + << type << "," + << sampling << "," + << region << "," + << etaBin << "," + << phiBin + << "); using default ID" + << std::endl; + } +#endif + subdet = ( p.z() > 0.) ? 4 : -4; + type = 1; + sampling = 0; + region = 0; + etaBin = (int) ( eta * m_oneOverDeta ); + if ( etaBin > 49 ) etaBin = 49; + phiBin = (int) ( phi * m_oneOverDphi ); + if (phiBin>m_phiBinMax) phiBin=m_phiBinMax; +#ifdef DEBUG_DMXYZ + G4double energy = std::accumulate(_energies.begin(),_energies.end(), 0.); + if(energy > 1e-15) LArG4::CalibrationDefaultCalculator::Print("UNEXP DefaultCalculator",_identifier,a_step,_energies); +#endif + } + + // Create the LArG4Identifier. + _identifier << detector + << subdet + << type + << sampling + << region + << etaBin + << phiBin; + } + +#ifdef DEBUG_HITS + G4double energy = accumulate(_energies.begin(),_energies.end(),0.); + std::cout << "LArG4::CalibrationDefaultCalculator::Process" + << " ID=" << std::string(_identifier) + << " energy=" << energy + << " energies=(" << _energies[0] + << "," << _energies[1] + << "," << _energies[2] + << "," << _energies[3] << ")" + << std::endl; +#endif +#ifdef DEBUG_DMXYZ +// LArG4::CalibrationDefaultCalculator::Print("DMXYZ DefaultCalculator",_identifier,a_step,_energies); +#endif + + // Check for bad result. + if ( _identifier == LArG4Identifier() ) + return false; + + return true; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationDefaultCalculator.h b/LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.h similarity index 56% rename from LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationDefaultCalculator.h rename to LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.h index 17477fe7b0c0..8972453352b5 100644 --- a/LArCalorimeter/LArG4/LArG4Code/LArG4Code/CalibrationDefaultCalculator.h +++ b/LArCalorimeter/LArG4/LArG4SD/src/CalibrationDefaultCalculator.h @@ -18,7 +18,7 @@ #ifndef LArG4_CalibrationDefaultCalculator_H #define LArG4_CalibrationDefaultCalculator_H -#include "LArG4Code/VCalibrationCalculator.h" +#include "LArG4Code/LArCalibCalculatorSvcImp.h" #include "LArG4Code/LArG4Identifier.h" #include "CaloG4Sim/SimulationEnergies.h" @@ -32,12 +32,14 @@ class G4Step; namespace LArG4 { - class CalibrationDefaultCalculator : public VCalibrationCalculator { + class CalibrationDefaultCalculator : public LArCalibCalculatorSvcImp { public: - - CalibrationDefaultCalculator(); + + CalibrationDefaultCalculator(const std::string& name, ISvcLocator *pSvcLocator); + StatusCode initialize() {return StatusCode::SUCCESS;} + StatusCode finalize() {return StatusCode::SUCCESS;} virtual ~CalibrationDefaultCalculator(); - + // The Process method returns a boolean value. If it's true, the // hit can be used by Geant4; if it's false, there's something wrong // with the energy deposit and it should be ignored. @@ -49,25 +51,31 @@ namespace LArG4 { // can never tell). Use the enum to control any special // processing. - virtual G4bool Process (const G4Step*, - const eCalculatorProcessing = kEnergyAndID); - - // The cell identifier determined by the Process method. - virtual const LArG4Identifier& identifier() const { return m_identifier; } - - // The calibration energies as determined by the Process method for - // the current G4Step. Units are the native G4 unit of energy. - virtual const std::vector<G4double>& energies() const { return m_energies; } + virtual G4bool Process (const G4Step* step, LArG4Identifier & identifier, + std::vector<G4double> & energies, + const eCalculatorProcessing p = kEnergyAndID) const override final; private: - // The results of the calculation. - LArG4Identifier m_identifier; - std::vector<G4double> m_energies; // The usual calibration energy calculator. CaloG4::SimulationEnergies m_energyCalculator; + // hardcoded numbers + const double m_oneOverDeta = 10.; // 1/Deta = 1./0.1 = 10. + const double m_oneOverDphi = 32./M_PI; // 1/Dphi + const int m_phiBinMax = 63; + const double m_rhoAlignmentSafety = 50.*CLHEP::mm; + const double m_zAlignmentSafety = 100.*CLHEP::mm; + const double m_rhoCalorOut = 3885.*CLHEP::mm - m_rhoAlignmentSafety; + const double m_zCalorOut = 6100.*CLHEP::mm - m_zAlignmentSafety; + const double m_rhoInDetOut = 1150.*CLHEP::mm + m_rhoAlignmentSafety; + const double m_zInDetOut = 3511.*CLHEP::mm + m_zAlignmentSafety; + const double m_startZFCal1 = 4668.5 - m_zAlignmentSafety; + const double m_z1BeforeFCal = 4225.5 + m_zAlignmentSafety; // + const double m_z2BeforeFCal = 4557.5 + m_zAlignmentSafety; // + + }; } // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.cc new file mode 100644 index 000000000000..c1212f206bc2 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.cc @@ -0,0 +1,137 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "DeadSDTool.h" + +#include "LArG4Code/SDWrapper.h" + +#include "CalibrationDefaultCalculator.h" + +// For escaped energy +#include "CaloG4Sim/EscapedEnergyRegistry.h" +#include "CaloG4Sim/CalibrationDefaultProcessing.h" +#include "LArG4Code/EscapedEnergyProcessing.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + DeadSDTool::DeadSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : CalibSDTool(type, name, parent) + , m_hitCollName("LArCalibrationHitDeadMaterial") + , m_embccalc("BarrelCryostatCalibrationCalculator", name) + , m_embclarcalc("BarrelCryostatCalibrationLArCalculator", name) + , m_mixcalc("BarrelCryostatCalibrationMixedCalculator", name) + , m_dmcalc("DMCalibrationCalculator", name) + , m_embpscalc("BarrelPresamplerCalibrationCalculator", name) + , m_embcalc("BarrelCalibrationCalculator", name) + , m_emeccalc("EndcapCryostatCalibrationCalculator", name) + , m_emecclarcalc("EndcapCryostatCalibrationLArCalculator", name) + , m_ememixcalc("EndcapCryostatCalibrationMixedCalculator", name) + , m_emesupcalc("EMECSupportCalibrationCalculator", name) + , m_heccalc("HECCalibrationWheelDeadCalculator", name) + , m_defcalc("CalibrationDefaultCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("BarrelCryVolumes", m_barCryVolumes); + declareProperty("BarrelCryLArVolumes", m_barCryLArVolumes); + declareProperty("BarrelCryMixVolumes", m_barCryMixVolumes); + declareProperty("DeadMaterialVolumes", m_DMVolumes); + declareProperty("BarrelPresVolumes", m_barPresVolumes); + declareProperty("BarrelVolumes", m_barVolumes); + declareProperty("ECCryVolumes", m_ECCryVolumes); + declareProperty("ECCryLArVolumes", m_ECCryLArVolumes); + declareProperty("ECCryMixVolumes", m_ECCryMixVolumes); + declareProperty("ECSupportVolumes", m_ECSupportVolumes); + declareProperty("HECWheelVolumes", m_HECWheelVolumes); + declareProperty("doEscapedEnergy", m_do_eep=false); + + declareProperty("EMBCryoCalibrationCalculator",m_embccalc); + declareProperty("EMBCryoLArCalibrationCalculator",m_embclarcalc); + declareProperty("EMBCryoMixCalibrationCalculator",m_mixcalc); + declareProperty("DMCalibrationCalculator",m_dmcalc); + declareProperty("EMBPSCalibrationCalculator",m_embpscalc); + declareProperty("EMBCalibrationCalculator",m_embcalc); + declareProperty("ECCryoCalibrationCalculator",m_emeccalc); + declareProperty("ECCryoLArCalibrationCalculator",m_emecclarcalc); + declareProperty("ECCryoMixCalibrationCalculator",m_ememixcalc); + declareProperty("EMECSuppCalibrationCalculator",m_emesupcalc); + declareProperty("HECWheelDeadCalculator",m_heccalc); + declareProperty("DefaultCalibrationCalculator",m_defcalc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode DeadSDTool::initializeCalculators() + { + // Lots of calculators !!! + ATH_CHECK(m_embccalc.retrieve()); + ATH_CHECK(m_embclarcalc.retrieve()); + ATH_CHECK(m_mixcalc.retrieve()); + ATH_CHECK(m_dmcalc.retrieve()); + ATH_CHECK(m_embpscalc.retrieve()); + ATH_CHECK(m_embcalc.retrieve()); + ATH_CHECK(m_emeccalc.retrieve()); + ATH_CHECK(m_emecclarcalc.retrieve()); + ATH_CHECK(m_ememixcalc.retrieve()); + ATH_CHECK(m_emesupcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + // Take care of the default material + if (m_do_eep) + { + ATH_CHECK(m_defcalc.retrieve()); + } + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create SDs for the current thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* DeadSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("LArDeadSDWrapper", m_hitCollName); + + // Create the SDs. + sdWrapper->addSD( makeOneSD("LArDead::BarrelCryostat::Dead", &*m_embccalc, m_barCryVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::BarrelCryostat::LAr::Dead", &*m_embclarcalc, m_barCryLArVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::BarrelCryostat::Mixed::Dead", &*m_mixcalc, m_barCryMixVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::DM::Dead", &*m_dmcalc, m_DMVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::Barrel::Presampler::Dead", &*m_embpscalc, m_barPresVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::Barrel::Dead", &*m_embcalc, m_barVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::EndcapCryostat::Dead", &*m_emeccalc, m_ECCryVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::EndcapCryostat::LAr::Dead", &*m_emecclarcalc, m_ECCryLArVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::EndcapCryostat::Mixed::Dead", &*m_ememixcalc, m_ECCryMixVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::EMECSupport::Dead", &*m_emesupcalc, m_ECSupportVolumes ) ); + sdWrapper->addSD( makeOneSD("LArDead::HEC::Wheel::Inactive", &*m_heccalc, m_HECWheelVolumes ) ); + + // Take care of the default material + if (m_do_eep) + { + const std::vector<std::string> noVolumes; + auto uninstSD = makeOneSD("Default::Dead::Uninstrumented::Calibration::Region", &*m_defcalc, noVolumes); + + // Initialize the escaped energy processing for LAr volumes. + // This is from initialize processing in the former LArG4CalibSD. + // I still think we can do better than this, though. + // FIXME: I don't think this is thread safe!! + ATH_MSG_DEBUG("Creating EscapedEnergyProcessing and adding to registry"); + CaloG4::VEscapedEnergyProcessing* eep = + new EscapedEnergyProcessing( uninstSD.get() ); + CaloG4::EscapedEnergyRegistry* registry = + CaloG4::EscapedEnergyRegistry::GetInstance(); + registry->AddAndAdoptProcessing( "LAr::", eep ); + + sdWrapper->addSD( std::move(uninstSD) ); + } + + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.h new file mode 100644 index 000000000000..2f1660269e36 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/DeadSDTool.h @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_DEADSDTOOL_H +#define LARG4SD_DEADSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/CalibSDTool.h" + +namespace LArG4 +{ + + class DeadSDTool : public CalibSDTool + { + + public: + + // Constructor + DeadSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// Do we add the escaped energy processing? + /// This is only in "mode 1" (Tile+LAr), not in "DeadLAr" mode + bool m_do_eep; + + // The volumes per SD, and the corresponding SDs + std::vector<std::string> m_barCryVolumes; + std::vector<std::string> m_barCryLArVolumes; + std::vector<std::string> m_barCryMixVolumes; + std::vector<std::string> m_DMVolumes; + std::vector<std::string> m_barPresVolumes; + std::vector<std::string> m_barVolumes; + std::vector<std::string> m_ECCryVolumes; + std::vector<std::string> m_ECCryLArVolumes; + std::vector<std::string> m_ECCryMixVolumes; + std::vector<std::string> m_ECSupportVolumes; + std::vector<std::string> m_HECWheelVolumes; + //LArG4CalibSD* m_barCrySD; + //LArG4CalibSD* m_barCryLArSD; + //LArG4CalibSD* m_barCryMixSD; + //LArG4CalibSD* m_DMSD; + //LArG4CalibSD* m_barPresSD; + //LArG4CalibSD* m_barSD; + //LArG4CalibSD* m_ECCrySD; + //LArG4CalibSD* m_ECCryLArSD; + //LArG4CalibSD* m_ECCryMixSD; + //LArG4CalibSD* m_ECSupportSD; + //LArG4CalibSD* m_HECWheelSD; + //LArG4CalibSD* m_uninstSD; + + ServiceHandle<ILArCalibCalculatorSvc> m_embccalc; //BarrelCryostat::CalibrationCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_embclarcalc; //BarrelCryostat::CalibrationLArCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_mixcalc; //BarrelCryostat::CalibrationMixedCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_dmcalc; //DM::CalibrationCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_embpscalc; //BarrelPresampler::CalibrationCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_embcalc; //Barrel::CalibrationCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_emeccalc; //EndcapCryostat::CalibrationCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_emecclarcalc; //EndcapCryostat::CalibrationLArCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_ememixcalc; //EndcapCryostat::CalibrationMixedCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_emesupcalc; //EMECSupportCalibrationCalculator() + ServiceHandle<ILArCalibCalculatorSvc> m_heccalc; //HEC::LArHECCalibrationWheelCalculator(HEC::kWheelDead) + ServiceHandle<ILArCalibCalculatorSvc> m_defcalc; //CalibrationDefaultCalculator() + + }; + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.cc new file mode 100644 index 000000000000..2eddb6e3242f --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.cc @@ -0,0 +1,64 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "EMBSDTool.h" + +// Project includes +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + EMBSDTool::EMBSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : SimpleSDTool(type, name, parent) + , m_hitCollName("LArHitEMB") + , m_embcalc("EMBCalculator", name) + , m_pscalc("EMBPresamplerCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("StacVolumes", m_stacVolumes); + declareProperty("PresamplerVolumes", m_presVolumes); + + declareProperty("EMBCalculator",m_embcalc); + declareProperty("EMBPSCalculator",m_pscalc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode EMBSDTool::initializeCalculators() + { + ATH_CHECK(m_pscalc.retrieve()); + ATH_CHECK(m_embcalc.retrieve()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* EMBSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArEMBSDWrapper", m_hitCollName); + + // Add the SDs + sdWrapper->addSD( makeOneSD("LAr::Barrel::Presampler::Module", &*m_pscalc, m_presVolumes) ); + sdWrapper->addSD( makeOneSD("LAr::EMB::STAC", &*m_embcalc, m_stacVolumes) ); + + // Setup frozen shower SD + if(useFrozenShowers()) + { + sdWrapper->addFastSimSD("BarrelFastSimDedicatedSD"); + } + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.h new file mode 100644 index 000000000000..a89293715557 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/EMBSDTool.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_EMBSDTOOL_H +#define LARG4SD_EMBSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class EMBSDTool + /// @brief SD tool which manages EM barrel sensitive detectors. + /// + /// NOTE: this design is in flux, migrating to be more multi-threading-friendly + /// + class EMBSDTool : public SimpleSDTool + { + + public: + + /// Constructor + EMBSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// @name Configuration + /// @{ + + /// Hit collection name + std::string m_hitCollName; + + /// List of volumes for the stac SD + std::vector<std::string> m_stacVolumes; + /// List of volumes for the presampler SD + std::vector<std::string> m_presVolumes; + + /// @} + + ServiceHandle<ILArCalculatorSvc> m_embcalc; //LArBarrelCalculator::GetCalculator() + ServiceHandle<ILArCalculatorSvc> m_pscalc; //LArBarrelPresamplerCalculator::GetCalculator() + + }; // class EMBSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.cc new file mode 100644 index 000000000000..0f55d3e1f289 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.cc @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "EMECSDTool.h" + +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + EMECSDTool::EMECSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : SimpleSDTool(type, name, parent), + m_hitCollName("LArHitEMEC") + , m_emepiwcalc("EMECPosInnerWheelCalculator", name) + , m_emeniwcalc("EMECNegInnerWheelCalculator", name) + , m_emepowcalc("EMECPosOuterWheelCalculator", name) + , m_emenowcalc("EMECNegOuterWheelCalculator", name) + , m_emepscalc("EMECPresamplerCalculator", name) + , m_emeobarcalc("EMECBackOuterBarretteCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("PosIWVolumes", m_posIWVolumes); + declareProperty("NegIWVolumes", m_negIWVolumes); + declareProperty("PosOWVolumes", m_posOWVolumes); + declareProperty("NegOWVolumes", m_negOWVolumes); + declareProperty("PresVolumes", m_presVolumes); + declareProperty("BOBarretteVolumes", m_bobVolumes); + + declareProperty("EMECPosIWCalculator", m_emepiwcalc); + declareProperty("EMECNegIWCalculator", m_emeniwcalc); + declareProperty("EMECPosOWCalculator", m_emepowcalc); + declareProperty("EMECNegOWCalculator", m_emenowcalc); + declareProperty("EMECPSCalculator", m_emepscalc); + declareProperty("EMECBOBCalculator", m_emeobarcalc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode EMECSDTool::initializeCalculators() + { + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_emeniwcalc.retrieve()); + ATH_CHECK(m_emepowcalc.retrieve()); + ATH_CHECK(m_emenowcalc.retrieve()); + ATH_CHECK(m_emepscalc.retrieve()); + ATH_CHECK(m_emeobarcalc.retrieve()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* EMECSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArEMECSDWrapper", m_hitCollName); + + // Add the SDs + sdWrapper->addSD( + makeOneSD( "LAr::EMEC::Pos::InnerWheel", &*m_emepiwcalc, m_posIWVolumes ) + ); + sdWrapper->addSD( + makeOneSD( "LAr::EMEC::Neg::InnerWheel", &*m_emeniwcalc, m_negIWVolumes ) + ); + sdWrapper->addSD( + makeOneSD( "LAr::EMEC::Pos::OuterWheel", &*m_emepowcalc, m_posOWVolumes ) + ); + sdWrapper->addSD( + makeOneSD( "LAr::EMEC::Neg::OuterWheel", &*m_emenowcalc, m_negOWVolumes ) + ); + sdWrapper->addSD( + makeOneSD( "LAr::Endcap::Presampler::LiquidArgon", &*m_emepscalc, m_presVolumes ) + ); + sdWrapper->addSD( + makeOneSD( "LAr::EMEC::BackOuterBarrette::Module::Phidiv", &*m_emeobarcalc, m_bobVolumes ) + ); + + // Setup frozen shower SD + if(useFrozenShowers()) + { + sdWrapper->addFastSimSD("EndcapFastSimDedicatedSD"); + } + + // Return the wrapper as my SD + return sdWrapper; + } + +} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.h new file mode 100644 index 000000000000..730c5e8fdaaa --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/EMECSDTool.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_EMECSDTOOL_H +#define LARG4SD_EMECSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class EMECSDTool + /// @brief SD tool which manages EM endcap sensitive detectors. + /// + /// NOTE: this design is in flux, migrating to be more multi-threading-friendly + /// + class EMECSDTool : public SimpleSDTool + { + + public: + + /// Constructor + EMECSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// @name List of volumes for each SD and the corresponding SD + /// @{ + std::vector<std::string> m_posIWVolumes; + std::vector<std::string> m_negIWVolumes; + std::vector<std::string> m_posOWVolumes; + std::vector<std::string> m_negOWVolumes; + std::vector<std::string> m_presVolumes; + std::vector<std::string> m_bobVolumes; + /// @} + + ServiceHandle<ILArCalculatorSvc> m_emepiwcalc; //EnergyCalculator(LArG4::InnerAbsorberWheel, LArG4::EMEC_ECOR_ROPT, 1) + ServiceHandle<ILArCalculatorSvc> m_emeniwcalc; //EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel, LArG4::EMEC_ECOR_ROPT, -1), + ServiceHandle<ILArCalculatorSvc> m_emepowcalc; //EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel, EC::EnergyCalculator::EMEC_ECOR_ROPT, 1), + ServiceHandle<ILArCalculatorSvc> m_emenowcalc; //EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel, EC::EnergyCalculator::EMEC_ECOR_ROPT, -1), + ServiceHandle<ILArCalculatorSvc> m_emepscalc; //LArEndcapPresamplerCalculator::GetCalculator() + ServiceHandle<ILArCalculatorSvc> m_emeobarcalc; //EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteWheel) + + + + }; // class EMECSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.cc new file mode 100644 index 000000000000..493fba86a9db --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.cc @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "FCALSDTool.h" + +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + FCALSDTool::FCALSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : SimpleSDTool(type, name, parent) + , m_hitCollName("LArHitFCAL") + , m_fcal1calc("FCAL1Calculator", name) + , m_fcal2calc("FCAL2Calculator", name) + , m_fcal3calc("FCAL3Calculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("FCAL1Volumes", m_fcal1Volumes); + declareProperty("FCAL2Volumes", m_fcal2Volumes); + declareProperty("FCAL3Volumes", m_fcal3Volumes); + + declareProperty("FCAL1Calculator", m_fcal1calc); + declareProperty("FCAL2Calculator", m_fcal2calc); + declareProperty("FCAL3Calculator", m_fcal3calc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode FCALSDTool::initializeCalculators() + { + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcal3calc.retrieve()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* FCALSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArFCALSDWrapper", m_hitCollName); + + // Add the SDs + sdWrapper->addSD( makeOneSD("LAr::FCAL::Module1::Gap", &*m_fcal1calc, m_fcal1Volumes) ); + sdWrapper->addSD( makeOneSD("LAr::FCAL::Module2::Gap", &*m_fcal2calc, m_fcal2Volumes) ); + sdWrapper->addSD( makeOneSD("LAr::FCAL::Module3::Gap", &*m_fcal3calc, m_fcal3Volumes) ); + + // Setup frozen shower SD + if(useFrozenShowers()) + { + sdWrapper->addFastSimSD("FCALFastSimDedicatedSD"); + } + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.h new file mode 100644 index 000000000000..f41499e7c761 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/FCALSDTool.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_FCALSDTOOL_H +#define LARG4SD_FCALSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class FCALSDTool + /// @brief SD tool which manages the LAr forward calo sensitive detectors. + /// + /// NOTE: this design is in flux, migrating to be more multi-threading-friendly + /// + class FCALSDTool : public SimpleSDTool + { + + public: + + /// Constructor + FCALSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// List of volumes for each SD + /// @{ + std::vector<std::string> m_fcal1Volumes; + std::vector<std::string> m_fcal2Volumes; + std::vector<std::string> m_fcal3Volumes; + /// @} + + ServiceHandle<ILArCalculatorSvc> m_fcal1calc; //LArFCAL1Calculator::GetInstance() + ServiceHandle<ILArCalculatorSvc> m_fcal2calc; //LArFCAL2Calculator::GetInstance() + ServiceHandle<ILArCalculatorSvc> m_fcal3calc; //LArFCAL3Calculator::GetInstance() + + }; // class FCALSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.cc new file mode 100644 index 000000000000..671f46e34ec0 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.cc @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "HECSDTool.h" + +#include "LArG4Code/SDWrapper.h" + + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + HECSDTool::HECSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : SimpleSDTool(type, name, parent) + , m_hitCollName("LArHitHEC") + , m_heccalc("HECWheelCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + //declareProperty("SliceVolumes", m_sliceVolumes); + //declareProperty("LocalVolumes", m_localVolumes); + declareProperty("WheelVolumes", m_wheelVolumes); + + declareProperty("HECWheelCalculator", m_heccalc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode HECSDTool::initializeCalculators() + { + ATH_CHECK(m_heccalc.retrieve()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* HECSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArHECSDWrapper", m_hitCollName); + + // Add the SDs + //sdWrapper->addSD( makeOneSD("LAr::HEC::Module::Depth::Slice", + // LArHECCalculator::GetCalculator(), + // m_sliceVolumes) ); + //sdWrapper->addSD( makeOneSD("LAr::HEC::Module::Depth::Slice::Local", + // LArHECLocalCalculator::GetCalculator(), + // m_localVolumes) ); + + sdWrapper->addSD( makeOneSD("LAr::HEC::Module::Depth::Slice::Wheel", &*m_heccalc, m_wheelVolumes) ); + + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.h new file mode 100644 index 000000000000..bd0580949d96 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/HECSDTool.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_HECSDTOOL_H +#define LARG4SD_HECSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class HECSDTool + /// @brief SD tool which manages the LAr hadronic endcap sensitive detectors. + /// + /// NOTE: this design is in flux, migrating to be more multi-threading-friendly + /// + class HECSDTool : public SimpleSDTool + { + + public: + + /// Constructor + HECSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// List of volumes for each SD + /// @{ + std::vector<std::string> m_sliceVolumes; + std::vector<std::string> m_localVolumes; + std::vector<std::string> m_wheelVolumes; + /// @} + + ServiceHandle<ILArCalculatorSvc> m_heccalc; //LArHECWheelCalculator::GetCalculator() + }; // class HECSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.cc new file mode 100644 index 000000000000..f874ed97b7a9 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.cc @@ -0,0 +1,147 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "InactiveSDTool.h" + +#include "LArG4Code/SDWrapper.h" + + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + InactiveSDTool::InactiveSDTool(const std::string& type, const std::string& name, + const IInterface *parent) + : CalibSDTool(type, name, parent) + , m_hitCollName("LArCalibrationHitInactive") + , m_embpscalc("BarrelPresamplerCalibrationCalculator", name) + , m_embcalc("BarrelCalibrationCalculator", name) + , m_emepiwcalc("EMECPosInnerWheelCalibrationCalculator", name) + , m_emeniwcalc("EMECNegInnerWheelCalibrationCalculator", name) + , m_emepowcalc("EMECPosOuterWheelCalibrationCalculator", name) + , m_emenowcalc("EMECNegOuterWheelCalibrationCalculator", name) + , m_heccalc("HECCalibrationWheelInactiveCalculator", name) + , m_fcal1calc("FCAL1CalibCalculator", name) + , m_fcal2calc("FCAL2CalibCalculator", name) + , m_fcal3calc("FCAL3CalibCalculator", name) + , m_minfcalcalc("MiniFCALInactiveCalibrationCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("BarrelPreVolumes", m_barPreVolumes); + declareProperty("BarrelVolumes", m_barVolumes); + declareProperty("ECPosInVolumes", m_ECPosInVolumes); + declareProperty("ECPosOutVolumes", m_ECPosOutVolumes); + declareProperty("ECNegInVolumes", m_ECNegInVolumes); + declareProperty("ECNegOutVolumes", m_ECNegOutVolumes); + //declareProperty("HECVolumes", m_HECVolumes={"LAr::HEC::Inactive"}); + //declareProperty("HECLocalVolumes", m_HECLocVolumes={"LAr::HEC::Local::Inactive"}); + declareProperty("HECWheelVolumes", m_HECWheelVolumes); + declareProperty("FCAL1Volumes", m_fcal1Volumes); + declareProperty("FCAL2Volumes", m_fcal2Volumes); + declareProperty("FCAL3Volumes", m_fcal3Volumes); + declareProperty("MiniMomVolumes", m_miniMomVolumes); + declareProperty("MiniVolumes", m_miniVolumes); + declareProperty("MiniLayVolumes", m_miniLayVolumes); + + declareProperty("EMBPSCalibrationCalculator", m_embpscalc); + declareProperty("EMBCalibrationCalculator", m_embcalc); + declareProperty("EMECPosIWCalibrationCalculator", m_emepiwcalc); + declareProperty("EMECNegIWCalibrationCalculator", m_emeniwcalc); + declareProperty("EMECPosOWCalibrationCalculator", m_emepowcalc); + declareProperty("EMECNegOWCalibrationCalculator", m_emenowcalc); + declareProperty("HECWheelInactiveCalculator", m_heccalc); + declareProperty("FCAL1CalibCalculator", m_fcal1calc); + declareProperty("FCAL2CalibCalculator", m_fcal2calc); + declareProperty("FCAL3CalibCalculator", m_fcal3calc); + declareProperty("MiniFCALInactiveCalibrationCalculator", m_minfcalcalc); + } + + //--------------------------------------------------------------------------- + // Initialization of Athena-components + //--------------------------------------------------------------------------- + StatusCode InactiveSDTool::initializeCalculators() + { + ATH_CHECK(m_embpscalc.retrieve()); + ATH_CHECK(m_embcalc.retrieve()); + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_emepowcalc.retrieve()); + ATH_CHECK(m_emeniwcalc.retrieve()); + ATH_CHECK(m_emenowcalc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcal3calc.retrieve()); + ATH_CHECK(m_minfcalcalc.retrieve()); + + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create SD wrapper for current thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* InactiveSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new CalibSDWrapper("LArInactiveSDWrapper", m_hitCollName); + + sdWrapper->addSD( + makeOneSD("LAr::Barrel::Presampler::Inactive", &*m_embpscalc, m_barPreVolumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::Barrel::Inactive", &*m_embcalc, m_barVolumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::EMEC::Pos::InnerWheel::Inactive", &*m_emepiwcalc, m_ECPosInVolumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::EMEC::Pos::OuterWheel::Inactive", &*m_emepowcalc, m_ECPosOutVolumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::EMEC::Neg::InnerWheel::Inactive", &*m_emeniwcalc, m_ECNegInVolumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::EMEC::Neg::OuterWheel::Inactive", &*m_emenowcalc, m_ECNegOutVolumes) + ); + + //sdWrapper->addSD( + // makeOneSD("LAr::HEC::Inactive", + // new HEC::CalibrationCalculator(HEC::kInactive), + // m_HECVolumes) + //); + + //sdWrapper->addSD( + // makeOneSD("LAr::HEC::Local::Inactive", + // new HEC::LocalCalibrationCalculator(HEC::kLocInactive), + // m_HECLocVolumes) + //); + + sdWrapper->addSD( + makeOneSD("LAr::HEC::Wheel::Inactive", &*m_heccalc, m_HECWheelVolumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::FCAL::Inactive1", &*m_fcal1calc, m_fcal1Volumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::FCAL::Inactive2", &*m_fcal2calc, m_fcal2Volumes) + ); + sdWrapper->addSD( + makeOneSD("LAr::FCAL::Inactive3", &*m_fcal3calc, m_fcal3Volumes) + ); + sdWrapper->addSD( + makeOneSD("MiniFCALMother::Inactive", &*m_minfcalcalc, m_miniMomVolumes) + ); + sdWrapper->addSD( + makeOneSD("MiniFCAL::Inactive", &*m_minfcalcalc, m_miniVolumes) + ); + sdWrapper->addSD( + makeOneSD("MiniFCAL::Layer::Inactive", &*m_minfcalcalc, m_miniLayVolumes) + ); + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.h new file mode 100644 index 000000000000..4d128086b311 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/InactiveSDTool.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_INACTIVESDTOOL_H +#define LARG4SD_INACTIVESDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/CalibSDTool.h" +#include "LArG4Code/ILArCalibCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class InactiveSDTool + /// @brief Sensitive detector tool which manages inactive-area LAr calib SDs. + /// + /// Design is in flux. + /// + class InactiveSDTool : public CalibSDTool + { + + public: + + /// Constructor + InactiveSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + /// Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// @name SD volumes + /// @{ + std::vector<std::string> m_barPreVolumes; + std::vector<std::string> m_barVolumes; + std::vector<std::string> m_ECPosInVolumes; + std::vector<std::string> m_ECPosOutVolumes; + std::vector<std::string> m_ECNegInVolumes; + std::vector<std::string> m_ECNegOutVolumes; + std::vector<std::string> m_HECWheelVolumes; + std::vector<std::string> m_fcal1Volumes; + std::vector<std::string> m_fcal2Volumes; + std::vector<std::string> m_fcal3Volumes; + std::vector<std::string> m_miniMomVolumes; + std::vector<std::string> m_miniVolumes; + std::vector<std::string> m_miniLayVolumes; + /// @} + + ServiceHandle<ILArCalibCalculatorSvc> m_embpscalc; //BarrelPresampler::CalibrationCalculator + ServiceHandle<ILArCalibCalculatorSvc> m_embcalc; //Barrel::CalibrationCalculator + ServiceHandle<ILArCalibCalculatorSvc> m_emepiwcalc;//LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, 1) + ServiceHandle<ILArCalibCalculatorSvc> m_emeniwcalc;//LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, -1) + ServiceHandle<ILArCalibCalculatorSvc> m_emepowcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, 1) + ServiceHandle<ILArCalibCalculatorSvc> m_emenowcalc; //LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, -1) + ServiceHandle<ILArCalibCalculatorSvc> m_heccalc; //LArG4::HEC::LArHECCalibrationWheelCalculator(LArG4::HEC::kWheelInactive) + ServiceHandle<ILArCalibCalculatorSvc> m_fcal1calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal2calc; + ServiceHandle<ILArCalibCalculatorSvc> m_fcal3calc; + ServiceHandle<ILArCalibCalculatorSvc> m_minfcalcalc; //LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kInactive) + + }; // class InactiveSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.cc deleted file mode 100644 index 04d27af54b0e..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4ActiveSDTool.h" - -#include "LArG4Code/LArG4CalibSD.h" - -#include "LArG4Code/LArG4Hit.h" -#include "CxxUtils/make_unique.h" - -// All the calculators I need -#include "LArG4Barrel/LArBarrelCalibrationCalculator.h" -#include "LArG4Barrel/PresamplerCalibrationCalculator.h" -#include "LArG4EC/PresamplerCalibrationCalculator.h" -#include "LArG4EC/CalibrationCalculator.h" -#include "LArG4EC/PresamplerCalibrationCalculator.h" -#include "LArG4FCAL/LArFCAL1CalibCalculator.h" -#include "LArG4FCAL/LArFCAL2CalibCalculator.h" -#include "LArG4FCAL/LArFCAL3CalibCalculator.h" -#include "LArG4MiniFCAL/MiniFCALCalibrationCalculator.h" -#include "LArG4HEC/LArHECCalibrationWheelCalculator.h" - -LArG4ActiveSDTool::LArG4ActiveSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArCalibrationHitActive") - , m_stacSD(nullptr) - , m_presBarSD(nullptr) - , m_posIWSD(nullptr) - , m_negIWSD(nullptr) - , m_posOWSD(nullptr) - , m_negOWSD(nullptr) - , m_presECSD(nullptr) - , m_bobSD(nullptr) - , m_fcal1SD(nullptr) - , m_fcal2SD(nullptr) - , m_fcal3SD(nullptr) - , m_sliceSD(nullptr) - , m_miniSD(nullptr) -{ - declareProperty("StacVolumes",m_stacVolumes); - declareProperty("PresamplerVolumes",m_presBarVolumes); - declareProperty("PosIWVolumes",m_posIWVolumes); - declareProperty("NegIWVolumes",m_negIWVolumes); - declareProperty("PosOWVolumes",m_posOWVolumes); - declareProperty("NegOWVolumes",m_negOWVolumes); - declareProperty("PresVolumes",m_presECVolumes); - declareProperty("BOBarretteVolumes",m_bobVolumes); - declareProperty("FCAL1Volumes",m_fcal1Volumes); - declareProperty("FCAL2Volumes",m_fcal2Volumes); - declareProperty("FCAL3Volumes",m_fcal3Volumes); - declareProperty("SliceVolumes",m_sliceVolumes); - declareProperty("MiniVolumes",m_miniVolumes); - - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4ActiveSDTool::initializeSD() -{ - // Lots of singleton calculators !!! - m_presBarSD = new LArG4CalibSD( "Barrel::Presampler::Module::Calibration" , new LArG4::BarrelPresampler::CalibrationCalculator() , m_doPID ); - m_stacSD = new LArG4CalibSD( "EMB::STAC::Calibration" , new LArG4::Barrel::CalibrationCalculator() , m_doPID ); - m_posIWSD = new LArG4CalibSD( "EMEC::Pos::InnerWheel::Calibration" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, 1) , m_doPID ); - m_negIWSD = new LArG4CalibSD( "EMEC::Neg::InnerWheel::Calibration" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, -1) , m_doPID ); - m_posOWSD = new LArG4CalibSD( "EMEC::Pos::OuterWheel::Calibration" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, 1) , m_doPID ); - m_negOWSD = new LArG4CalibSD( "EMEC::Neg::OuterWheel::Calibration" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, -1) , m_doPID ); - m_presECSD = new LArG4CalibSD( "Endcap::Presampler::LiquidArgon::Calibration" , new LArG4::EC::PresamplerCalibrationCalculator() , m_doPID ); - m_bobSD = new LArG4CalibSD( "EMEC::BackOuterBarrette::Calibration", new LArG4::EC::CalibrationCalculator(LArWheelCalculator::BackOuterBarretteWheelCalib, 1) , m_doPID ); - m_fcal1SD = new LArG4CalibSD( "FCAL::Module1::Gap::Calibration" , LArG4::FCAL::LArFCAL1CalibCalculator::GetCalculator() , m_doPID ); - m_fcal2SD = new LArG4CalibSD( "FCAL::Module2::Gap::Calibration" , LArG4::FCAL::LArFCAL2CalibCalculator::GetCalculator() , m_doPID ); - m_fcal3SD = new LArG4CalibSD( "FCAL::Module3::Gap::Calibration" , LArG4::FCAL::LArFCAL3CalibCalculator::GetCalculator() , m_doPID ); - m_sliceSD = new LArG4CalibSD( "HEC::Module::Depth::Slice::Wheel::Calibration" , new LArG4::HEC::LArHECCalibrationWheelCalculator(LArG4::HEC::kWheelActive) , m_doPID ); - m_miniSD = new LArG4CalibSD( "MiniFCAL::Wafer" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kActive) , m_doPID ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_presBarSD] = &m_presBarVolumes; - configuration[m_stacSD] = &m_stacVolumes; - configuration[m_posIWSD] = &m_posIWVolumes; - configuration[m_posOWSD] = &m_posOWVolumes; - configuration[m_negIWSD] = &m_negIWVolumes; - configuration[m_negOWSD] = &m_negOWVolumes; - configuration[m_presECSD] = &m_presECVolumes; - configuration[m_bobSD] = &m_bobVolumes; - configuration[m_fcal1SD] = &m_fcal1Volumes; - configuration[m_fcal2SD] = &m_fcal2Volumes; - configuration[m_fcal3SD] = &m_fcal3Volumes; - configuration[m_sliceSD] = &m_sliceVolumes; - configuration[m_miniSD] = &m_miniVolumes; - setupAllSDs(configuration); - - // make sure they have the identifiers they need - setupHelpers(m_presBarSD); - setupHelpers(m_stacSD); - setupHelpers(m_posIWSD); - setupHelpers(m_posOWSD); - setupHelpers(m_negIWSD); - setupHelpers(m_negOWSD); - setupHelpers(m_presECSD); - setupHelpers(m_bobSD); - setupHelpers(m_fcal1SD); - setupHelpers(m_fcal2SD); - setupHelpers(m_fcal3SD); - setupHelpers(m_sliceSD); - setupHelpers(m_miniSD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4ActiveSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<CaloCalibrationHitContainer>(m_HitColl.name()); - m_presBarSD->EndOfAthenaEvent( &*m_HitColl ); - m_stacSD ->EndOfAthenaEvent( &*m_HitColl ); - m_posIWSD ->EndOfAthenaEvent( &*m_HitColl ); - m_negIWSD ->EndOfAthenaEvent( &*m_HitColl ); - m_posOWSD ->EndOfAthenaEvent( &*m_HitColl ); - m_negOWSD ->EndOfAthenaEvent( &*m_HitColl ); - m_presECSD ->EndOfAthenaEvent( &*m_HitColl ); - m_bobSD ->EndOfAthenaEvent( &*m_HitColl ); - m_fcal1SD ->EndOfAthenaEvent( &*m_HitColl ); - m_fcal2SD ->EndOfAthenaEvent( &*m_HitColl ); - m_fcal3SD ->EndOfAthenaEvent( &*m_HitColl ); - m_sliceSD ->EndOfAthenaEvent( &*m_HitColl ); - m_miniSD ->EndOfAthenaEvent( &*m_HitColl ); - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.h deleted file mode 100644 index 3bc861f1b948..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4ActiveSDTool.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4ACTIVESDTOOL_H -#define LARG4ACTIVESDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "CaloSimEvent/CaloCalibrationHitContainer.h" - -class LArG4CalibSD; - -class LArG4ActiveSDTool : public LArG4SDTool -{ - public: - // Constructor - LArG4ActiveSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - // Destructor - virtual ~LArG4ActiveSDTool() {} - - // Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - // Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ -// StatusCode SetupEvent() override final; - - private: - // The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; - - std::vector<std::string> m_stacVolumes; - std::vector<std::string> m_presBarVolumes; - std::vector<std::string> m_posIWVolumes; - std::vector<std::string> m_negIWVolumes; - std::vector<std::string> m_posOWVolumes; - std::vector<std::string> m_negOWVolumes; - std::vector<std::string> m_presECVolumes; - std::vector<std::string> m_bobVolumes; - std::vector<std::string> m_fcal1Volumes; - std::vector<std::string> m_fcal2Volumes; - std::vector<std::string> m_fcal3Volumes; - std::vector<std::string> m_sliceVolumes; - std::vector<std::string> m_miniVolumes; - - LArG4CalibSD* m_stacSD; - LArG4CalibSD* m_presBarSD; - LArG4CalibSD* m_posIWSD; - LArG4CalibSD* m_negIWSD; - LArG4CalibSD* m_posOWSD; - LArG4CalibSD* m_negOWSD; - LArG4CalibSD* m_presECSD; - LArG4CalibSD* m_bobSD; - LArG4CalibSD* m_fcal1SD; - LArG4CalibSD* m_fcal2SD; - LArG4CalibSD* m_fcal3SD; - LArG4CalibSD* m_sliceSD; - LArG4CalibSD* m_miniSD; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.cc deleted file mode 100644 index dec603cdbba8..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4DeadSDTool.h" - -#include "LArG4Code/LArG4CalibSD.h" - -#include "LArG4Code/LArG4Hit.h" -#include "CxxUtils/make_unique.h" - -// The calculators that I need... -#include "LArG4Barrel/LArBarrelCalibrationCalculator.h" -#include "LArG4Barrel/CryostatCalibrationCalculator.h" -#include "LArG4Barrel/CryostatCalibrationMixedCalculator.h" -#include "LArG4Barrel/CryostatCalibrationLArCalculator.h" -#include "LArG4Barrel/DMCalibrationCalculator.h" -#include "LArG4Barrel/PresamplerCalibrationCalculator.h" -#include "LArG4EC/CryostatCalibrationCalculator.h" -#include "LArG4EC/CryostatCalibrationMixedCalculator.h" -#include "LArG4EC/CryostatCalibrationLArCalculator.h" -#include "LArG4EC/EMECSupportCalibrationCalculator.h" -#include "LArG4HEC/LArHECCalibrationWheelCalculator.h" -#include "LArG4Code/CalibrationDefaultCalculator.h" - -// For escaped energy -#include "CaloG4Sim/EscapedEnergyRegistry.h" -#include "CaloG4Sim/CalibrationDefaultProcessing.h" -#include "LArG4Code/EscapedEnergyProcessing.h" - -LArG4DeadSDTool::LArG4DeadSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArCalibrationHitDeadMaterial") - , m_barCrySD(nullptr) - , m_barCryLArSD(nullptr) - , m_barCryMixSD(nullptr) - , m_DMSD(nullptr) - , m_barPresSD(nullptr) - , m_barSD(nullptr) - , m_ECCrySD(nullptr) - , m_ECCryLArSD(nullptr) - , m_ECCryMixSD(nullptr) - , m_ECSupportSD(nullptr) - , m_HECWheelSD(nullptr) - , m_uninstSD(nullptr) -{ - declareProperty("BarrelCryVolumes",m_barCryVolumes); - declareProperty("BarrelCryLArVolumes",m_barCryLArVolumes); - declareProperty("BarrelCryMixVolumes",m_barCryMixVolumes); - declareProperty("DeadMaterialVolumes",m_DMVolumes); - declareProperty("BarrelPresVolumes",m_barPresVolumes); - declareProperty("BarrelVolumes",m_barVolumes); - declareProperty("ECCryVolumes",m_ECCryVolumes); - declareProperty("ECCryLArVolumes",m_ECCryLArVolumes); - declareProperty("ECCryMixVolumes",m_ECCryMixVolumes); - declareProperty("ECSupportVolumes",m_ECSupportVolumes); - declareProperty("HECWheelVolumes",m_HECWheelVolumes); - //declareProperty("HECVolumes",m_HECVolumes={"LArDead::HEC::Dead"}); - //declareProperty("HECLocalVolumes",m_HECLocVolumes={"LArDead::HEC::Local::Dead"}); - //declareProperty("MiniMomVolumes",m_miniMomVolumes={"MiniFCALMother::Dead"}); - //declareProperty("MiniVolumes",m_miniVolumes={"MiniFCAL::Dead"}); - //declareProperty("MiniLayVolumes",m_miniLayVolumes={"MiniFCAL::Layer::Dead"}); - declareProperty("doEscapedEnergy",m_do_eep=false); - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4DeadSDTool::initializeSD() -{ - // Lots of singleton calculators !!! - m_barCrySD = new LArG4CalibSD( "LArDead::BarrelCryostat::Dead" , new LArG4::BarrelCryostat::CalibrationCalculator() , m_doPID); - m_barCryLArSD = new LArG4CalibSD( "LArDead::BarrelCryostat::LAr::Dead" , new LArG4::BarrelCryostat::CalibrationLArCalculator() , m_doPID); - m_barCryMixSD = new LArG4CalibSD( "LArDead::BarrelCryostat::Mixed::Dead" , new LArG4::BarrelCryostat::CalibrationMixedCalculator() , m_doPID); - m_DMSD = new LArG4CalibSD( "LArDead::DM::Dead" , new LArG4::DM::CalibrationCalculator() , m_doPID); - m_barPresSD = new LArG4CalibSD( "LArDead::Barrel::Presampler::Dead" , new LArG4::BarrelPresampler::CalibrationCalculator() , m_doPID); - m_barSD = new LArG4CalibSD( "LArDead::Barrel::Dead" , new LArG4::Barrel::CalibrationCalculator() , m_doPID); - m_ECCrySD = new LArG4CalibSD( "LArDead::EndcapCryostat::Dead" , new LArG4::EndcapCryostat::CalibrationCalculator() , m_doPID); - m_ECCryLArSD = new LArG4CalibSD( "LArDead::EndcapCryostat::LAr::Dead" , new LArG4::EndcapCryostat::CalibrationLArCalculator() , m_doPID); - m_ECCryMixSD = new LArG4CalibSD( "LArDead::EndcapCryostat::Mixed::Dead" , new LArG4::EndcapCryostat::CalibrationMixedCalculator() , m_doPID); - m_ECSupportSD = new LArG4CalibSD( "LArDead::EMECSupport::Dead" , new LArG4::EMECSupportCalibrationCalculator() , m_doPID); - m_HECWheelSD = new LArG4CalibSD( "LArDead::HEC::Wheel::Inactive" , new LArG4::HEC::LArHECCalibrationWheelCalculator(LArG4::HEC::kWheelDead) , m_doPID); - //m_HECSD = new LArG4CalibSD( "LArDead::HEC::Inactive" , new LArG4::HEC::CalibrationCalculator(LArG4::HEC::kDead) , m_doPID); - //m_HECLocSD = new LArG4CalibSD( "LArDead::HEC::Local::Inactive" , new LArG4::HEC::LocalCalibrationCalculator(LArG4::HEC::kLocDead) , m_doPID); - //m_miniMomSD = new LArG4CalibSD( "MiniFCALMother::Dead" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kDead) , m_doPID); - //m_miniSD = new LArG4CalibSD( "MiniFCAL::Dead" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kDead) , m_doPID); - //m_miniLaySD = new LArG4CalibSD( "MiniFCAL::Layer::Dead" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kDead) , m_doPID); - // Take care of the default material - if (m_do_eep) m_uninstSD = new LArG4CalibSD( "Default::Dead::Uninstrumented::Calibration::Region" , new LArG4::CalibrationDefaultCalculator() , m_doPID ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_barCrySD] = &m_barCryVolumes; - configuration[m_barCryLArSD] = &m_barCryLArVolumes; - configuration[m_barCryMixSD] = &m_barCryMixVolumes; - configuration[m_DMSD] = &m_DMVolumes; - configuration[m_barPresSD] = &m_barPresVolumes; - configuration[m_barSD] = &m_barVolumes; - configuration[m_ECCrySD] = &m_ECCryVolumes; - configuration[m_ECCryLArSD] = &m_ECCryLArVolumes; - configuration[m_ECCryMixSD] = &m_ECCryMixVolumes; - configuration[m_ECSupportSD] = &m_ECSupportVolumes; - configuration[m_HECWheelSD] = &m_HECWheelVolumes; - //configuration[m_HECSD] = &m_HECVolumes; - //configuration[m_HECLocSD] = &m_HECLocVolumes; - //configuration[m_miniMomSD] = &m_miniMomVolumes; - //configuration[m_miniSD] = &m_miniVolumes; - //configuration[m_miniLaySD] = &m_miniLayVolumes; - if (m_do_eep) configuration[m_uninstSD] = new std::vector<std::string>; // No volumes for this guy - setupAllSDs(configuration); - - // Make sure they have the helpers they need - setupHelpers(m_barCrySD); - setupHelpers(m_barCryLArSD); - setupHelpers(m_barCryMixSD); - setupHelpers(m_DMSD); - setupHelpers(m_barPresSD); - setupHelpers(m_barSD); - setupHelpers(m_ECCrySD); - setupHelpers(m_ECCryLArSD); - setupHelpers(m_ECCryMixSD); - setupHelpers(m_ECSupportSD); - setupHelpers(m_HECWheelSD); - //setupHelpers(m_HECSD); - //setupHelpers(m_HECLocSD); - //setupHelpers(m_miniMomSD); - //setupHelpers(m_miniSD); - //setupHelpers(m_miniLaySD); - if (m_do_eep) setupHelpers(m_uninstSD); - - // This is from initialize processing in the former LArG4CalibSD - // I still think we can do better than this, though - if (m_do_eep){ - ATH_MSG_INFO("new EscapedEnergyProcessing"); - // Initialize the escaped energy processing for LAr volumes. - CaloG4::VEscapedEnergyProcessing* eep = new EscapedEnergyProcessing(m_uninstSD); - - ATH_MSG_INFO("EER instance"); - CaloG4::EscapedEnergyRegistry* registry = CaloG4::EscapedEnergyRegistry::GetInstance(); - ATH_MSG_INFO("addAndAdoptProcessing"); - registry->AddAndAdoptProcessing( "LAr::", eep ); - } - - return StatusCode::SUCCESS; -} - -StatusCode LArG4DeadSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<CaloCalibrationHitContainer>(m_HitColl.name()); - m_barCrySD ->EndOfAthenaEvent( &*m_HitColl ); - m_barCryLArSD->EndOfAthenaEvent( &*m_HitColl ); - m_barCryMixSD->EndOfAthenaEvent( &*m_HitColl ); - m_DMSD ->EndOfAthenaEvent( &*m_HitColl ); - m_barPresSD ->EndOfAthenaEvent( &*m_HitColl ); - m_barSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECCrySD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECCryLArSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECCryMixSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECSupportSD->EndOfAthenaEvent( &*m_HitColl ); - m_HECWheelSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_HECSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_HECLocSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_miniMomSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_miniSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_miniLaySD ->EndOfAthenaEvent( &*m_HitColl ); - if (m_do_eep) m_uninstSD ->EndOfAthenaEvent( &*m_HitColl ); - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.h deleted file mode 100644 index c8b7a254d372..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4DeadSDTool.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4DEADSDTOOL_H -#define LARG4DEADSDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "CaloSimEvent/CaloCalibrationHitContainer.h" - -class LArG4CalibSD; - -class LArG4DeadSDTool : public LArG4SDTool -{ - public: - // Constructor - LArG4DeadSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - // Destructor - virtual ~LArG4DeadSDTool() {} - - // Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - // Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ -// StatusCode SetupEvent() override final; - - private: - // Do we add the escaped energy processing? This is only in "mode 1" (Tile+LAr), not in "DeadLAr" mode - bool m_do_eep; - - // The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; - - // The volumes per SD, and the corresponding SDs - std::vector<std::string> m_barCryVolumes; - std::vector<std::string> m_barCryLArVolumes; - std::vector<std::string> m_barCryMixVolumes; - std::vector<std::string> m_DMVolumes; - std::vector<std::string> m_barPresVolumes; - std::vector<std::string> m_barVolumes; - std::vector<std::string> m_ECCryVolumes; - std::vector<std::string> m_ECCryLArVolumes; - std::vector<std::string> m_ECCryMixVolumes; - std::vector<std::string> m_ECSupportVolumes; - std::vector<std::string> m_HECWheelVolumes; - LArG4CalibSD* m_barCrySD; - LArG4CalibSD* m_barCryLArSD; - LArG4CalibSD* m_barCryMixSD; - LArG4CalibSD* m_DMSD; - LArG4CalibSD* m_barPresSD; - LArG4CalibSD* m_barSD; - LArG4CalibSD* m_ECCrySD; - LArG4CalibSD* m_ECCryLArSD; - LArG4CalibSD* m_ECCryMixSD; - LArG4CalibSD* m_ECSupportSD; - LArG4CalibSD* m_HECWheelSD; - LArG4CalibSD* m_uninstSD; - -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.cc deleted file mode 100644 index d45c703119a4..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4EMBSDTool.h" -#include "LArG4Code/LArG4SimpleSD.h" - -#include "LArG4Code/LArG4Hit.h" - -#include "LArG4Barrel/LArBarrelCalculator.h" -#include "LArG4Barrel/LArBarrelPresamplerCalculator.h" - -#include "CxxUtils/make_unique.h" -#include "G4SDManager.hh" - -LArG4EMBSDTool::LArG4EMBSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArHitEMB") - , m_presSD(nullptr) - , m_stacSD(nullptr) -{ - declareProperty("StacVolumes",m_stacVolumes); - declareProperty("PresamplerVolumes",m_presVolumes); - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4EMBSDTool::initializeSD() -{ - m_presSD = new LArG4SimpleSD( "LAr::Barrel::Presampler::Module" , LArBarrelPresamplerCalculator::GetCalculator() , m_timeBinType , m_timeBinWidth ); - m_stacSD = new LArG4SimpleSD( "LAr::EMB::STAC" , LArBarrelCalculator::GetCalculator() , m_timeBinType , m_timeBinWidth ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_presSD] = &m_presVolumes; - configuration[m_stacSD] = &m_stacVolumes; - setupAllSDs(configuration); - - // Make sure the helpers are all set up - setupHelpers(m_presSD); - setupHelpers(m_stacSD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4EMBSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<LArHitContainer>(m_HitColl.name()); - m_presSD->EndOfAthenaEvent( &*m_HitColl ); - m_stacSD->EndOfAthenaEvent( &*m_HitColl ); - - // Additions for optional fast simulation - if (m_useFrozenShowers){ - // FIXME: this is very expensive, especially for a fastsim! - LArG4SimpleSD* fastSD = dynamic_cast<LArG4SimpleSD*> - ( G4SDManager::GetSDMpointer()->FindSensitiveDetector("BarrelFastSimDedicatedSD") ); - if (fastSD){ - fastSD->EndOfAthenaEvent( &*m_HitColl ); - } else { - ATH_MSG_WARNING( "Could not find BarrelFastSimDedicatedSD, but fast sim was configured" ); - } - } - - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.h deleted file mode 100644 index 0255cd218eab..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMBSDTool.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4EMBSDTOOL_H -#define LARG4EMBSDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "LArSimEvent/LArHitContainer.h" - -class LArG4SimpleSD; - -/// @class LArG4EMBSDTool -/// @brief SD tool which manages EM barrel sensitive detectors. -/// -/// NOTE: this design has some multi-threading issues which will need to be -/// addressed. -/// -class LArG4EMBSDTool : public LArG4SDTool -{ - public: - /// Constructor - LArG4EMBSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - /// Destructor - virtual ~LArG4EMBSDTool() {} - - /// Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - /// Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ - //StatusCode SetupEvent() override final; - - private: - /// The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<LArHitContainer> m_HitColl; - - /// List of volumes for the stac SD - std::vector<std::string> m_stacVolumes; - /// List of volumes for the presampler SD - std::vector<std::string> m_presVolumes; - /// Pointer to the presampler SD - LArG4SimpleSD* m_presSD; - /// Pointer to the stac SD - LArG4SimpleSD* m_stacSD; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.cc deleted file mode 100644 index d2e49d7e2ce8..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.cc +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4EMECSDTool.h" -#include "LArG4Code/LArG4SimpleSD.h" - -#include "LArG4Code/LArG4Hit.h" - -#include "LArG4EC/EnergyCalculator.h" -#include "LArG4EC/LArEndcapPresamplerCalculator.h" - -#include "CxxUtils/make_unique.h" -#include "G4SDManager.hh" - -LArG4EMECSDTool::LArG4EMECSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArHitEMEC") - , m_posIWSD(nullptr) - , m_negIWSD(nullptr) - , m_posOWSD(nullptr) - , m_negOWSD(nullptr) - , m_presSD(nullptr) - , m_bobSD(nullptr) -{ - declareProperty("PosIWVolumes",m_posIWVolumes); - declareProperty("NegIWVolumes",m_negIWVolumes); - declareProperty("PosOWVolumes",m_posOWVolumes); - declareProperty("NegOWVolumes",m_negOWVolumes); - declareProperty("PresVolumes",m_presVolumes); - declareProperty("BOBarretteVolumes",m_bobVolumes); - //declareProperty("BIBarretteVolumes",m_bibVolumes={"LArMgr::LAr::EMEC::BackInnerBarrette::Module::Phidiv"}); - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4EMECSDTool::initializeSD() -{ - m_posIWSD = new LArG4SimpleSD( "LAr::EMEC::Pos::InnerWheel" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, 1) , m_timeBinType , m_timeBinWidth ); - m_negIWSD = new LArG4SimpleSD( "LAr::EMEC::Neg::InnerWheel" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, -1) , m_timeBinType , m_timeBinWidth ); - m_posOWSD = new LArG4SimpleSD( "LAr::EMEC::Pos::OuterWheel" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, 1) , m_timeBinType , m_timeBinWidth ); - m_negOWSD = new LArG4SimpleSD( "LAr::EMEC::Neg::OuterWheel" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel, LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, -1) , m_timeBinType , m_timeBinWidth ); - m_presSD = new LArG4SimpleSD( "LAr::Endcap::Presampler::LiquidArgon" , LArEndcapPresamplerCalculator::GetCalculator() , m_timeBinType , m_timeBinWidth ); - m_bobSD = new LArG4SimpleSD( "LAr::EMEC::BackOuterBarrette::Module::Phidiv", new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteWheel) , m_timeBinType , m_timeBinWidth); - //m_bibSD = new LArG4SimpleSD( "LAr::EMEC::BackInnerBarrette::Module::Phidiv" , new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackInnerBarretteWheel) , m_timeBinType , m_timeBinWidth); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_posIWSD] = &m_posIWVolumes; - configuration[m_posOWSD] = &m_posOWVolumes; - configuration[m_negIWSD] = &m_negIWVolumes; - configuration[m_negOWSD] = &m_negOWVolumes; - configuration[m_presSD] = &m_presVolumes; - configuration[m_bobSD] = &m_bobVolumes; - //configuration[m_bibSD] = &m_bibVolumes; - setupAllSDs(configuration); - - // Make sure the ID helpers are all set up - setupHelpers(m_posIWSD); - setupHelpers(m_posOWSD); - setupHelpers(m_negIWSD); - setupHelpers(m_negOWSD); - setupHelpers(m_presSD); - setupHelpers(m_bobSD); - //setupHelpers(m_bibSD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4EMECSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<LArHitContainer>(m_HitColl.name()); - - // Hand this collection name off to the SDs. They will be writing to the - // collection, but only one at a time! - m_posIWSD->EndOfAthenaEvent( &*m_HitColl ); - m_negIWSD->EndOfAthenaEvent( &*m_HitColl ); - m_posOWSD->EndOfAthenaEvent( &*m_HitColl ); - m_negOWSD->EndOfAthenaEvent( &*m_HitColl ); - m_presSD->EndOfAthenaEvent( &*m_HitColl ); - m_bobSD->EndOfAthenaEvent( &*m_HitColl ); - //m_bibSD->EndOfAthenaEvent( &*m_HitColl ); - - // Additions for optional fast simulation - if (m_useFrozenShowers){ - // FIXME: this is very expensive, especially for a fastsim! - LArG4SimpleSD * fastSD = dynamic_cast<LArG4SimpleSD*> - ( G4SDManager::GetSDMpointer()->FindSensitiveDetector("EndcapFastSimDedicatedSD") ); - if (fastSD){ - fastSD->EndOfAthenaEvent( &*m_HitColl ); - } else { - ATH_MSG_WARNING( "Could not find EndcapFastSimDedicatedSD, but fast sim was configured" ); - } - } - - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.h deleted file mode 100644 index bb99308f44d9..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4EMECSDTool.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4EMECSDTOOL_H -#define LARG4EMECSDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "LArSimEvent/LArHitContainer.h" - -class LArG4SimpleSD; - -/// @class LArG4EMECSDTool -/// @brief SD tool which manages EM endcap sensitive detectors. -/// -/// NOTE: this design has some multi-threading issues which will need to be -/// addressed. -/// -class LArG4EMECSDTool : public LArG4SDTool -{ - public: - /// Constructor - LArG4EMECSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - /// Destructor - virtual ~LArG4EMECSDTool() {} - - /// Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - /// Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - private: - /// The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<LArHitContainer> m_HitColl; - - // List of volumes for each SD and the corresponding SD - std::vector<std::string> m_posIWVolumes; - std::vector<std::string> m_negIWVolumes; - std::vector<std::string> m_posOWVolumes; - std::vector<std::string> m_negOWVolumes; - std::vector<std::string> m_presVolumes; - std::vector<std::string> m_bobVolumes; - LArG4SimpleSD* m_posIWSD; - LArG4SimpleSD* m_negIWSD; - LArG4SimpleSD* m_posOWSD; - LArG4SimpleSD* m_negOWSD; - LArG4SimpleSD* m_presSD; - LArG4SimpleSD* m_bobSD; -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.cc deleted file mode 100644 index 11c8d19ac763..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4FCALSDTool.h" -#include "LArG4Code/LArG4SimpleSD.h" - -#include "LArG4Code/LArG4Hit.h" - -#include "LArG4FCAL/LArFCAL1Calculator.h" -#include "LArG4FCAL/LArFCAL2Calculator.h" -#include "LArG4FCAL/LArFCAL3Calculator.h" - -#include "CxxUtils/make_unique.h" -#include "G4SDManager.hh" - -LArG4FCALSDTool::LArG4FCALSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArHitFCAL") - , m_fcal1SD(nullptr) - , m_fcal2SD(nullptr) - , m_fcal3SD(nullptr) -{ - declareProperty("FCAL1Volumes",m_fcal1Volumes); - declareProperty("FCAL2Volumes",m_fcal2Volumes); - declareProperty("FCAL3Volumes",m_fcal3Volumes); - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4FCALSDTool::initializeSD() -{ - m_fcal1SD = new LArG4SimpleSD( "LAr::FCAL::Module1::Gap" , LArFCAL1Calculator::GetInstance() , m_timeBinType , m_timeBinWidth ); - m_fcal2SD = new LArG4SimpleSD( "LAr::FCAL::Module2::Gap" , LArFCAL2Calculator::GetInstance() , m_timeBinType , m_timeBinWidth ); - m_fcal3SD = new LArG4SimpleSD( "LAr::FCAL::Module3::Gap" , LArFCAL3Calculator::GetInstance() , m_timeBinType , m_timeBinWidth ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_fcal1SD] = &m_fcal1Volumes; - configuration[m_fcal2SD] = &m_fcal2Volumes; - configuration[m_fcal3SD] = &m_fcal3Volumes; - setupAllSDs(configuration); - - // Make sure the ID helpers are all set up - setupHelpers(m_fcal1SD); - setupHelpers(m_fcal2SD); - setupHelpers(m_fcal3SD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4FCALSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<LArHitContainer>(m_HitColl.name()); - // Hand this collection name off to the SDs. They will be writing to the - // collection, but only one at a time! - m_fcal1SD->EndOfAthenaEvent( &*m_HitColl ); - m_fcal2SD->EndOfAthenaEvent( &*m_HitColl ); - m_fcal3SD->EndOfAthenaEvent( &*m_HitColl ); - - // Additions for optional fast simulation - if (m_useFrozenShowers){ - // FIXME: this is very expensive, especially for a fastsim! - LArG4SimpleSD * fastSD = dynamic_cast<LArG4SimpleSD*>( G4SDManager::GetSDMpointer()->FindSensitiveDetector("FCALFastSimDedicatedSD") ); - if (fastSD){ - fastSD->EndOfAthenaEvent( &*m_HitColl ); - } else { - ATH_MSG_WARNING( "Could not find FCALFastSimDedicatedSD, but fast sim was configured" ); - } - } - - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.h deleted file mode 100644 index bda3d8100b17..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4FCALSDTool.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4FCALSDTOOL_H -#define LARG4FCALSDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "LArSimEvent/LArHitContainer.h" - -class LArG4SimpleSD; - -/// @class LArG4FCALSDTool -/// @brief SD tool which manages the LAr forward calo sensitive detectors. -/// -/// NOTE: this design has some multi-threading issues which will need to be -/// addressed. -/// -class LArG4FCALSDTool : public LArG4SDTool -{ - public: - /// Constructor - LArG4FCALSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - /// Destructor - virtual ~LArG4FCALSDTool() {} - - /// Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - /// Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ - //StatusCode SetupEvent() override final; - - private: - /// The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<LArHitContainer> m_HitColl; - - // List of volumes for each SD and their corresponding SD - std::vector<std::string> m_fcal1Volumes; - std::vector<std::string> m_fcal2Volumes; - std::vector<std::string> m_fcal3Volumes; - LArG4SimpleSD* m_fcal1SD; - LArG4SimpleSD* m_fcal2SD; - LArG4SimpleSD* m_fcal3SD; - -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.cc deleted file mode 100644 index 855388baf31e..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4HECSDTool.h" -#include "LArG4Code/LArG4SimpleSD.h" - -#include "LArG4Code/LArG4Hit.h" - -#include "LArG4HEC/LArHECCalculator.h" -#include "LArG4HEC/LArHECLocalCalculator.h" -#include "LArG4HEC/LArHECWheelCalculator.h" - -#include "CxxUtils/make_unique.h" - -LArG4HECSDTool::LArG4HECSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArHitHEC") - //, m_sliceSD(nullptr) - //, m_localSD(nullptr) - , m_wheelSD(nullptr) -{ - //declareProperty("SliceVolumes",m_sliceVolumes); - //declareProperty("LocalVolumes",m_localVolumes); - declareProperty("WheelVolumes",m_wheelVolumes); - // Only Wheel volumes? Why are the others there? - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4HECSDTool::initializeSD() -{ - //m_sliceSD = new LArG4SimpleSD( "LAr::HEC::Module::Depth::Slice" , LArHECCalculator::GetCalculator() , m_timeBinType , m_timeBinWidth ); - //m_localSD = new LArG4SimpleSD( "LAr::HEC::Module::Depth::Slice::Local" , LArHECLocalCalculator::GetCalculator() , m_timeBinType , m_timeBinWidth ); - m_wheelSD = new LArG4SimpleSD( "LAr::HEC::Module::Depth::Slice::Wheel" , LArHECWheelCalculator::GetCalculator() , m_timeBinType , m_timeBinWidth ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - //configuration[m_sliceSD] = &m_sliceVolumes; - //configuration[m_localSD] = &m_localVolumes; - configuration[m_wheelSD] = &m_wheelVolumes; - setupAllSDs(configuration); - - // Make sure the ID helpers are all set up - //setupHelpers(m_sliceSD); - //setupHelpers(m_localSD); - setupHelpers(m_wheelSD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4HECSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<LArHitContainer>(m_HitColl.name()); - // Hand this collection name off to the SDs. They will be writing to the - // collection, but only one at a time! - //m_sliceSD->EndOfAthenaEvent( &*m_HitColl ); - //m_localSD->EndOfAthenaEvent( &*m_HitColl ); - m_wheelSD->EndOfAthenaEvent( &*m_HitColl ); - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.h deleted file mode 100644 index 43cca9aa718d..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4HECSDTool.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4HECSDTOOL_H -#define LARG4HECSDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "LArSimEvent/LArHitContainer.h" - -class LArG4SimpleSD; - -/// @class LArG4HECSDTool -/// @brief SD tool which manages the LAr hadronic endcap sensitive detectors. -/// -/// NOTE: this design has some multi-threading issues which will need to be -/// addressed. -/// -class LArG4HECSDTool : public LArG4SDTool -{ - public: - /// Constructor - LArG4HECSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - /// Destructor - virtual ~LArG4HECSDTool() {} - - /// Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - /// Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ - //StatusCode SetupEvent() override final; - - private: - /// The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<LArHitContainer> m_HitColl; - - std::vector<std::string> m_sliceVolumes; - std::vector<std::string> m_localVolumes; - std::vector<std::string> m_wheelVolumes; - //LArG4SimpleSD* m_sliceSD; - //LArG4SimpleSD* m_localSD; - LArG4SimpleSD* m_wheelSD; - -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.cc deleted file mode 100644 index a4e68f61cdae..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.cc +++ /dev/null @@ -1,136 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4InactiveSDTool.h" - -#include "LArG4Code/LArG4CalibSD.h" - -#include "LArG4Code/LArG4Hit.h" -#include "CxxUtils/make_unique.h" - -// All the calculators that I need -#include "LArG4Barrel/LArBarrelCalibrationCalculator.h" -#include "LArG4Barrel/PresamplerCalibrationCalculator.h" -#include "LArG4EC/CalibrationCalculator.h" -#include "LArG4HEC/LArHECCalibrationWheelCalculator.h" -#include "LArG4FCAL/LArFCAL1CalibCalculator.h" -#include "LArG4FCAL/LArFCAL2CalibCalculator.h" -#include "LArG4FCAL/LArFCAL3CalibCalculator.h" -#include "LArG4MiniFCAL/MiniFCALCalibrationCalculator.h" - - -LArG4InactiveSDTool::LArG4InactiveSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArCalibrationHitInactive") - , m_barPreSD(nullptr) - , m_barSD(nullptr) - , m_ECPosInSD(nullptr) - , m_ECPosOutSD(nullptr) - , m_ECNegInSD(nullptr) - , m_ECNegOutSD(nullptr) - , m_HECWheelSD(nullptr) - , m_fcal1SD(nullptr) - , m_fcal2SD(nullptr) - , m_fcal3SD(nullptr) - , m_miniMomSD(nullptr) - , m_miniSD(nullptr) - , m_miniLaySD(nullptr) -{ - declareProperty("BarrelPreVolumes",m_barPreVolumes); - declareProperty("BarrelVolumes",m_barVolumes); - declareProperty("ECPosInVolumes",m_ECPosInVolumes); - declareProperty("ECPosOutVolumes",m_ECPosOutVolumes); - declareProperty("ECNegInVolumes",m_ECNegInVolumes); - declareProperty("ECNegOutVolumes",m_ECNegOutVolumes); - //declareProperty("HECVolumes",m_HECVolumes={"LAr::HEC::Inactive"}); - //declareProperty("HECLocalVolumes",m_HECLocVolumes={"LAr::HEC::Local::Inactive"}); - declareProperty("HECWheelVolumes",m_HECWheelVolumes); - declareProperty("FCAL1Volumes",m_fcal1Volumes); - declareProperty("FCAL2Volumes",m_fcal2Volumes); - declareProperty("FCAL3Volumes",m_fcal3Volumes); - declareProperty("MiniMomVolumes",m_miniMomVolumes); - declareProperty("MiniVolumes",m_miniVolumes); - declareProperty("MiniLayVolumes",m_miniLayVolumes); - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4InactiveSDTool::initializeSD() -{ - // Lots of singleton calculators !!! - m_barPreSD = new LArG4CalibSD( "LAr::Barrel::Presampler::Inactive" , new LArG4::BarrelPresampler::CalibrationCalculator() , m_doPID ); - m_barSD = new LArG4CalibSD( "LAr::Barrel::Inactive" , new LArG4::Barrel::CalibrationCalculator() , m_doPID ); - m_ECPosInSD = new LArG4CalibSD( "LAr::EMEC::Pos::InnerWheel::Inactive" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, 1) , m_doPID ); - m_ECPosOutSD = new LArG4CalibSD( "LAr::EMEC::Pos::OuterWheel::Inactive" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, 1) , m_doPID ); - m_ECNegInSD = new LArG4CalibSD( "LAr::EMEC::Neg::InnerWheel::Inactive" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::InnerAbsorberWheel, -1) , m_doPID ); - m_ECNegOutSD = new LArG4CalibSD( "LAr::EMEC::Neg::OuterWheel::Inactive" , new LArG4::EC::CalibrationCalculator(LArWheelCalculator::OuterAbsorberWheel, -1) , m_doPID ); - //m_HECSD = new LArG4CalibSD( "LAr::HEC::Inactive" , new LArG4::HEC::CalibrationCalculator(LArG4::HEC::kInactive) , m_doPID ); - //m_HECLocSD = new LArG4CalibSD( "LAr::HEC::Local::Inactive" , new LArG4::HEC::LocalCalibrationCalculator(LArG4::HEC::kLocInactive) , m_doPID ); - m_HECWheelSD = new LArG4CalibSD( "LAr::HEC::Wheel::Inactive" , new LArG4::HEC::LArHECCalibrationWheelCalculator(LArG4::HEC::kWheelInactive) , m_doPID ); - m_fcal1SD = new LArG4CalibSD( "LAr::FCAL::Inactive1" , LArG4::FCAL::LArFCAL1CalibCalculator::GetCalculator() , m_doPID ); - m_fcal2SD = new LArG4CalibSD( "LAr::FCAL::Inactive2" , LArG4::FCAL::LArFCAL2CalibCalculator::GetCalculator() , m_doPID ); - m_fcal3SD = new LArG4CalibSD( "LAr::FCAL::Inactive3" , LArG4::FCAL::LArFCAL3CalibCalculator::GetCalculator() , m_doPID ); - m_miniMomSD = new LArG4CalibSD( "MiniFCALMother::Inactive" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kInactive) , m_doPID ); - m_miniSD = new LArG4CalibSD( "MiniFCAL::Inactive" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kInactive) , m_doPID ); - m_miniLaySD = new LArG4CalibSD( "MiniFCAL::Layer::Inactive" , new LArG4::MiniFCAL::MiniFCALCalibrationCalculator(LArG4::MiniFCAL::kInactive) , m_doPID ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_barPreSD] = &m_barPreVolumes; - configuration[m_barSD] = &m_barVolumes; - configuration[m_ECPosInSD] = &m_ECPosInVolumes; - configuration[m_ECPosOutSD] = &m_ECPosOutVolumes; - configuration[m_ECNegInSD] = &m_ECNegInVolumes; - configuration[m_ECNegOutSD] = &m_ECNegOutVolumes; - //configuration[m_HECSD] = &m_HECVolumes; - //configuration[m_HECLocSD] = &m_HECLocVolumes; - configuration[m_HECWheelSD] = &m_HECWheelVolumes; - configuration[m_fcal1SD] = &m_fcal1Volumes; - configuration[m_fcal2SD] = &m_fcal2Volumes; - configuration[m_fcal3SD] = &m_fcal3Volumes; - configuration[m_miniMomSD] = &m_miniMomVolumes; - configuration[m_miniSD] = &m_miniVolumes; - configuration[m_miniLaySD] = &m_miniLayVolumes; - setupAllSDs(configuration); - - // Make sure the ID helpers are all set up - setupHelpers(m_barPreSD); - setupHelpers(m_barSD); - setupHelpers(m_ECPosInSD); - setupHelpers(m_ECPosOutSD); - setupHelpers(m_ECNegInSD); - setupHelpers(m_ECNegOutSD); - //setupHelpers(m_HECSD); - //setupHelpers(m_HECLocSD); - setupHelpers(m_HECWheelSD); - setupHelpers(m_fcal1SD); - setupHelpers(m_fcal2SD); - setupHelpers(m_fcal3SD); - setupHelpers(m_miniMomSD); - setupHelpers(m_miniSD); - setupHelpers(m_miniLaySD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4InactiveSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<CaloCalibrationHitContainer>(m_HitColl.name()); - m_barPreSD->EndOfAthenaEvent( &*m_HitColl ); - m_barSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECPosInSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECPosOutSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECNegInSD ->EndOfAthenaEvent( &*m_HitColl ); - m_ECNegOutSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_HECSD ->EndOfAthenaEvent( &*m_HitColl ); - //m_HECLocSD ->EndOfAthenaEvent( &*m_HitColl ); - m_HECWheelSD ->EndOfAthenaEvent( &*m_HitColl ); - m_fcal1SD ->EndOfAthenaEvent( &*m_HitColl ); - m_fcal2SD ->EndOfAthenaEvent( &*m_HitColl ); - m_fcal3SD ->EndOfAthenaEvent( &*m_HitColl ); - m_miniMomSD ->EndOfAthenaEvent( &*m_HitColl ); - m_miniSD ->EndOfAthenaEvent( &*m_HitColl ); - m_miniLaySD ->EndOfAthenaEvent( &*m_HitColl ); - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.h deleted file mode 100644 index b1500f11e3de..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4InactiveSDTool.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4INACTIVESDTOOL_H -#define LARG4INACTIVESDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "CaloSimEvent/CaloCalibrationHitContainer.h" - -class LArG4CalibSD; - -class LArG4InactiveSDTool : public LArG4SDTool -{ - public: - // Constructor - LArG4InactiveSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - // Destructor - virtual ~LArG4InactiveSDTool() {} - - // Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - // Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ -// StatusCode SetupEvent() override final; - - private: - // The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<CaloCalibrationHitContainer> m_HitColl; - - // The list of volumes and the corresponding SDs - std::vector<std::string> m_barPreVolumes; - std::vector<std::string> m_barVolumes; - std::vector<std::string> m_ECPosInVolumes; - std::vector<std::string> m_ECPosOutVolumes; - std::vector<std::string> m_ECNegInVolumes; - std::vector<std::string> m_ECNegOutVolumes; - std::vector<std::string> m_HECWheelVolumes; - std::vector<std::string> m_fcal1Volumes; - std::vector<std::string> m_fcal2Volumes; - std::vector<std::string> m_fcal3Volumes; - std::vector<std::string> m_miniMomVolumes; - std::vector<std::string> m_miniVolumes; - std::vector<std::string> m_miniLayVolumes; - LArG4CalibSD* m_barPreSD; - LArG4CalibSD* m_barSD; - LArG4CalibSD* m_ECPosInSD; - LArG4CalibSD* m_ECPosOutSD; - LArG4CalibSD* m_ECNegInSD; - LArG4CalibSD* m_ECNegOutSD; - LArG4CalibSD* m_HECWheelSD; - LArG4CalibSD* m_fcal1SD; - LArG4CalibSD* m_fcal2SD; - LArG4CalibSD* m_fcal3SD; - LArG4CalibSD* m_miniMomSD; - LArG4CalibSD* m_miniSD; - LArG4CalibSD* m_miniLaySD; - -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.cc deleted file mode 100644 index 2741c04dac65..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#include "LArG4MiniFCALSDTool.h" -#include "LArG4Code/LArG4SimpleSD.h" - -#include "LArG4Code/LArG4Hit.h" - -#include "LArG4MiniFCAL/MiniFCALCalculator.h" - -#include "CxxUtils/make_unique.h" - -LArG4MiniFCALSDTool::LArG4MiniFCALSDTool(const std::string& type, const std::string& name, - const IInterface *parent) - : LArG4SDTool(type,name,parent) - , m_HitColl("LArHitMiniFCAL") // I don't know what this should be!!! - , m_miniSD(nullptr) -{ - declareProperty("MiniVolumes",m_miniVolumes); - declareInterface<ISensitiveDetector>(this); -} - -StatusCode LArG4MiniFCALSDTool::initializeSD() -{ - m_miniSD = new LArG4SimpleSD( "MiniFCAL::Wafer", MiniFCALCalculator::GetCalculator(), - m_timeBinType , m_timeBinWidth ); - - std::map<G4VSensitiveDetector*,std::vector<std::string>*> configuration; - configuration[m_miniSD] = &m_miniVolumes; - setupAllSDs(configuration); - - // Make sure the ID helpers are all set up - setupHelpers(m_miniSD); - - return StatusCode::SUCCESS; -} - -StatusCode LArG4MiniFCALSDTool::Gather() -{ - // In this case, *unlike* other SDs, the *tool* owns the collection - if (!m_HitColl.isValid()) m_HitColl = CxxUtils::make_unique<LArHitContainer>(m_HitColl.name()); - // Hand this collection name off to the SDs. They will be writing to the - // collection, but only one at a time! - m_miniSD->EndOfAthenaEvent( &*m_HitColl ); - return StatusCode::SUCCESS; -} diff --git a/LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.h deleted file mode 100644 index 704df373fa30..000000000000 --- a/LArCalorimeter/LArG4/LArG4SD/src/LArG4MiniFCALSDTool.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -#ifndef LARG4MINIFCALSDTOOL_H -#define LARG4MINIFCALSDTOOL_H - -#include "LArG4Code/LArG4SDTool.h" -#include <string> -#include <vector> - -#include "StoreGate/WriteHandle.h" -#include "LArSimEvent/LArHitContainer.h" - -class LArG4SimpleSD; - -class LArG4MiniFCALSDTool : public LArG4SDTool -{ - public: - // Constructor - LArG4MiniFCALSDTool(const std::string& type, const std::string& name, const IInterface *parent); - - // Destructor - virtual ~LArG4MiniFCALSDTool() {} - - // Method in which all the SDs are created and assigned to the relevant volumes - StatusCode initializeSD() override final; - - // Calls down to all the SDs to get them to pack their hits into a central collection - StatusCode Gather() override final; - - /** Beginning of an athena event. This is where collection initialization should happen. - If we are using a WriteHandle, then this could be empty. */ -// StatusCode SetupEvent() override final; - - private: - // The actual hit container - here because the base class is for both calib and standard SD tools - SG::WriteHandle<LArHitContainer> m_HitColl; - - // The list of volumes per SD and the corresponding SD - std::vector<std::string> m_miniVolumes; - LArG4SimpleSD* m_miniSD; - -}; - -#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.cc b/LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.cc new file mode 100644 index 000000000000..40c1dec44d1e --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.cc @@ -0,0 +1,48 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "MiniFCALSDTool.h" + +#include "LArG4Code/SDWrapper.h" + +namespace LArG4 +{ + + //--------------------------------------------------------------------------- + // Constructor + //--------------------------------------------------------------------------- + MiniFCALSDTool::MiniFCALSDTool(const std::string& type, const std::string& name, + const IInterface* parent) + : SimpleSDTool(type, name, parent), + m_hitCollName("LArHitMiniFCAL") + , m_calc("MiniFCALCalculator", name) + { + declareProperty("HitCollectionName", m_hitCollName); + declareProperty("MiniVolumes", m_miniVolumes); + + declareProperty("MiniFCALCalculator", m_calc); + } + + StatusCode MiniFCALSDTool::initializeCalculators() + { + ATH_CHECK(m_calc.retrieve()); + return StatusCode::SUCCESS; + } + + //--------------------------------------------------------------------------- + // Create the SD wrapper for current worker thread + //--------------------------------------------------------------------------- + G4VSensitiveDetector* MiniFCALSDTool::makeSD() + { + // Create the wrapper + auto sdWrapper = new SimpleSDWrapper("LArMiniFCALSDWrapper", m_hitCollName); + + // Add the SDs + sdWrapper->addSD( makeOneSD("MiniFCAL::Wafer", &*m_calc, m_miniVolumes) ); + + // Return the wrapper as my SD + return sdWrapper; + } + +} // namespace LArG4 diff --git a/LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.h b/LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.h new file mode 100644 index 000000000000..2fde7470afb8 --- /dev/null +++ b/LArCalorimeter/LArG4/LArG4SD/src/MiniFCALSDTool.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef LARG4SD_MINIFCALSDTOOL_H +#define LARG4SD_MINIFCALSDTOOL_H + +// System includes +#include <string> +#include <vector> + +// Project includes +#include "LArG4Code/SimpleSDTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" + +namespace LArG4 +{ + + /// @class MiniFCALSDTool + /// @brief SD tool which manages the Mini FCAL sensitive detectors. + /// + /// NOTE: this design is in flux. + /// + class MiniFCALSDTool : public SimpleSDTool + { + + public: + + // Constructor + MiniFCALSDTool(const std::string& type, const std::string& name, + const IInterface* parent); + + private: + + // Initialize Calculator Services + StatusCode initializeCalculators() override final; + + /// Create the SD wrapper for current worker thread + G4VSensitiveDetector* makeSD() override final; + + /// Hit collection name + std::string m_hitCollName; + + /// The list of volumes + std::vector<std::string> m_miniVolumes; + + ServiceHandle<ILArCalculatorSvc> m_calc; //MiniFCALCalculator::GetCalculator() + + }; // class MiniFCALSDTool + +} // namespace LArG4 + +#endif diff --git a/LArCalorimeter/LArG4/LArG4SD/src/components/LArG4SD_entries.cxx b/LArCalorimeter/LArG4/LArG4SD/src/components/LArG4SD_entries.cxx index 711a78fd1d3b..6ca192b78f73 100644 --- a/LArCalorimeter/LArG4/LArG4SD/src/components/LArG4SD_entries.cxx +++ b/LArCalorimeter/LArG4/LArG4SD/src/components/LArG4SD_entries.cxx @@ -1,19 +1,24 @@ #include "GaudiKernel/DeclareFactoryEntries.h" -#include "../LArG4EMBSDTool.h" -#include "../LArG4EMECSDTool.h" -#include "../LArG4HECSDTool.h" -#include "../LArG4FCALSDTool.h" -#include "../LArG4MiniFCALSDTool.h" -#include "../LArG4InactiveSDTool.h" -#include "../LArG4ActiveSDTool.h" -#include "../LArG4DeadSDTool.h" +// MT-friendly LAr SD tools +#include "../EMBSDTool.h" +#include "../EMECSDTool.h" +#include "../HECSDTool.h" +#include "../FCALSDTool.h" +#include "../MiniFCALSDTool.h" +#include "../ActiveSDTool.h" +#include "../InactiveSDTool.h" +#include "../DeadSDTool.h" -DECLARE_TOOL_FACTORY( LArG4EMBSDTool ) -DECLARE_TOOL_FACTORY( LArG4EMECSDTool ) -DECLARE_TOOL_FACTORY( LArG4HECSDTool ) -DECLARE_TOOL_FACTORY( LArG4FCALSDTool ) -DECLARE_TOOL_FACTORY( LArG4MiniFCALSDTool ) -DECLARE_TOOL_FACTORY( LArG4InactiveSDTool ) -DECLARE_TOOL_FACTORY( LArG4ActiveSDTool ) -DECLARE_TOOL_FACTORY( LArG4DeadSDTool ) \ No newline at end of file +#include "../CalibrationDefaultCalculator.h" + +DECLARE_TOOL_FACTORY( LArG4::EMBSDTool ) +DECLARE_TOOL_FACTORY( LArG4::EMECSDTool ) +DECLARE_TOOL_FACTORY( LArG4::HECSDTool ) +DECLARE_TOOL_FACTORY( LArG4::FCALSDTool ) +DECLARE_TOOL_FACTORY( LArG4::MiniFCALSDTool ) +DECLARE_TOOL_FACTORY( LArG4::ActiveSDTool ) +DECLARE_TOOL_FACTORY( LArG4::InactiveSDTool ) +DECLARE_TOOL_FACTORY( LArG4::DeadSDTool ) + +DECLARE_SERVICE_FACTORY( LArG4::CalibrationDefaultCalculator ) diff --git a/LArCalorimeter/LArG4/LArG4Validation/cmt/requirements b/LArCalorimeter/LArG4/LArG4Validation/cmt/requirements deleted file mode 100755 index 422beaa907cb..000000000000 --- a/LArCalorimeter/LArG4/LArG4Validation/cmt/requirements +++ /dev/null @@ -1,56 +0,0 @@ -package LArG4Validation - - -author Joe Boudreau - -# This is the same boilerplate used for every executable in the universe: -use AtlasPolicy AtlasPolicy-* -use GaudiInterface GaudiInterface-* External -use AtlasROOT AtlasROOT-* External -use AthenaBaseComps AthenaBaseComps-* Control - -# These should be private -private -use StoreGate StoreGate-* Control - -# This is the same boilerplate used for every executable in the universe: -use AtlasCLHEP AtlasCLHEP-* External -use CaloDetDescr CaloDetDescr-* Calorimeter -use AthenaBaseComps AthenaBaseComps-* Control - -# This is for the Monte Carlo Truth Information. -use GeneratorObjects GeneratorObjects-* Generators - -# This is for the B Field Service -use MagFieldInterfaces MagFieldInterfaces-* MagneticField - -# This is for the PartPropSvc -use HepPDT v* LCG_Interfaces - -# To access electron container in AOD -use egammaEvent egammaEvent-* Reconstruction/egamma - -# This is to access geometrical services: -use GeoModelKernel GeoModelKernel-* DetectorDescription/GeoModel -use GeoAdaptors GeoAdaptors-* DetectorDescription/GeoModel - -use CaloIdentifier CaloIdentifier-* Calorimeter -use EventInfo EventInfo-* Event -use LArSimEvent LArSimEvent-* LArCalorimeter - -# For XML validation -use TestPolicy TestPolicy-* -apply_pattern validate_xml -end_private - -library LArG4Validation *.cxx -s=components *.cxx -apply_pattern component_library -apply_pattern declare_scripts files="AODElectronContainerReader.py LArG4ValidationGenerate.py LArG4AODNtuplePlotter.py LArG4ValidationPlotter.py" -apply_pattern declare_python_modules files="*.py" -apply_pattern declare_joboptions files="*.py" - -#macro_append cppflags " -w -g -O0 " - -# For RTT tests: -macro LArG4Validation_TestConfiguration "../test/LArG4Validation_TestConfiguration.xml" -apply_pattern declare_runtime extras="../test/*.xml" diff --git a/LArCalorimeter/LArGeoModel/LArGeoEndcap/src/EMECSupportConstruction.cxx b/LArCalorimeter/LArGeoModel/LArGeoEndcap/src/EMECSupportConstruction.cxx index 2600572d2bb3..600e29f7e686 100755 --- a/LArCalorimeter/LArGeoModel/LArGeoEndcap/src/EMECSupportConstruction.cxx +++ b/LArCalorimeter/LArGeoModel/LArGeoEndcap/src/EMECSupportConstruction.cxx @@ -724,7 +724,7 @@ void EMECSupportConstruction::put_front_outer_barettes(GeoPhysVol *motherPhysica double dr = getNumber(m_DB_numbers, numbers, "DRabs", "PARVALUE", 41.4); // start of barrette rel to start of abs. double dx = getNumber(m_DB_numbers, numbers, "Labs", "PARVALUE", 1290.) / 2.; // length of the connected part assert(rmn + dr > rminFOB && rmn + dr + dx*2 < rmaxFOB); - double dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::OuterAbsorberWheel); + double dy = LArWheelCalculator::GetFanHalfThickness(LArG4::OuterAbsorberWheel); const double r0A = rmn + dr + dx; GeoBox *shapeFOBA = new GeoBox(dx, dy, dzFOB); GeoLogVol *logicalFOBA = new GeoLogVol(name, shapeFOBA, m_G10FeOuter); @@ -736,7 +736,7 @@ void EMECSupportConstruction::put_front_outer_barettes(GeoPhysVol *motherPhysica dr = getNumber(m_DB_numbers, numbers, "DRele", "PARVALUE", 48.4); dx = getNumber(m_DB_numbers, numbers, "Lele", "PARVALUE", 1283.8) / 2.; assert(rmn + dr > rminFOB && rmn + dr + dx*2 < rmaxFOB); - dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::OuterElectrodWheel); + dy = LArWheelCalculator::GetFanHalfThickness(LArG4::OuterElectrodWheel); const double r0E = rmn + dr + dx; double x0 = r0E * cos(dfi/2.); double y0 = r0E * sin(dfi/2.); @@ -821,7 +821,7 @@ void EMECSupportConstruction::put_front_inner_barettes(GeoPhysVol *motherPhysica double dr = getNumber(m_DB_numbers, numbers, "DRabs", "PARVALUE", 75.6); // start of barrette rel to start of abs. double dx = getNumber(m_DB_numbers, numbers, "Labs", "PARVALUE", 192.) / 2.; // length of the connected part assert(rmn + dr > rminFIB && rmn + dr + dx*2 < rmaxFIB); - double dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::InnerAbsorberWheel); + double dy = LArWheelCalculator::GetFanHalfThickness(LArG4::InnerAbsorberWheel); const double r0A = rmn + dr + dx; GeoBox *shapeFIBA = new GeoBox(dx, dy, dzFIB); GeoLogVol *logicalFIBA = new GeoLogVol(name, shapeFIBA, m_G10FeInner); @@ -833,7 +833,7 @@ void EMECSupportConstruction::put_front_inner_barettes(GeoPhysVol *motherPhysica dr = getNumber(m_DB_numbers, numbers, "DRele", "PARVALUE", 106.3); dx = getNumber(m_DB_numbers, numbers, "Lele", "PARVALUE", 144.4) / 2.; assert(rmn + dr > rminFIB && rmn + dr + dx*2 < rmaxFIB); - dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::InnerElectrodWheel); + dy = LArWheelCalculator::GetFanHalfThickness(LArG4::InnerElectrodWheel); const double r0E = rmn + dr + dx; double x0 = r0E * cos(dfi/2.); double y0 = r0E * sin(dfi/2.); @@ -918,7 +918,7 @@ void EMECSupportConstruction::put_back_outer_barettes(GeoPhysVol *motherPhysical double dr = getNumber(m_DB_numbers, numbers, "DRabs", "PARVALUE", 42.1); // start of barrette rel to start of abs double dx = getNumber(m_DB_numbers, numbers, "Labs", "PARVALUE", 1229.) / 2.; // length of the connected part assert(rmn + dr > rminBOB && rmn + dr + dx * 2 < rmaxBOB); - double dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::OuterAbsorberWheel); + double dy = LArWheelCalculator::GetFanHalfThickness(LArG4::OuterAbsorberWheel); const double r0A = rmn + dr + dx; GeoBox *shapeBOBA = new GeoBox(dx, dy, dzBOB); GeoLogVol *logicalBOBA = new GeoLogVol(name, shapeBOBA, m_G10FeOuter); @@ -930,7 +930,7 @@ void EMECSupportConstruction::put_back_outer_barettes(GeoPhysVol *motherPhysical dr = getNumber(m_DB_numbers, numbers, "DRele", "PARVALUE", 41.); dx = getNumber(m_DB_numbers, numbers, "Lele", "PARVALUE", 1246.9) / 2.; assert(rmn + dr > rminBOB && rmn + dr + dx*2 < rmaxBOB); - dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::OuterElectrodWheel); + dy = LArWheelCalculator::GetFanHalfThickness(LArG4::OuterElectrodWheel); double r0E = rmn + dr + dx; double y0 = r0E * sin(dfi/2.); double x0 = r0E * cos(dfi/2.); @@ -1017,7 +1017,7 @@ void EMECSupportConstruction::put_back_inner_barettes(GeoPhysVol *motherPhysical double rmn = getNumber(m_DB_numbers, numbers, "R0", "PARVALUE", 344.28); // start of abs. double dr = getNumber(m_DB_numbers, numbers, "DRabs", "PARVALUE", 56.1); // start of barrette rel to start of abs. double dx = getNumber(m_DB_numbers, numbers, "Labs", "PARVALUE", 255.) / 2.; - double dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::InnerAbsorberWheel); + double dy = LArWheelCalculator::GetFanHalfThickness(LArG4::InnerAbsorberWheel); assert(rmn+dr>rminBIB && rmn+dr+dx*2.<rmaxBIB); const double r0A = rmn + dr + dx; GeoBox *shapeBIBA = new GeoBox(dx, dy, dzBIB); @@ -1031,7 +1031,7 @@ void EMECSupportConstruction::put_back_inner_barettes(GeoPhysVol *motherPhysical dr = getNumber(m_DB_numbers, numbers, "DRele", "PARVALUE", 76.6); dx = getNumber(m_DB_numbers, numbers, "Lele", "PARVALUE", 208.9) / 2.; assert(rmn + dr > rminBIB && rmn + dr + dx * 2. < rmaxBIB); - dy = LArWheelCalculator::GetFanHalfThickness(LArWheelCalculator::InnerElectrodWheel); + dy = LArWheelCalculator::GetFanHalfThickness(LArG4::InnerElectrodWheel); const double r0E = rmn + dr + dx; double y0 = r0E * sin(dfi * 0.5); double x0 = r0E * cos(dfi * 0.5); diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py index c80503bbf56f..a03a92b65d61 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py @@ -271,21 +271,16 @@ class AtlasSimSkeleton(SimSkeleton): """ AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_GeoSD :: starting') - ## Inner detector - if DetFlags.ID_on(): - if DetFlags.geometry.TRT_on(): - AtlasG4Eng.G4Eng.read_XML("TRgeomodelgeometry.xml") # FIXME need to find a better way to do this - ## Calorimeters - if DetFlags.Calo_on(): - ## LAr - if DetFlags.geometry.LAr_on(): - from G4AtlasApps.SimFlags import simFlags - # if this is an ISF run, allow the collections on store gate to be modified - # by other algorithms (i.e. set them non-const) - allowSGMods = True if simFlags.ISFRun else False - from atlas_calo import PyLArG4RunControler - lArG4RunControl = PyLArG4RunControler('PyLArG4RunControl', 'LArG4RunControlDict', allowMods=allowSGMods) + ##if DetFlags.Calo_on(): + ## ## LAr + ## if DetFlags.geometry.LAr_on(): + ## from G4AtlasApps.SimFlags import simFlags + ## # if this is an ISF run, allow the collections on store gate to be modified + ## # by other algorithms (i.e. set them non-const) + ## allowSGMods = True if simFlags.ISFRun else False + ## from atlas_calo import PyLArG4RunControler + ## lArG4RunControl = PyLArG4RunControler('PyLArG4RunControl', 'LArG4RunControlDict', allowMods=allowSGMods) AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_GeoSD :: done') diff --git a/Simulation/G4Atlas/G4AtlasTools/G4AtlasTools/SensitiveDetectorBase.h b/Simulation/G4Atlas/G4AtlasTools/G4AtlasTools/SensitiveDetectorBase.h index 6d5502f9c87f..5c356512ba13 100644 --- a/Simulation/G4Atlas/G4AtlasTools/G4AtlasTools/SensitiveDetectorBase.h +++ b/Simulation/G4Atlas/G4AtlasTools/G4AtlasTools/SensitiveDetectorBase.h @@ -70,6 +70,11 @@ class SensitiveDetectorBase : virtual public ISensitiveDetector, public AthAlgTo protected: + /// @brief Assign SD to a list of volumes + /** This method supports wild card matching */ + StatusCode assignSD(G4VSensitiveDetector* sd, + const std::vector<std::string>& volumes) const; + /// @brief Retrieve the current SD. /** In AthenaMT, this means the thread-local SD. Otherwise, it is simply the single SD. */ diff --git a/Simulation/G4Atlas/G4AtlasTools/src/SensitiveDetectorBase.cxx b/Simulation/G4Atlas/G4AtlasTools/src/SensitiveDetectorBase.cxx index 236573a47c43..96dfeed22788 100644 --- a/Simulation/G4Atlas/G4AtlasTools/src/SensitiveDetectorBase.cxx +++ b/Simulation/G4Atlas/G4AtlasTools/src/SensitiveDetectorBase.cxx @@ -2,6 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ +// STL includes +#include <sstream> + // Base class #include "G4AtlasTools/SensitiveDetectorBase.h" @@ -15,6 +18,7 @@ #include "G4AtlasTools/G4MultiSensitiveDetector.hh" + SensitiveDetectorBase::SensitiveDetectorBase(const std::string& type, const std::string& name, const IInterface* parent) @@ -33,6 +37,15 @@ StatusCode SensitiveDetectorBase::initializeSD() { ATH_MSG_VERBOSE( name() << "::initializeSD()" ); + // Sanity check for volume configuration problems. + // It would be better to have a more robust solution for this. + if(m_volumeNames.empty() != m_noVolumes) { + ATH_MSG_ERROR("Initializing SD from " << name() << ", NoVolumes = " + << (m_noVolumes? "true" : "false") << ", but LogicalVolumeNames = " + << m_volumeNames); + return StatusCode::FAILURE; + } + // Make sure SD isn't already registered if(getSD()) { @@ -49,64 +62,73 @@ StatusCode SensitiveDetectorBase::initializeSD() } setSD(sd); - // Set the verbosity information on this thing - if(msgLvl(MSG::VERBOSE)) getSD()->SetVerboseLevel(10); - else if(msgLvl(MSG::DEBUG)) getSD()->SetVerboseLevel(5); + // Assign the SD to our list of volumes + ATH_CHECK( assignSD( getSD(), m_volumeNames ) ); - // Grab the user detector construction - // G4RunManager* rm = G4RunManager::GetRunManager(); - // G4VUserDetectorConstruction* dc=rm->GetUserDetectorConstruction(); + ATH_MSG_DEBUG( "Initialized and added SD " << name() ); + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------------------- +// Assign an SD to a list of volumes +//----------------------------------------------------------------------------- +StatusCode SensitiveDetectorBase:: +assignSD(G4VSensitiveDetector* sd, const std::vector<std::string>& volumes) const +{ + // Propagate verbosity setting to the SD + if(msgLvl(MSG::VERBOSE)) sd->SetVerboseLevel(10); + else if(msgLvl(MSG::DEBUG)) sd->SetVerboseLevel(5); // Add the sensitive detector to the SD manager in G4 for SDs, // even if it has no volumes associated to it. - G4SDManager* SDmanager = G4SDManager::GetSDMpointer(); - SDmanager->AddNewDetector(getSD()); - if(!m_noVolumes) - { - // Go through the logical volumes and hook the SDs up - bool gotOne = false; - G4LogicalVolumeStore* logicalVolumeStore = G4LogicalVolumeStore::GetInstance(); - for (const auto& myvol : m_volumeNames) - { - int found = 0; - for (auto ilv : *logicalVolumeStore ) - { - if (ilv->GetName() == myvol.data()) - { - // Do not break on found to protect against multiple volumes - // with the same name - ++found; - SetSensitiveDetector( ilv, getSD() ); - gotOne = true; - } // Found a volume! - } // Loop over all the volumes in the geometry - // Give notice if we have missed a volume in here - if (0==found) - { - ATH_MSG_WARNING( "Volume " << myvol << - " not found in G4LogicalVolumeStore." ); - } - else - { - ATH_MSG_VERBOSE( found << " copies of LV " << myvol << - " found; SD " << name() << " assigned." ); - } - } // Loop over my volumes - - // Crash out if we have failed to assign a volume - this is bad news! - if (!gotOne) - { - ATH_MSG_ERROR( "Failed to assign *any* volume to SD " << name() << - " and expected at least one." ); - return StatusCode::FAILURE; + auto sdMgr = G4SDManager::GetSDMpointer(); + sdMgr->AddNewDetector(sd); + + if(!volumes.empty()) { + bool gotOne = false; + auto logicalVolumeStore = G4LogicalVolumeStore::GetInstance(); + for(const auto& volumeName : volumes) { + // Keep track of how many volumes we find with this name string. + // We allow for multiple matches. + int numFound = 0; + + // Find volumes with this name + for(auto* logVol : *logicalVolumeStore) { + //if( matchStrings( volumeName.data(), logVol->GetName() ) ) + if(logVol->GetName() == volumeName.c_str()) { + ++numFound; + SetSensitiveDetector(logVol, sd); } + } + // Warn if no volumes were found + if(numFound == 0) { + ATH_MSG_WARNING("Volume " << volumeName << + " not found in G4LogicalVolumeStore."); + } + else { + ATH_MSG_VERBOSE("Found " << numFound << " copies of LV " << volumeName << + "; SD " << sd->GetName() << " assigned."); + gotOne = true; + } + } - ATH_MSG_DEBUG( "Initialized and added SD " << name() ); + + // Abort if we have failed to assign any volume + if(!gotOne) { + ATH_MSG_ERROR( "Failed to assign *any* volume to SD " << name() << + " and expected at least one." ); + return StatusCode::FAILURE; + } + } + return StatusCode::SUCCESS; } -StatusCode -SensitiveDetectorBase::queryInterface(const InterfaceID& riid, void** ppvIf) +//----------------------------------------------------------------------------- +// Interface query boiler plate +//----------------------------------------------------------------------------- +StatusCode SensitiveDetectorBase:: +queryInterface(const InterfaceID& riid, void** ppvIf) { if ( riid == ISensitiveDetector::interfaceID() ) { @@ -142,8 +164,8 @@ void SensitiveDetectorBase::setSD(G4VSensitiveDetector* sd) #endif } -void SensitiveDetectorBase::SetSensitiveDetector -(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD) const +void SensitiveDetectorBase:: +SetSensitiveDetector(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD) const { // New Logic: allow for "multiple" SDs being attached to a single LV. // To do that we use a special proxy SD called G4MultiSensitiveDetector @@ -163,7 +185,11 @@ void SensitiveDetectorBase::SetSensitiveDetector } else { - const G4String msdname = "/MultiSD_"+logVol->GetName(); + // Construct a unique name using the volume address + std::stringstream ss; + ss << static_cast<const void*>(logVol); + const G4String msdname = "/MultiSD_" + logVol->GetName() + ss.str(); + //ATH_MSG_INFO("MultiSD name: " << msdname); msd = new G4MultiSensitiveDetector(msdname); // We need to register the proxy to have correct handling of IDs G4SDManager::GetSDMpointer()->AddNewDetector(msd); diff --git a/Simulation/G4Utilities/Geo2G4/src/LArWheelSolidInit.cxx b/Simulation/G4Utilities/Geo2G4/src/LArWheelSolidInit.cxx index 2fdcc32be326..a92d93051f4c 100644 --- a/Simulation/G4Utilities/Geo2G4/src/LArWheelSolidInit.cxx +++ b/Simulation/G4Utilities/Geo2G4/src/LArWheelSolidInit.cxx @@ -38,43 +38,43 @@ LArWheelSolid::LArWheelSolid(const G4String& name, LArWheelSolid_t type, ATH_MSG_INFO ( "compiled with private find_exit_point" ); #endif - LArWheelCalculator::LArWheelCalculator_t calc_type = LArWheelCalculator::LArWheelCalculator_t(0); + LArG4::LArWheelCalculator_t calc_type = LArG4::LArWheelCalculator_t(0); switch(m_Type){ case InnerAbsorberWheel: - calc_type = LArWheelCalculator::InnerAbsorberWheel; + calc_type = LArG4::InnerAbsorberWheel; break; case OuterAbsorberWheel: - calc_type = LArWheelCalculator::OuterAbsorberWheel; + calc_type = LArG4::OuterAbsorberWheel; break; case InnerElectrodWheel: - calc_type = LArWheelCalculator::InnerElectrodWheel; + calc_type = LArG4::InnerElectrodWheel; break; case OuterElectrodWheel: - calc_type = LArWheelCalculator::OuterElectrodWheel; + calc_type = LArG4::OuterElectrodWheel; break; case InnerAbsorberModule: - calc_type = LArWheelCalculator::InnerAbsorberModule; + calc_type = LArG4::InnerAbsorberModule; break; case OuterAbsorberModule: - calc_type = LArWheelCalculator::OuterAbsorberModule; + calc_type = LArG4::OuterAbsorberModule; break; case InnerElectrodModule: - calc_type = LArWheelCalculator::InnerElectrodModule; + calc_type = LArG4::InnerElectrodModule; break; case OuterElectrodModule: - calc_type = LArWheelCalculator::OuterElectrodModule; + calc_type = LArG4::OuterElectrodModule; break; case InnerGlueWheel: - calc_type = LArWheelCalculator::InnerGlueWheel; + calc_type = LArG4::InnerGlueWheel; break; case OuterGlueWheel: - calc_type = LArWheelCalculator::OuterGlueWheel; + calc_type = LArG4::OuterGlueWheel; break; case InnerLeadWheel: - calc_type = LArWheelCalculator::InnerLeadWheel; + calc_type = LArG4::InnerLeadWheel; break; case OuterLeadWheel: - calc_type = LArWheelCalculator::OuterLeadWheel; + calc_type = LArG4::OuterLeadWheel; break; default: G4Exception("LArWheelSolid", "UnknownSolidType", FatalException, diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/CMakeLists.txt b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/CMakeLists.txt index 5058790f0c82..7a02122f42e1 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/CMakeLists.txt +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/CMakeLists.txt @@ -17,11 +17,7 @@ atlas_depends_on_subdirs( PUBLIC Control/CxxUtils Control/AthenaBaseComps Generators/GeneratorObjects - LArCalorimeter/LArG4/LArG4Barrel LArCalorimeter/LArG4/LArG4Code - LArCalorimeter/LArG4/LArG4EC - LArCalorimeter/LArG4/LArG4FCAL - LArCalorimeter/LArG4/LArG4HEC Simulation/ISF/ISF_FastCaloSim/ISF_FastCaloSimEvent TileCalorimeter/TileG4/TileGeoG4SD ) @@ -36,7 +32,7 @@ atlas_add_component( ISF_Geant4UserActions src/*.cxx src/components/*.cxx INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${GEANT4_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} - LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} StoreGateLib SGtests GaudiKernel G4AtlasInterfaces G4AtlasToolsLib CaloDetDescrLib CaloIdentifier CxxUtils GeneratorObjects LArG4Barrel LArG4Code LArG4EC LArG4FCAL LArG4HEC ISF_FastCaloSimEvent TileGeoG4SDLib ) + LINK_LIBRARIES ${ROOT_LIBRARIES} ${XERCESC_LIBRARIES} ${GEANT4_LIBRARIES} ${CLHEP_LIBRARIES} StoreGateLib SGtests GaudiKernel G4AtlasInterfaces G4AtlasToolsLib CaloDetDescrLib CaloIdentifier CxxUtils GeneratorObjects LArG4Code ISF_FastCaloSimEvent TileGeoG4SDLib ) # Install files from the package: atlas_install_headers( ISF_Geant4UserActions ) diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamAction.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamAction.h index 3737ee832fc2..d706af05b15e 100755 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamAction.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamAction.h @@ -10,6 +10,7 @@ #include <vector> // athena simulation includes + #include "GaudiKernel/ServiceHandle.h" // forward declarations in namespaces @@ -20,7 +21,7 @@ namespace HepMC { class GenParticle; } // forward declarations in global namespace -class LArVCalculator; +class ILArCalculatorSvc; class G4VSolid; class G4AffineTransform; class LArG4SimpleSD; @@ -28,20 +29,20 @@ class LArIdentifierConverter; class TileGeoG4SDCalc; class CaloDetDescrManager; class LArEM_ID; - /** - * - * @short Class for collecting G4 hit information - * - * Collect and store Geant4 hit information, i.e. - * position, deposited energy and time, from hits - * - * @author Wolfgang Ehrenfeld, University of Hamburg, Germany - * @author Sasha Glazov, DESY Hamburg, Germany - * @author Zdenek Hubacek, CERN - * @author Geoffrey Gilles, Clermont-Ferrand, France - * - * - */ +/** + * + * @short Class for collecting G4 hit information + * + * Collect and store Geant4 hit information, i.e. + * position, deposited energy and time, from hits + * + * @author Wolfgang Ehrenfeld, University of Hamburg, Germany + * @author Sasha Glazov, DESY Hamburg, Germany + * @author Zdenek Hubacek, CERN + * @author Geoffrey Gilles, Clermont-Ferrand, France + * + * + */ #include "G4AtlasInterfaces/IBeginRunAction.h" #include "G4AtlasInterfaces/IEndRunAction.h" @@ -58,18 +59,33 @@ namespace G4UA{ class FastCaloSimParamAction: - public IBeginRunAction, public IEndRunAction, public IBeginEventAction, public IEndEventAction, public ISteppingAction + public IBeginRunAction, public IEndRunAction, public IBeginEventAction, public IEndEventAction, public ISteppingAction { - + public: - + struct Config { bool shift_lar_subhit=true; bool shorten_lar_step=false; - + // calculators + ILArCalculatorSvc* calculator_EMECIW_pos=nullptr; //!< pointer to EMEC positive inner wheel calculator + ILArCalculatorSvc* calculator_EMECIW_neg=nullptr; //!< pointer to EMEC negative inner wheel calculator + ILArCalculatorSvc* calculator_EMECOW_pos=nullptr; //!< pointer to EMEC positive outer wheel calculator + ILArCalculatorSvc* calculator_EMECOW_neg=nullptr; //!< pointer to EMEC negative outer wheel calculator + //ILArCalculatorSvc* calculator_BIB=nullptr; //!< pointer to EMEC Back Inner Barrette wheel calculator + ILArCalculatorSvc* calculator_BOB=nullptr; //!< pointer to EMEC Back Outer Barrette wheel calculator + ILArCalculatorSvc* calculator_EMB=nullptr; //!< pointer to barrel calculator + ILArCalculatorSvc* calculator_FCAL1=nullptr; + ILArCalculatorSvc* calculator_FCAL2=nullptr; + ILArCalculatorSvc* calculator_FCAL3=nullptr; + ILArCalculatorSvc* calculator_HEC=nullptr; + ILArCalculatorSvc* calculator_EMBPS=nullptr; //!< pointer to barrel presampler calculator + ILArCalculatorSvc* calculator_EMEPS=nullptr; //!< pointer to endcap presampler calculator + //ILArCalculatorSvc* calculator_HECLocal=nullptr; + }; - + FastCaloSimParamAction(const Config& config); virtual void beginOfRun(const G4Run*) override; virtual void endOfRun(const G4Run*) override; @@ -78,58 +94,40 @@ namespace G4UA{ virtual void processStep(const G4Step*) override; private: Config m_config; - + typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t; /// Pointer to StoreGate (event store by default) mutable StoreGateSvc_t m_evtStore; /// Pointer to StoreGate (detector store by default) mutable StoreGateSvc_t m_detStore; - - + + /* data members */ - - LArVCalculator* m_current_calculator; - TileGeoG4SDCalc* m_current_calculator_Tile; - - G4VSolid* m_current_solid; - G4AffineTransform* m_current_transform; - + + ILArCalculatorSvc *m_current_calculator; + TileGeoG4SDCalc *m_current_calculator_Tile; + + G4VSolid *m_current_solid; + G4AffineTransform *m_current_transform; + // calculators - LArVCalculator* m_calculator_EMECIW_pos; //!< pointer to EMEC inner wheel calculator - LArVCalculator* m_calculator_EMECIW_neg; //!< pointer to EMEC inner wheel calculator - - LArVCalculator* m_calculator_EMECOW_pos; //!< pointer to EMEC outer wheel calculator - LArVCalculator* m_calculator_EMECOW_neg; - - //LArVCalculator* m_calculator_BIB; //!< BackInnerBarrette - LArVCalculator* m_calculator_BOB; //!< BackOuterBarrette - - LArVCalculator* m_calculator_EMB; - LArVCalculator* m_calculator_FCAL1; - LArVCalculator* m_calculator_FCAL2; - LArVCalculator* m_calculator_FCAL3; - LArVCalculator* m_calculator_HEC; - LArVCalculator* m_calculator_EMBPS; //!< calculators for presampler - LArVCalculator* m_calculator_EMEPS; - - //LArVCalculator* m_calculator_HECLocal; - TileGeoG4SDCalc* m_calculator_Tile; - + TileGeoG4SDCalc *m_calculator_Tile; + // helper - LArG4SimpleSD* m_lar_helper; + LArG4SimpleSD *m_lar_helper; const LArEM_ID *m_lar_emID; - const CaloDetDescrManager* m_calo_dd_man; - - ISF_FCS_Parametrization::FCS_StepInfoCollection* m_eventSteps; //!< collection of StepInfo + const CaloDetDescrManager *m_calo_dd_man; + + ISF_FCS_Parametrization::FCS_StepInfoCollection *m_eventSteps; //!< collection of StepInfo std::map<std::string,int> m_detectormap; std::set<std::string> m_unuseddetector; int m_ndetectors; - - + + }; // class FastCaloSimParamAction - - -} // namespace G4UA + + +} // namespace G4UA diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamActionTool.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamActionTool.h index 70b39d88a89a..dde4313197ca 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamActionTool.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/ISF_Geant4UserActions/FastCaloSimParamActionTool.h @@ -2,17 +2,20 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -#ifndef ISF_GEANT4USERACTIONS_G4UA__FASTCALOSIMPARAMACTIONTOOL_H -#define ISF_GEANT4USERACTIONS_G4UA__FASTCALOSIMPARAMACTIONTOOL_H +#ifndef ISF_GEANT4USERACTIONS_G4UA__FASTCALOSIMPARAMACTIONTOOL_H +#define ISF_GEANT4USERACTIONS_G4UA__FASTCALOSIMPARAMACTIONTOOL_H #include "G4AtlasInterfaces/IBeginRunActionTool.h" #include "G4AtlasInterfaces/IEndRunActionTool.h" #include "G4AtlasInterfaces/IBeginEventActionTool.h" #include "G4AtlasInterfaces/IEndEventActionTool.h" #include "G4AtlasInterfaces/ISteppingActionTool.h" + #include "G4AtlasTools/ActionToolBase.h" + #include "ISF_Geant4UserActions/FastCaloSimParamAction.h" -namespace G4UA{ +class ILArCalculatorSvc; +namespace G4UA{ /// @class FastCaloSimParamActionTool /// @brief Tool which manages the FastCaloSimParamAction @@ -20,28 +23,30 @@ namespace G4UA{ /// @author Andrea Di Simone /// - class FastCaloSimParamActionTool: + class FastCaloSimParamActionTool: public ActionToolBase<FastCaloSimParamAction>, public IBeginRunActionTool, public IEndRunActionTool, public IBeginEventActionTool, public IEndEventActionTool, public ISteppingActionTool { - + public: /// Standard constructor FastCaloSimParamActionTool(const std::string& type, const std::string& name,const IInterface* parent); + /// Intialize Athena components + StatusCode initialize() override final; /// Retrieve the BoR action - virtual IBeginRunAction* getBeginRunAction() override final + virtual IBeginRunAction* getBeginRunAction() override final { return static_cast<IBeginRunAction*>( getAction() ); } /// Retrieve the EoR action - virtual IEndRunAction* getEndRunAction() override final + virtual IEndRunAction* getEndRunAction() override final { return static_cast<IEndRunAction*>( getAction() ); } /// Retrieve the BoE action - virtual IBeginEventAction* getBeginEventAction() override final + virtual IBeginEventAction* getBeginEventAction() override final { return static_cast<IBeginEventAction*>( getAction() ); } /// Retrieve the EoE action - virtual IEndEventAction* getEndEventAction() override final + virtual IEndEventAction* getEndEventAction() override final { return static_cast<IEndEventAction*>( getAction() ); } /// Retrieve the stepping action - virtual ISteppingAction* getSteppingAction() override final + virtual ISteppingAction* getSteppingAction() override final { return static_cast<ISteppingAction*>( getAction() ); } virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override; protected: @@ -50,8 +55,22 @@ namespace G4UA{ private: /// Configuration parameters FastCaloSimParamAction::Config m_config; + + ServiceHandle<ILArCalculatorSvc> m_emepiwcalc; //!< EMEC positive inner wheel calculator + ServiceHandle<ILArCalculatorSvc> m_emeniwcalc; //!< EMEC negative inner wheel calculator + ServiceHandle<ILArCalculatorSvc> m_emepowcalc; //!< EMEC positive outer wheel calculator + ServiceHandle<ILArCalculatorSvc> m_emenowcalc; //!< EMEC negative outer wheel calculator + ServiceHandle<ILArCalculatorSvc> m_emeobarcalc; //!< EMEC Back Outer Barrette wheel calculator + ServiceHandle<ILArCalculatorSvc> m_embcalc; //!< Barrel calculator + ServiceHandle<ILArCalculatorSvc> m_fcal1calc; //!< FCAL1 calculator + ServiceHandle<ILArCalculatorSvc> m_fcal2calc; //!< FCAL2 calculator + ServiceHandle<ILArCalculatorSvc> m_fcal3calc; //!< FCAL3 calculator + ServiceHandle<ILArCalculatorSvc> m_heccalc; //!< HEC wheel calculator + ServiceHandle<ILArCalculatorSvc> m_pscalc; //!< Barrel presampler calculator + ServiceHandle<ILArCalculatorSvc> m_emepscalc; //!< Endcap presampler calculator + }; // class FastCaloSimParamActionTool - - -} // namespace G4UA + + +} // namespace G4UA #endif diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/cmt/requirements b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/cmt/requirements index ba24b39a3923..07a7cd43c8a2 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/cmt/requirements +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/cmt/requirements @@ -14,11 +14,7 @@ use CaloIdentifier CaloIdentifier-* Calorimeter use Geant4 Geant4-* External use GeneratorObjects GeneratorObjects-* Generators use ISF_FastCaloSimEvent ISF_FastCaloSimEvent-* Simulation/ISF/ISF_FastCaloSim -use LArG4Barrel LArG4Barrel-* LArCalorimeter/LArG4 use LArG4Code LArG4Code-* LArCalorimeter/LArG4 -use LArG4EC LArG4EC-* LArCalorimeter/LArG4 -use LArG4FCAL LArG4FCAL-* LArCalorimeter/LArG4 -use LArG4HEC LArG4HEC-* LArCalorimeter/LArG4 use TileGeoG4SD TileGeoG4SD-* TileCalorimeter/TileG4 use CxxUtils CxxUtils-* Control use AthenaBaseComps AthenaBaseComps-* Control diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamAction.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamAction.cxx index 3af08c7b44c8..c3bada4392c5 100755 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamAction.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamAction.cxx @@ -16,18 +16,8 @@ #include "G4EventManager.hh" #include "G4ThreeVector.hh" -// all the LAr calculators -#include "LArG4Code/LArVCalculator.h" -#include "LArG4Barrel/LArBarrelCalculator.h" -#include "LArG4EC/EnergyCalculator.h" -#include "LArG4FCAL/LArFCAL1Calculator.h" -#include "LArG4FCAL/LArFCAL2Calculator.h" -#include "LArG4FCAL/LArFCAL3Calculator.h" -//#include "LArG4HEC/LArHECCalculator.h" -#include "LArG4HEC/LArHECWheelCalculator.h" -//#include "LArG4HEC/LArHECLocalCalculator.h" -#include "LArG4EC/LArEndcapPresamplerCalculator.h" -#include "LArG4Barrel/LArBarrelPresamplerCalculator.h" +// LAr calculator interface +#include "LArG4Code/ILArCalculatorSvc.h" // For the identifiers #include "LArG4Code/LArG4SimpleSD.h" @@ -48,7 +38,7 @@ // For MC Truth information: #include "GeneratorObjects/McEventCollection.h" -#include "ISF_Geant4UserActions/FastCaloSimParamAction.h" + namespace G4UA{ @@ -56,281 +46,146 @@ namespace G4UA{ m_config(config), m_evtStore("StoreGateSvc/StoreGateSvc","FastCaloSimParamAction"), m_detStore("StoreGateSvc/DetectorStore","FastCaloSimParamAction"), - m_current_calculator(0), - m_current_calculator_Tile(0), - m_current_solid(0), - m_current_transform(0), - m_calculator_EMECIW_pos(0), - m_calculator_EMECIW_neg(0), - m_calculator_EMECOW_pos(0), - m_calculator_EMECOW_neg(0), - //m_calculator_BIB(0), - m_calculator_BOB(0), - m_calculator_EMB(0), - m_calculator_FCAL1(0), - m_calculator_FCAL2(0), - m_calculator_FCAL3(0), - m_calculator_HEC(0), - //m_calculator_HECLocal(0), - m_calculator_EMBPS(0), - m_calculator_EMEPS(0), - m_calculator_Tile(0), - m_lar_helper(0), - m_lar_emID(0), - m_calo_dd_man(0), - m_eventSteps(0), + m_current_calculator(nullptr), + m_current_calculator_Tile(nullptr), + m_current_solid(nullptr), + m_current_transform(nullptr), + m_calculator_Tile(nullptr), + m_lar_helper(nullptr), + m_lar_emID(nullptr), + m_calo_dd_man(nullptr), + m_eventSteps(nullptr), m_ndetectors(0){ #ifdef _myDEBUG_ G4cout << "############################################" << G4endl - << "## FastCaloSimParamAction - Constructor ##" << G4endl - << "############################################" << G4endl; + << "## FastCaloSimParamAction - Constructor ##" << G4endl + << "############################################" << G4endl; #endif - + } void FastCaloSimParamAction::beginOfRun(const G4Run*){ - + //G4cout << "############################################" << G4endl // << "## FastCaloSimParamAction - BeginOfRun ##" << G4endl // << "############################################" << G4endl; // ?? Ok, where do I need this?? - // init calculator - if (m_calculator_EMECIW_pos == 0) - m_calculator_EMECIW_pos = new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, 1); - if (m_calculator_EMECOW_pos == 0) - m_calculator_EMECOW_pos = new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, 1); - if (m_calculator_EMECIW_neg == 0) - m_calculator_EMECIW_neg = new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, -1); - if (m_calculator_EMECOW_neg == 0) - m_calculator_EMECOW_neg = new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, -1); - //if (m_calculator_BIB == 0) - // m_calculator_BIB = new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackInnerBarretteWheel); - if (m_calculator_BOB == 0) - m_calculator_BOB = new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteWheel); - if (m_calculator_FCAL1 == 0) - m_calculator_FCAL1 = LArFCAL1Calculator::GetInstance(); - if (m_calculator_FCAL2 == 0) - m_calculator_FCAL2 = LArFCAL2Calculator::GetInstance(); - if (m_calculator_FCAL3 == 0) - m_calculator_FCAL3 = LArFCAL3Calculator::GetInstance(); - if (m_calculator_HEC == 0) - m_calculator_HEC = LArHECWheelCalculator::GetCalculator(); - //if (m_calculator_HECLocal == 0) - // m_calculator_HECLocal = LArHECLocalCalculator::GetCalculator(); - if (m_calculator_EMB ==0) - m_calculator_EMB = LArBarrelCalculator::GetCalculator(); - if (m_calculator_EMBPS == 0) - m_calculator_EMBPS = LArBarrelPresamplerCalculator::GetCalculator(); - if (m_calculator_EMEPS == 0) - m_calculator_EMEPS = LArEndcapPresamplerCalculator::GetCalculator(); - if (m_calculator_Tile ==0) + // init tile calculator + if (m_calculator_Tile == nullptr) + { + // Get the tile calculator from the SD + G4SDManager *sdManager = G4SDManager::GetSDMpointer(); + TileGeoG4SD * tileSD = dynamic_cast<TileGeoG4SD*>( sdManager->FindSensitiveDetector("TileGeoG4SD") ); + if (tileSD){ + m_calculator_Tile = tileSD->GetCalculator(); + } else { + G4ExceptionDescription description; + description << "FastCaloSimParamAction::BeginOfRunAction - can't find TileGeoG4SDCalc"; + G4Exception("FastCaloSimParamAction", "NoTileGeoG4SDCalc", FatalException, description); + abort(); + } + } + + if (m_current_transform == nullptr) { - // Get the tile calculator from the SD - G4SDManager *sdManager = G4SDManager::GetSDMpointer(); - TileGeoG4SD * tileSD = dynamic_cast<TileGeoG4SD*>( sdManager->FindSensitiveDetector("TileGeoG4SD") ); - if (tileSD){ - m_calculator_Tile = tileSD->GetCalculator(); - } else { - G4ExceptionDescription description; - description << "FastCaloSimParamAction::BeginOfRunAction - can't find TileGeoG4SDCalc"; - G4Exception("FastCaloSimParamAction", "NoTileGeoG4SDCalc", FatalException, description); - abort(); - } + m_current_transform = new G4AffineTransform (); } - - if (m_current_transform == 0) - m_current_transform = new G4AffineTransform (); - m_lar_helper = new LArG4SimpleSD( "IDHelper" , &(*m_detStore) ); - + //get also lar em helper m_calo_dd_man = CaloDetDescrManager::instance(); - + const DataHandle<CaloIdManager> caloIdManager; - StatusCode sc=m_detStore->retrieve(caloIdManager); - if(sc.isSuccess()) + if(m_detStore->retrieve(caloIdManager).isSuccess()) std::cout<<"CaloIDManager retrieved."<<std::endl; else throw std::runtime_error("ISF_HitAnalysis: Unable to retrieve CaloIDManeger"); - + m_lar_emID=caloIdManager->getEM_ID(); - return; + return; } - + void FastCaloSimParamAction::endOfRun(const G4Run*){ - + G4cout << "############################################" << G4endl - << "## FastCaloSimParamAction - EndOfRun ##" << G4endl - << "## deleting calculators ##" << G4endl - << "############################################" << G4endl; - - if (m_calculator_EMECIW_pos != 0) { - delete m_calculator_EMECIW_pos; - m_calculator_EMECIW_pos = 0; - } - if (m_calculator_EMECIW_neg != 0) { - delete m_calculator_EMECIW_neg; - m_calculator_EMECIW_neg = 0; - } - if (m_calculator_EMECOW_pos != 0) { - delete m_calculator_EMECOW_pos; - m_calculator_EMECOW_pos = 0; - } - if (m_calculator_EMECOW_neg != 0) { - delete m_calculator_EMECOW_neg; - m_calculator_EMECOW_neg = 0; - } - //if (m_calculator_BIB != 0) { - // delete m_calculator_BIB; - // m_calculator_BIB=0; - //} - if (m_calculator_BOB != 0) { - delete m_calculator_BOB; - m_calculator_BOB=0; - } - if (m_calculator_EMB !=0) { - delete m_calculator_EMB; - m_calculator_EMB = 0; - } - - if (m_calculator_FCAL1 !=0) { - delete m_calculator_FCAL1; - m_calculator_FCAL1 = 0; - } - - if (m_calculator_FCAL2 !=0) { - delete m_calculator_FCAL2; - m_calculator_FCAL2 = 0; - } - - if (m_calculator_FCAL3 !=0) { - delete m_calculator_FCAL3; - m_calculator_FCAL3 = 0; - } - - if (m_calculator_HEC !=0) { - delete m_calculator_HEC; - m_calculator_HEC = 0; - } - std::cout <<"ZH EM PS calculators: "<<std::endl; - - if (m_calculator_EMBPS !=0) { - delete m_calculator_EMBPS; - m_calculator_EMBPS = 0; - } - /* - if (m_calculator_EMEPS !=0) { - delete m_calculator_EMEPS; - m_calculator_EMEPS = 0; - } - */ - //if (m_calculator_HECLocal !=0) { - // delete m_calculator_HECLocal; - // m_calculator_HECLocal = 0; - //} - + << "## FastCaloSimParamAction - EndOfRun ##" << G4endl + << "## deleting calculators ##" << G4endl + << "############################################" << G4endl; + if (m_calculator_Tile !=0) { delete m_calculator_Tile; m_calculator_Tile = 0; - + } - - std::cout <<"ZH good detector map: "<<std::endl; + + G4cout << "ZH good detector map: " << G4endl; for (std::map<std::string, int>::iterator it = m_detectormap.begin(); it!= m_detectormap.end(); ++it) { - std::cout <<it->second<<" "<<it->first<<std::endl; + std::cout <<it->second<<" "<<it->first<<std::endl; } std::cout <<"-----------------------------------------------"<<std::endl; std::cout <<"List of unused parts :"<<std::endl; for (std::set<std::string>::iterator it = m_unuseddetector.begin(); it!=m_unuseddetector.end(); it++) { - std::cout <<(*it)<<" "; + std::cout <<(*it)<<" "; } std::cout <<std::endl; - - + + G4cout << "############################################" << G4endl - << "## FastCaloSimParamAction - EndOfRun ##" << G4endl - << "############################################" << G4endl; - + << "## FastCaloSimParamAction - EndOfRun ##" << G4endl + << "############################################" << G4endl; + return; - - + + } - + void FastCaloSimParamAction::beginOfEvent(const G4Event*){ //G4cout << "############################################" << G4endl // << "## FastCaloSimParamAction - BeginOfEvent ##" << G4endl // << "############################################" << G4endl; - - // init calculator - if (m_calculator_EMECIW_pos == 0) - m_calculator_EMECIW_pos = new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, 1); - if (m_calculator_EMECOW_pos == 0) - m_calculator_EMECOW_pos = new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, 1); - - if (m_calculator_EMECIW_neg == 0) - m_calculator_EMECIW_neg = new LArG4::EC::EnergyCalculator(LArWheelCalculator::InnerAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, -1); - if (m_calculator_EMECOW_neg == 0) - m_calculator_EMECOW_neg = new LArG4::EC::EnergyCalculator(LArWheelCalculator::OuterAbsorberWheel,LArG4::EC::EnergyCalculator::EMEC_ECOR_ROPT, -1); - //if (m_calculator_BIB == 0) - // m_calculator_BIB = new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackInnerBarretteWheel); - if (m_calculator_BOB == 0) - m_calculator_BOB = new LArG4::EC::EnergyCalculator(LArWheelCalculator::BackOuterBarretteWheel); - if (m_calculator_FCAL1 == 0) - m_calculator_FCAL1 = LArFCAL1Calculator::GetInstance(); - if (m_calculator_FCAL2 == 0) - m_calculator_FCAL2 = LArFCAL2Calculator::GetInstance(); - if (m_calculator_FCAL3 == 0) - m_calculator_FCAL3 = LArFCAL3Calculator::GetInstance(); - if (m_calculator_HEC == 0) - m_calculator_HEC = LArHECWheelCalculator::GetCalculator(); - //if (m_calculator_HECLocal == 0) - // m_calculator_HECLocal = LArHECLocalCalculator::GetCalculator(); - if (m_calculator_EMB == 0) - m_calculator_EMB = LArBarrelCalculator::GetCalculator(); - if (m_calculator_EMBPS == 0) - m_calculator_EMBPS = LArBarrelPresamplerCalculator::GetCalculator(); - if (m_calculator_EMEPS == 0) - m_calculator_EMEPS = LArEndcapPresamplerCalculator::GetCalculator(); - if (m_calculator_Tile == 0) + + // init tile calculator + if (m_calculator_Tile == nullptr) { - // Get the tile calculator from the SD - G4SDManager *sdManager = G4SDManager::GetSDMpointer(); - TileGeoG4SD * tileSD = dynamic_cast<TileGeoG4SD*>( sdManager->FindSensitiveDetector("TileGeoG4SD") ); - if (tileSD){ - m_calculator_Tile = tileSD->GetCalculator(); - } else { - G4ExceptionDescription description; - description << "FastCaloSimParamAction::BeginOfEventAction - can't find TileGeoG4SDCalc"; - G4Exception("FastCaloSimParamAction", "NoTileGeoG4SDCalc", FatalException, description); - abort(); - } + // Get the tile calculator from the SD + G4SDManager *sdManager = G4SDManager::GetSDMpointer(); + TileGeoG4SD * tileSD = dynamic_cast<TileGeoG4SD*>( sdManager->FindSensitiveDetector("TileGeoG4SD") ); + if (tileSD){ + m_calculator_Tile = tileSD->GetCalculator(); + } else { + G4ExceptionDescription description; + description << "FastCaloSimParamAction::BeginOfEventAction - can't find TileGeoG4SDCalc"; + G4Exception("FastCaloSimParamAction", "NoTileGeoG4SDCalc", FatalException, description); + abort(); + } } - - if (m_current_transform == 0) - m_current_transform = new G4AffineTransform (); - - + + if (m_current_transform == nullptr) + { + m_current_transform = new G4AffineTransform (); + } + m_eventSteps = new ISF_FCS_Parametrization::FCS_StepInfoCollection(); //G4cout << "############################################" << G4endl // << "## FastCaloSimParamAction - BeginOfEvent2 ##" << G4endl // << "############################################" << G4endl; - - - return; + + + return; } - + void FastCaloSimParamAction::endOfEvent(const G4Event*){ - + //G4cout << "############################################" << G4endl // << "## FastCaloSimParamAction - EndOfEvent ##" << G4endl // << "## ##" << G4endl // << "############################################" << G4endl; - + // // Zero order cleanup // combine hits from the same spot (distance < 1 mm^2) @@ -341,11 +196,11 @@ namespace G4UA{ #ifdef _myDEBUG_ G4cout << "FastCaloSimParamAction::EndOfEventAction: Before initial cleanup, N=" << m_eventSteps->size() << G4endl; #endif - + // G4cout << "FastCaloSimParamAction::EndOfEventAction: After initial cleanup, N=" << m_eventSteps->size() << G4endl; if (m_eventSteps->size()==0) return; //don't need to play with it G4cout << "FastCaloSimParamAction::EndOfEventAction: After initial cleanup, N=" << m_eventSteps->size() << G4endl; - + // // Put eventSteps into event store // @@ -354,90 +209,91 @@ namespace G4UA{ // std::cout <<"Check if already in StoreGate:"<<std::endl; if (m_evtStore->contains<ISF_FCS_Parametrization::FCS_StepInfoCollection>(location)) { - StatusCode check = m_evtStore->retrieve(test,location); - if (check.isSuccess()) - { - //std::cout <<"ZH, Already have in StoreGate : "<<test->size()<<std::endl; - //want to merge and overwrite! - for (ISF_FCS_Parametrization::FCS_StepInfoCollection::iterator iter = m_eventSteps->begin();iter != m_eventSteps->end();iter++) - { - test->push_back((*iter)); - } - //std::cout <<"Now have: "<<test->size()<<std::endl; - // StatusCode sc = evtStore()->remove( - //check - check = m_evtStore->retrieve(test,location); - if (check.isSuccess()) - { - std::cout <<"ZH, check in StoreGate : "<<test->size()<<std::endl; - } - /* - StatusCode sc = evtStore()->record( test, location); //want to overwrite? but current release doesn't have this method??? - if( sc.isFailure() ) { - G4cout << "Error: Couldn't store EventSteps object in event store at location: " << location << G4endl;// - } else { - - G4cout << "Info: Stored EventSteps object (size: " << test->size() << ")" - << " in event store at location: " << location << G4endl; - } - */ - } - else - { - std::cout <<"ZH WTF ??"<<std::endl; - } + StatusCode check = m_evtStore->retrieve(test,location); + if (check.isSuccess()) + { + //std::cout <<"ZH, Already have in StoreGate : "<<test->size()<<std::endl; + //want to merge and overwrite! + for (ISF_FCS_Parametrization::FCS_StepInfoCollection::iterator iter = m_eventSteps->begin();iter != m_eventSteps->end();iter++) + { + test->push_back((*iter)); + } + //std::cout <<"Now have: "<<test->size()<<std::endl; + // StatusCode sc = evtStore()->remove( + //check + check = m_evtStore->retrieve(test,location); + if (check.isSuccess()) + { + std::cout <<"ZH, check in StoreGate : "<<test->size()<<std::endl; + } + /* + StatusCode sc = evtStore()->record( test, location); //want to overwrite? but current release doesn't have this method??? + if( sc.isFailure() ) { + G4cout << "Error: Couldn't store EventSteps object in event store at location: " << location << G4endl;// + } else { + + G4cout << "Info: Stored EventSteps object (size: " << test->size() << ")" + << " in event store at location: " << location << G4endl; + } + */ + } + else + { + std::cout <<"ZH WTF ??"<<std::endl; + } } else { - StatusCode sc = m_evtStore->record( m_eventSteps, location, true ); - if( sc.isFailure() ) { - G4cout << "Error: Couldn't store EventSteps object in event store at location: " << location << G4endl; - } else { - G4cout << "Info: Stored EventSteps object (size: " << m_eventSteps->size() << ")" - << " in event store at location: " << location << G4endl; - } + StatusCode sc = m_evtStore->record( m_eventSteps, location, true ); + if( sc.isFailure() ) { + G4cout << "Error: Couldn't store EventSteps object in event store at location: " << location << G4endl; + } else { + G4cout << "Info: Stored EventSteps object (size: " << m_eventSteps->size() << ")" + << " in event store at location: " << location << G4endl; + } } return; } - - void FastCaloSimParamAction::processStep(const G4Step* aStep){ + + void FastCaloSimParamAction::processStep(const G4Step* aStep) +{ //G4cout <<"FastCaloSimParamAction - SteppingAction"<<G4endl; - m_current_calculator = NULL; - m_current_calculator_Tile = NULL; - + m_current_calculator = nullptr; + m_current_calculator_Tile = nullptr; + G4ThreeVector position1 = aStep->GetPreStepPoint()->GetPosition(); //pre step is the position i'm interested in G4ThreeVector position2 = aStep->GetPostStepPoint()->GetPosition(); G4ThreeVector pos = 0.5*(position1+position2); // std::cout <<" === NEW STEP ==="<<std::endl; - + G4TouchableHistory* theTouchable = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); //this has all the history depth if (!theTouchable) { - //This shouldn't happen anyway - //std::cout <<"ZH Missing touchable??"<<std::endl; - return; + //This shouldn't happen anyway + //std::cout <<"ZH Missing touchable??"<<std::endl; + return; } int depth = theTouchable->GetHistoryDepth(); G4VPhysicalVolume *pCurrentVolume = aStep->GetPreStepPoint()->GetPhysicalVolume(); if (!pCurrentVolume) { - //std::cout <<"ZH Missing current volume??"<<std::endl; - return; + //std::cout <<"ZH Missing current volume??"<<std::endl; + return; } - + G4LogicalVolume* pCurrentLogicalVolume = pCurrentVolume->GetLogicalVolume(); if (!pCurrentLogicalVolume) { - //std::cout <<"ZH Missing current logical volume"<<std::endl; - return; + //std::cout <<"ZH Missing current logical volume"<<std::endl; + return; } - + if (!pCurrentLogicalVolume->GetSensitiveDetector()) { - //std::cout <<"No SD"<<std::endl; - //this volume doesn't have a sensitive detector -> not interested - return; + //std::cout <<"No SD"<<std::endl; + //this volume doesn't have a sensitive detector -> not interested + return; } std::string CurrentLogicalVolumeName = pCurrentLogicalVolume->GetName(); std::string OrigLogicalVolumeName = CurrentLogicalVolumeName; @@ -445,454 +301,455 @@ namespace G4UA{ double StepLength = aStep->GetStepLength()/ CLHEP::mm;; //std::cout <<"ZH Step: "<<StepLength<<std::endl; //std::cout <<"Current : "<<CurrentLogicalVolumeName<<std::endl; - + std::string tilestring("Tile"); - + for (int idepth = 0; idepth<depth; idepth++) { - pCurrentVolume = theTouchable->GetVolume(idepth); - pCurrentLogicalVolume = pCurrentVolume->GetLogicalVolume(); - CurrentLogicalVolumeName = pCurrentLogicalVolume->GetName(); - //std::cout <<CurrentLogicalVolumeName<<" depth: "<<idepth<<std::endl; - if(CurrentLogicalVolumeName == "LArMgr::LAr::FCAL::Module1::Absorber") - { - // shower is inside FCAL1 - m_current_calculator = m_calculator_FCAL1; - //m_current_calculator = NULL; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::FCAL::Module2::Absorber") - { - // shower is inside FCAL2 - m_current_calculator = m_calculator_FCAL2; - //m_current_calculator = NULL; //try disable.. - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::FCAL::Module3::Absorber") - { - // shower is inside FCAL3 - m_current_calculator = m_calculator_FCAL3; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Pos::InnerWheel") - { - m_current_calculator = m_calculator_EMECIW_pos; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Neg::InnerWheel") - { - // shower is inside inner EMEC - m_current_calculator = m_calculator_EMECIW_neg; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Pos::OuterWheel") - { - m_current_calculator = m_calculator_EMECOW_pos; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Neg::OuterWheel") - { - // shower is inside outer EMEC positive - m_current_calculator = m_calculator_EMECOW_neg; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMB::STAC") - { - // shower is inside EMB positive - m_current_calculator = m_calculator_EMB; - break; - } - //else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::FrontInnerBarrette::Module::Phidiv") - // { - // m_current_calculator = m_calculator_BIB; - // break; - // } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::BackOuterBarrette::Module::Phidiv") - { - m_current_calculator = m_calculator_BOB; - break; - } - //else if (CurrentLogicalVolumeName == "LArMgr::LAr::HEC::Module::Depth::Slice::Local") - //{ - // m_current_calculator = m_calculator_HECLocal; - // break; - //} //doesn't exist anymore - else if (CurrentLogicalVolumeName == "LArMgr::LAr::HEC::Module::Depth::Slice") - { - m_current_calculator = m_calculator_HEC; - break; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::Barrel::Presampler::Module") - { - m_current_calculator = m_calculator_EMBPS; - } - else if (CurrentLogicalVolumeName == "LArMgr::LAr::Endcap::Presampler::LiquidArgon") - { - m_current_calculator = m_calculator_EMEPS; - } - else if (CurrentLogicalVolumeName.find(tilestring)!= std::string::npos) - { - m_current_calculator_Tile = m_calculator_Tile; - break; - } - + pCurrentVolume = theTouchable->GetVolume(idepth); + pCurrentLogicalVolume = pCurrentVolume->GetLogicalVolume(); + CurrentLogicalVolumeName = pCurrentLogicalVolume->GetName(); + //std::cout <<CurrentLogicalVolumeName<<" depth: "<<idepth<<std::endl; + if(CurrentLogicalVolumeName == "LArMgr::LAr::FCAL::Module1::Absorber") + { + // shower is inside FCAL1 + m_current_calculator = m_config.calculator_FCAL1; + //m_current_calculator = nullptr; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::FCAL::Module2::Absorber") + { + // shower is inside FCAL2 + m_current_calculator = m_config.calculator_FCAL2; + //m_current_calculator = nullptr; //try disable.. + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::FCAL::Module3::Absorber") + { + // shower is inside FCAL3 + m_current_calculator = m_config.calculator_FCAL3; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Pos::InnerWheel") + { + m_current_calculator = m_config.calculator_EMECIW_pos; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Neg::InnerWheel") + { + // shower is inside inner EMEC + m_current_calculator = m_config.calculator_EMECIW_neg; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Pos::OuterWheel") + { + m_current_calculator = m_config.calculator_EMECOW_pos; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::Neg::OuterWheel") + { + // shower is inside outer EMEC positive + m_current_calculator = m_config.calculator_EMECOW_neg; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMB::STAC") + { + // shower is inside EMB positive + m_current_calculator = m_config.calculator_EMB; + break; + } + //else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::FrontInnerBarrette::Module::Phidiv") + // { + // m_current_calculator = m_config.calculator_BIB; + // break; + // } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::EMEC::BackOuterBarrette::Module::Phidiv") + { + m_current_calculator = m_config.calculator_BOB; + break; + } + //else if (CurrentLogicalVolumeName == "LArMgr::LAr::HEC::Module::Depth::Slice::Local") + //{ + // m_current_calculator = m_config.calculator_HECLocal; + // break; + //} //doesn't exist anymore + else if (CurrentLogicalVolumeName == "LArMgr::LAr::HEC::Module::Depth::Slice") + { + m_current_calculator = m_config.calculator_HEC; + break; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::Barrel::Presampler::Module") + { + m_current_calculator = m_config.calculator_EMBPS; + } + else if (CurrentLogicalVolumeName == "LArMgr::LAr::Endcap::Presampler::LiquidArgon") + { + m_current_calculator = m_config.calculator_EMEPS; + } + else if (CurrentLogicalVolumeName.find(tilestring)!= std::string::npos) + { + m_current_calculator_Tile = m_calculator_Tile; + break; + } + } //std::cout <<"--- END SEARCHING ---"<<std::endl; - + if (m_current_calculator || m_current_calculator_Tile) { - //Good detector - if (m_detectormap.find(OrigLogicalVolumeName) == m_detectormap.end()) - { - m_detectormap.insert(std::pair<std::string,int>(OrigLogicalVolumeName,m_ndetectors)); - m_ndetectors++; - std::cout <<"ZH I have added new detector: "<<OrigLogicalVolumeName<<" because I know a calculator for: "<<CurrentLogicalVolumeName<<std::endl; - } + //Good detector + if (m_detectormap.find(OrigLogicalVolumeName) == m_detectormap.end()) + { + m_detectormap.insert(std::pair<std::string,int>(OrigLogicalVolumeName,m_ndetectors)); + m_ndetectors++; + std::cout <<"ZH I have added new detector: "<<OrigLogicalVolumeName<<" because I know a calculator for: "<<CurrentLogicalVolumeName<<std::endl; + } } else { - //Unused - if ( m_unuseddetector.insert(OrigLogicalVolumeName).second) - { - std::cout <<"ZH I don't have a calculator for: "<<OrigLogicalVolumeName<<" and I'm here for the first time"<<std::endl; - } - //std::cout <<"End here"<<std::endl; - return; + //Unused + if ( m_unuseddetector.insert(OrigLogicalVolumeName).second) + { + std::cout <<"ZH I don't have a calculator for: "<<OrigLogicalVolumeName<<" and I'm here for the first time"<<std::endl; + } + //std::cout <<"End here"<<std::endl; + return; } //std::cout <<"Continue"<<std::endl; - + //////////////////////////////////////////////////////////// // Calculation and storage of LAr/Tile Hit information //////////////////////////////////////////////////////////// - + if (aStep->GetTotalEnergyDeposit()>0) { /* - std::cout <<" === NEW STEP ==="<<std::endl; - std::cout <<"Prestep pos: "<<position1.x()<<" "<<position1.y()<<" "<<position1.z()<<std::endl; - std::cout <<"Poststep pos: "<<position2.x()<<" "<<position2.y()<<" "<<position2.z()<<std::endl; - std::cout <<"Step pos: "<<pos.x()<<" "<<pos.y()<<" "<<pos.z()<<std::endl; - - std::cout <<"ZH Step length: "<<aStep->GetStepLength() /CLHEP::mm <<" in "<<OrigLogicalVolumeName<<std::endl; + std::cout <<" === NEW STEP ==="<<std::endl; + std::cout <<"Prestep pos: "<<position1.x()<<" "<<position1.y()<<" "<<position1.z()<<std::endl; + std::cout <<"Poststep pos: "<<position2.x()<<" "<<position2.y()<<" "<<position2.z()<<std::endl; + std::cout <<"Step pos: "<<pos.x()<<" "<<pos.y()<<" "<<pos.z()<<std::endl; + + std::cout <<"ZH Step length: "<<aStep->GetStepLength() /CLHEP::mm <<" in "<<OrigLogicalVolumeName<<std::endl; */ /* - G4VPhysicalVolume *pNextVolume = aStep->GetPostStepPoint()->GetPhysicalVolume(); - if (!pNextVolume) - { - //std::cout <<"ZH Missing next volume??"<<std::endl; - //return; - } - - G4LogicalVolume* pNextLogicalVolume = pNextVolume->GetLogicalVolume(); - if (!pNextLogicalVolume) - { - //std::cout <<"ZH Missing next logical volume"<<std::endl; - //return; - } - - if (!pNextLogicalVolume->GetSensitiveDetector()) - { - //std::cout <<"ZH Missing next SD"<<std::endl; - //return; - } - if (pNextLogicalVolume) - { - //std::cout <<"ZH Missing volume: "<<pNextLogicalVolume->GetName()<<std::endl; - } + G4VPhysicalVolume *pNextVolume = aStep->GetPostStepPoint()->GetPhysicalVolume(); + if (!pNextVolume) + { + //std::cout <<"ZH Missing next volume??"<<std::endl; + //return; + } + + G4LogicalVolume* pNextLogicalVolume = pNextVolume->GetLogicalVolume(); + if (!pNextLogicalVolume) + { + //std::cout <<"ZH Missing next logical volume"<<std::endl; + //return; + } + + if (!pNextLogicalVolume->GetSensitiveDetector()) + { + //std::cout <<"ZH Missing next SD"<<std::endl; + //return; + } + if (pNextLogicalVolume) + { + //std::cout <<"ZH Missing volume: "<<pNextLogicalVolume->GetName()<<std::endl; + } */ //std::cout <<"ZH calculator should do something"<<OrigLogicalVolumeName<<" "<<m_current_calculator<<std::endl; - + ///////////////////// //Do LAr Stuff ///////////////////// if (m_current_calculator) { - - double et = 0; // Total collected charge - //G4cout << m_current_calculator << " " << position << G4endl; - - std::vector<const G4Step*> steps; - //bool shortstep = false; - if (m_config.shorten_lar_step && StepLength>0.2) - { - //create smaller substeps instead - G4int nsub_step=(int) (StepLength/0.2) + 1; - G4double delta=1./((double) nsub_step); - //std::cout <<"Orig prestep: "<<aStep->GetPreStepPoint()->GetPosition()<<std::endl; - for (G4int i=0;i<nsub_step;i++) { - // G4double fraction=(((G4double) i)+0.5)*delta; - G4double fraction1 = ((G4double) i)*delta; - G4double fraction2 = (((G4double) i) + 1.)*delta; - G4ThreeVector subpoint1=position1*(1-fraction1) + position2*fraction1; - G4ThreeVector subpoint2=position1*(1-fraction2) + position2*fraction2; - - //G4StepPoint *startpoint = 0; - //startpoint = const_cast<G4StepPoint*>(aStep->GetPreStepPoint()); - //startpoint->SetPosition(subpoint1); - //G4StepPoint *endpoint = 0; - //endpoint = const_cast<G4StepPoint*>(aStep->GetPostStepPoint()); - //endpoint->SetPosition(subpoint2); - - G4StepPoint *startpoint = new G4StepPoint(*(aStep->GetPreStepPoint())); - G4StepPoint *endpoint = new G4StepPoint(*(aStep->GetPostStepPoint())); - startpoint->SetPosition(subpoint1); - endpoint->SetPosition(subpoint2); - - //std::cout <<"ZH substep: "<<i<<" Pos: "<<subpoint1<<" "<<subpoint2<<std::endl; - G4Step* newstep = new G4Step(*aStep); - //newstep = const_cast<G4Step*>(aStep); - if(newstep->GetPreStepPoint()) delete newstep->GetPreStepPoint(); - if(newstep->GetPostStepPoint()) delete newstep->GetPostStepPoint(); - newstep->SetPreStepPoint(startpoint); - newstep->SetPostStepPoint(endpoint); - newstep->SetStepLength( (subpoint1-subpoint2).mag()); - newstep->SetTotalEnergyDeposit(aStep->GetTotalEnergyDeposit()/nsub_step); - //std::cout <<"ZH substep: "<<newstep->GetPreStepPoint()->GetPosition()<<" "<<newstep->GetPostStepPoint()->GetPosition()<<" / "<<0.5*(newstep->GetPreStepPoint()->GetPosition()+newstep->GetPostStepPoint()->GetPosition())<<std::endl; - steps.push_back(newstep); - } - //std::cout <<"Orig poststep"<<aStep->GetPostStepPoint()->GetPosition()<<std::endl; - //shortstep = true; - } - else - { - steps.push_back(aStep); - } - - //std::cout <<"ZH Step size: "<<steps.size()<<" full step length "<<StepLength<<std::endl; - for (unsigned int istep = 0; istep <steps.size(); istep++) - { - //need to update the position! - pos = 0.5*(steps[istep]->GetPreStepPoint()->GetPosition()+steps[istep]->GetPostStepPoint()->GetPosition()); - //std::cout <<"ZH Processing step: "<<istep<<" at position "<<pos<<std::endl; - - if (m_current_calculator->Process(steps[istep])) - { - //if (!shortstep) G4cout <<"ZH process step ok: "<<m_current_calculator->getNumHits()<<G4endl; - int nlarh = m_current_calculator->getNumHits(); - for (int i=0; i<nlarh; ++i) - { - et += (m_current_calculator->energy(i)); - //std::cout <<"ZH Hit: "<<i<<" E: "<<m_current_calculator->energy(i)<<" in: "<<(std::string) m_current_calculator->identifier(i)<<std::endl; - } - } - else - { - //Maybe 0 hits or something like that... - //G4cout << "ZH: Error: Hit not processed by calculator! " << istep<<" / "<<steps.size()<<" shortstep: "<<shortstep<<G4endl; - //G4cout << "ZH: calculator not processed: Volume: "<< pCurrentVolume->GetName()<<" "<<m_current_calculator<< " position: "<<pos<<" SL: "<<StepLength<<G4endl; - //G4cout <<"ZH: Orig position: "<<steps[istep]->GetPreStepPoint()->GetPosition()<<" / "<<steps[istep]->GetPostStepPoint()->GetPosition()<<"and SL: "<<StepLength<<" step: "<<aStep->GetPreStepPoint()->GetPosition()<<" / "<<aStep->GetPostStepPoint()->GetPosition()<<G4endl; - return; - } - - // drop hits with zero deposited energy (could still happen with negative corrections from calculator) - //Or if total energy is <0 - if (et <= 0.) - { - std::cout <<"ZH: Total negative energy: "<<et<<" not processing..."<<std::endl; - return; - } - - int nlarh = m_current_calculator->getNumHits(); - std::vector<G4ThreeVector> subhitcells; - subhitcells.resize(nlarh); - G4ThreeVector origpos = pos; - double e_subhitmax = -999.; - int e_subhitmaxindex =-1; - if (nlarh>0) - { - e_subhitmax = m_current_calculator->energy(0); - e_subhitmaxindex = 0; - } - //Figure out the subhit with most energy - for (int i=1; i<nlarh; ++i) - { - if (e_subhitmax< m_current_calculator->energy(i)) - { - e_subhitmax = m_current_calculator->energy(i); - e_subhitmaxindex = i; - } - } - //Identifier for the subhit with max energy - LArG4Identifier e_subhitmax_ident = m_current_calculator->identifier(e_subhitmaxindex); - Identifier e_subhitmax_id = m_lar_helper->ConvertID(e_subhitmax_ident); - - for (int i=0; i<nlarh; ++i) - { - LArG4Identifier ident = m_current_calculator->identifier(i); - Identifier id = m_lar_helper->ConvertID(ident); - - Identifier inv_id; - if (id == inv_id) - { - std::cout <<"Something wrong with identifier (LAr): "<<(std::string) ident; - std::cout <<" "<<id<<" "<<id.getString()<<" "<<CurrentLogicalVolumeName <<" nhit: "<<nlarh<<std::endl; - std::cout <<inv_id<<std::endl; - } - - //std::cout <<"Subhit: "<<i<<std::endl; - //std::cout <<"LArIdent "<<(std::string) ident<<std::endl; - //std::cout <<"Ident "<<id.getString()<<std::endl; - //std::cout <<"ZH Step: LAr: "<<StepLength<<std::endl; - //need to get the cell information - - if (nlarh>1) - { - //it didn't seem to happen outside em_barrel - if (m_lar_emID->is_em_barrel(id)) - { - if (m_config.shift_lar_subhit) - { - //find subhit with largest energy - - if (e_subhitmaxindex == -1) - { - std::cout <<"ZH no subhit index with e>-999??? "<<std::endl; - return; - } - else - { - //std::cout <<"ZH shifting subhits: largest energy subhit index is "<<e_subhitmaxindex<<" E: "<<e_subhitmax<<" identifier: "<<e_subhitmax_id.getString()<<std::endl; - } - //from sampling, hit_eta, hit_phi (simple geometry) - //CaloDetDescrElement *bestcell = m_calo_dd_man->get_element(m_calo_dd_man->get_element(id)->getSampling(),origpos.eta(), origpos.phi()); - CaloDetDescrElement *highestcell = m_calo_dd_man->get_element(e_subhitmax_id); - //from identifier - CaloDetDescrElement *thiscell = m_calo_dd_man->get_element(id); - //delete them afterwards? - if (!highestcell) - { - //How often does this happen, do not shift - std::cout <<"ZH highestEcell failed: "<<e_subhitmax_id.getString()<<std::endl; - //" "<<m_calo_dd_man->get_element(id)->getSampling()<<" "<<origpos.eta()<<" "<< origpos.phi()<<std::endl; - //do no shift? - pos = origpos; - } - else if (highestcell == thiscell) - { - //the cells match, do not shift this hit - //std::cout <<"No shift: index: "<<i<<std::endl; - //std::cout <<"Orig pos: "<<origpos.x()<<" "<<origpos.y()<<" "<<origpos.z()<<std::endl; - //std::cout <<"This cell: "<<thiscell->x()<<" "<<thiscell->y()<<" "<<thiscell->z()<<std::endl; - //std::cout <<"No shift"<<std::endl; - pos = origpos; - } - else - { - //the two cells do not match => shift - //std::cout <<"Orig pos: "<<origpos.x()<<" "<<origpos.y()<<" "<<origpos.z()<<std::endl; - G4ThreeVector diff(thiscell->x()-highestcell->x(), thiscell->y()-highestcell->y(), thiscell->z()-highestcell->z()); - pos = origpos+diff; - //std::cout <<"Shift: ! index: "<<i<<std::endl; - //std::cout <<"This cell: "<<thiscell->x()<<" "<<thiscell->y()<<" "<<thiscell->z()<<std::endl; - //std::cout <<"Highest E cell: "<<highestcell->x()<<" "<<highestcell->y()<<" "<<highestcell->z()<<std::endl; - //std::cout <<"(Best cell: "<<bestcell->x()<<" "<<bestcell->y()<<" "<<bestcell->z()<<")"<<std::endl; - //std::cout <<"Shift pos: "<<pos.x()<<" "<<pos.y()<<" "<<pos.z()<<std::endl; - } - //delete highestcell; - //delete thiscell; - } - } - else - { - //Does this happen? - std::cout <<"More subhits, but not in LAr barrel "<<(std::string) ident<<std::endl; - } - } - - /* - //This was only for testing purposes that the shifted hits match to the right cells - CaloDetDescrElement *pcell = m_calo_dd_man->get_element(id); - if (pcell) - { - G4ThreeVector cellvec(pcell->x(),pcell->y(), pcell->z()); - std::cout <<"Hit-cell dist: "<<(pos-cellvec).mag()<<" in: "<<i<<" "<<(std::string) ident<<" sampling: "<<pcell->getSampling()<<" "<<id.getString()<<std::endl; - CaloDetDescrElement *testcell = m_calo_dd_man->get_element(pcell->getSampling(),pos.eta(), pos.phi()); - if (testcell) - { - G4ThreeVector testvec(testcell->x(),testcell->y(), testcell->z()); - std::cout <<"Test cell: "<<testcell->x()<<" "<<testcell->y()<<" "<<testcell->z()<<" "<<testcell->identify().getString()<<std::endl; - std::cout <<"Hit-test cell dist: "<<(pos-testvec).mag()<<" in: "<<i<<" sampling: "<<testcell->getSampling()<<std::endl; - } - else - { - std::cout <<"Test cell failed: "<<pcell->getSampling()<<" "<<pos.eta()<<" "<<pos.phi()<<std::endl; - } - } - else - { - std::cout <<"pcell failed: "<<id.getString()<<std::endl; - } - */ - //Finalize time for LAr hits?: NO - //double time = m_current_calculator->energy(i)==0 ? 0. : (double) m_current_calculator->time(i)/m_current_calculator->energy(i)/CLHEP::ns; - double time = m_current_calculator->time(i); - double energy = m_current_calculator->energy(i)/CLHEP::MeV; - - ISF_FCS_Parametrization::FCS_StepInfo* theInfo = new ISF_FCS_Parametrization::FCS_StepInfo(pos, id, energy, time, true, nlarh); //store nlarh as info - //This one stores also StepLength, but it is not yet in SVN... - // ISF_FCS_Parametrization::FCS_StepInfo* theInfo = new ISF_FCS_Parametrization::FCS_StepInfo(pos, id, (double) m_current_calculator->energy(i), (double) m_current_calculator->time(i), true, nlarh, StepLength); //store nlarh as info - //std::cout <<"Adding new step info: "<<i<<" at: "<<pos<<" Id: "<<id<<" E: "<<energy<<" time: "<<time<<std::endl; - m_eventSteps->push_back(theInfo); - }//nlarh - //std::cout <<"----"<<std::endl; - } //istep - - //Delete steps? - if (steps.size()>1) - { - //only when doing substeps, don't want to delete the original a4step - while(!steps.empty()) delete steps.back(), steps.pop_back(); - } + + double et = 0; // Total collected charge + //G4cout << m_current_calculator << " " << position << G4endl; + + std::vector<const G4Step*> steps; + //bool shortstep = false; + if (m_config.shorten_lar_step && StepLength>0.2) + { + //create smaller substeps instead + G4int nsub_step=(int) (StepLength/0.2) + 1; + G4double delta=1./((double) nsub_step); + //std::cout <<"Orig prestep: "<<aStep->GetPreStepPoint()->GetPosition()<<std::endl; + for (G4int i=0;i<nsub_step;i++) { + // G4double fraction=(((G4double) i)+0.5)*delta; + G4double fraction1 = ((G4double) i)*delta; + G4double fraction2 = (((G4double) i) + 1.)*delta; + G4ThreeVector subpoint1=position1*(1-fraction1) + position2*fraction1; + G4ThreeVector subpoint2=position1*(1-fraction2) + position2*fraction2; + + //G4StepPoint *startpoint = 0; + //startpoint = const_cast<G4StepPoint*>(aStep->GetPreStepPoint()); + //startpoint->SetPosition(subpoint1); + //G4StepPoint *endpoint = 0; + //endpoint = const_cast<G4StepPoint*>(aStep->GetPostStepPoint()); + //endpoint->SetPosition(subpoint2); + + G4StepPoint *startpoint = new G4StepPoint(*(aStep->GetPreStepPoint())); + G4StepPoint *endpoint = new G4StepPoint(*(aStep->GetPostStepPoint())); + startpoint->SetPosition(subpoint1); + endpoint->SetPosition(subpoint2); + + //std::cout <<"ZH substep: "<<i<<" Pos: "<<subpoint1<<" "<<subpoint2<<std::endl; + G4Step* newstep = new G4Step(*aStep); + //newstep = const_cast<G4Step*>(aStep); + if(newstep->GetPreStepPoint()) delete newstep->GetPreStepPoint(); + if(newstep->GetPostStepPoint()) delete newstep->GetPostStepPoint(); + newstep->SetPreStepPoint(startpoint); + newstep->SetPostStepPoint(endpoint); + newstep->SetStepLength( (subpoint1-subpoint2).mag()); + newstep->SetTotalEnergyDeposit(aStep->GetTotalEnergyDeposit()/nsub_step); + //std::cout <<"ZH substep: "<<newstep->GetPreStepPoint()->GetPosition()<<" "<<newstep->GetPostStepPoint()->GetPosition()<<" / "<<0.5*(newstep->GetPreStepPoint()->GetPosition()+newstep->GetPostStepPoint()->GetPosition())<<std::endl; + steps.push_back(newstep); + } + //std::cout <<"Orig poststep"<<aStep->GetPostStepPoint()->GetPosition()<<std::endl; + //shortstep = true; + } + else + { + steps.push_back(aStep); + } + + //std::cout <<"ZH Step size: "<<steps.size()<<" full step length "<<StepLength<<std::endl; + for (unsigned int istep = 0; istep <steps.size(); istep++) + { + //need to update the position! + pos = 0.5*(steps[istep]->GetPreStepPoint()->GetPosition()+steps[istep]->GetPostStepPoint()->GetPosition()); + //std::cout <<"ZH Processing step: "<<istep<<" at position "<<pos<<std::endl; + + std::vector<LArHitData> results; + if (m_current_calculator->Process(steps[istep], results)) + { + //if (!shortstep) G4cout <<"ZH process step ok: "<<results.size()<<G4endl; + + for (auto larhit: results) + { + et += larhit.energy; + //std::cout <<"ZH Hit: "<<i<<" E: "<<larhit.energy<<" in: "<<(std::string) larhit.id <<std::endl; + } + } + else + { + //Maybe 0 hits or something like that... + //G4cout << "ZH: Error: Hit not processed by calculator! " << istep<<" / "<<steps.size()<<" shortstep: "<<shortstep<<G4endl; + //G4cout << "ZH: calculator not processed: Volume: "<< pCurrentVolume->GetName()<<" "<<m_current_calculator<< " position: "<<pos<<" SL: "<<StepLength<<G4endl; + //G4cout <<"ZH: Orig position: "<<steps[istep]->GetPreStepPoint()->GetPosition()<<" / "<<steps[istep]->GetPostStepPoint()->GetPosition()<<"and SL: "<<StepLength<<" step: "<<aStep->GetPreStepPoint()->GetPosition()<<" / "<<aStep->GetPostStepPoint()->GetPosition()<<G4endl; + return; + } + + // drop hits with zero deposited energy (could still happen with negative corrections from calculator) + //Or if total energy is <0 + if (et <= 0.) + { + std::cout <<"ZH: Total negative energy: "<<et<<" not processing..."<<std::endl; + return; + } + + size_t nlarh = results.size(); + std::vector<G4ThreeVector> subhitcells; + subhitcells.resize(nlarh); + G4ThreeVector origpos = pos; + double e_subhitmax = -999.; + int e_subhitmaxindex =-1; + if (nlarh>0) + { + e_subhitmax = results[0].energy; + e_subhitmaxindex = 0; + } + //Figure out the subhit with most energy + for (size_t i=1; i<nlarh; ++i) + { + if (e_subhitmax< results[i].energy) + { + e_subhitmax = results[i].energy; + e_subhitmaxindex = i; + } + } + //Identifier for the subhit with max energy + LArG4Identifier e_subhitmax_ident = results[e_subhitmaxindex].id; + Identifier e_subhitmax_id = m_lar_helper->ConvertID(e_subhitmax_ident); + + for (size_t i=0; i<nlarh; ++i) + { + LArG4Identifier ident = results[i].id; + Identifier id = m_lar_helper->ConvertID(ident); + + Identifier inv_id; + if (id == inv_id) + { + std::cout <<"Something wrong with identifier (LAr): "<<(std::string) ident; + std::cout <<" "<<id<<" "<<id.getString()<<" "<<CurrentLogicalVolumeName <<" nhit: "<<nlarh<<std::endl; + std::cout <<inv_id<<std::endl; + } + + //std::cout <<"Subhit: "<<i<<std::endl; + //std::cout <<"LArIdent "<<(std::string) ident<<std::endl; + //std::cout <<"Ident "<<id.getString()<<std::endl; + //std::cout <<"ZH Step: LAr: "<<StepLength<<std::endl; + //need to get the cell information + + if (nlarh>1) + { + //it didn't seem to happen outside em_barrel + if (m_lar_emID->is_em_barrel(id)) + { + if (m_config.shift_lar_subhit) + { + //find subhit with largest energy + + if (e_subhitmaxindex == -1) + { + std::cout <<"ZH no subhit index with e>-999??? "<<std::endl; + return; + } + else + { + //std::cout <<"ZH shifting subhits: largest energy subhit index is "<<e_subhitmaxindex<<" E: "<<e_subhitmax<<" identifier: "<<e_subhitmax_id.getString()<<std::endl; + } + //from sampling, hit_eta, hit_phi (simple geometry) + //CaloDetDescrElement *bestcell = m_calo_dd_man->get_element(m_calo_dd_man->get_element(id)->getSampling(),origpos.eta(), origpos.phi()); + CaloDetDescrElement *highestcell = m_calo_dd_man->get_element(e_subhitmax_id); + //from identifier + CaloDetDescrElement *thiscell = m_calo_dd_man->get_element(id); + //delete them afterwards? + if (!highestcell) + { + //How often does this happen, do not shift + std::cout <<"ZH highestEcell failed: "<<e_subhitmax_id.getString()<<std::endl; + //" "<<m_calo_dd_man->get_element(id)->getSampling()<<" "<<origpos.eta()<<" "<< origpos.phi()<<std::endl; + //do no shift? + pos = origpos; + } + else if (highestcell == thiscell) + { + //the cells match, do not shift this hit + //std::cout <<"No shift: index: "<<i<<std::endl; + //std::cout <<"Orig pos: "<<origpos.x()<<" "<<origpos.y()<<" "<<origpos.z()<<std::endl; + //std::cout <<"This cell: "<<thiscell->x()<<" "<<thiscell->y()<<" "<<thiscell->z()<<std::endl; + //std::cout <<"No shift"<<std::endl; + pos = origpos; + } + else + { + //the two cells do not match => shift + //std::cout <<"Orig pos: "<<origpos.x()<<" "<<origpos.y()<<" "<<origpos.z()<<std::endl; + G4ThreeVector diff(thiscell->x()-highestcell->x(), thiscell->y()-highestcell->y(), thiscell->z()-highestcell->z()); + pos = origpos+diff; + //std::cout <<"Shift: ! index: "<<i<<std::endl; + //std::cout <<"This cell: "<<thiscell->x()<<" "<<thiscell->y()<<" "<<thiscell->z()<<std::endl; + //std::cout <<"Highest E cell: "<<highestcell->x()<<" "<<highestcell->y()<<" "<<highestcell->z()<<std::endl; + //std::cout <<"(Best cell: "<<bestcell->x()<<" "<<bestcell->y()<<" "<<bestcell->z()<<")"<<std::endl; + //std::cout <<"Shift pos: "<<pos.x()<<" "<<pos.y()<<" "<<pos.z()<<std::endl; + } + //delete highestcell; + //delete thiscell; + } + } + else + { + //Does this happen? + std::cout <<"More subhits, but not in LAr barrel "<<(std::string) ident<<std::endl; + } + } + + /* + //This was only for testing purposes that the shifted hits match to the right cells + CaloDetDescrElement *pcell = m_calo_dd_man->get_element(id); + if (pcell) + { + G4ThreeVector cellvec(pcell->x(),pcell->y(), pcell->z()); + std::cout <<"Hit-cell dist: "<<(pos-cellvec).mag()<<" in: "<<i<<" "<<(std::string) ident<<" sampling: "<<pcell->getSampling()<<" "<<id.getString()<<std::endl; + CaloDetDescrElement *testcell = m_calo_dd_man->get_element(pcell->getSampling(),pos.eta(), pos.phi()); + if (testcell) + { + G4ThreeVector testvec(testcell->x(),testcell->y(), testcell->z()); + std::cout <<"Test cell: "<<testcell->x()<<" "<<testcell->y()<<" "<<testcell->z()<<" "<<testcell->identify().getString()<<std::endl; + std::cout <<"Hit-test cell dist: "<<(pos-testvec).mag()<<" in: "<<i<<" sampling: "<<testcell->getSampling()<<std::endl; + } + else + { + std::cout <<"Test cell failed: "<<pcell->getSampling()<<" "<<pos.eta()<<" "<<pos.phi()<<std::endl; + } + } + else + { + std::cout <<"pcell failed: "<<id.getString()<<std::endl; + } + */ + //Finalize time for LAr hits?: NO + //double time = results[i].energy)==0 ? 0. : (double) results[i].time/results[i].energy/CLHEP::ns; + double time = results[i].time; + double energy = results[i].energy/CLHEP::MeV; + + ISF_FCS_Parametrization::FCS_StepInfo* theInfo = new ISF_FCS_Parametrization::FCS_StepInfo(pos, id, energy, time, true, nlarh); //store nlarh as info + //This one stores also StepLength, but it is not yet in SVN... + // ISF_FCS_Parametrization::FCS_StepInfo* theInfo = new ISF_FCS_Parametrization::FCS_StepInfo(pos, id, (double) results[i].energy, (double) results[i].time, true, nlarh, StepLength); //store nlarh as info + //std::cout <<"Adding new step info: "<<i<<" at: "<<pos<<" Id: "<<id<<" E: "<<energy<<" time: "<<time<<std::endl; + m_eventSteps->push_back(theInfo); + }//nlarh + //std::cout <<"----"<<std::endl; + } //istep + + //Delete steps? + if (steps.size()>1) + { + //only when doing substeps, don't want to delete the original a4step + while(!steps.empty()) delete steps.back(), steps.pop_back(); + } } //////////////////////// //Do TileCal Stuff //////////////////////// - + else if (m_current_calculator_Tile) - { - //std::cout<<"GG: Hello" << std::endl; - - //calculation of MicroHit with aStep - TileMicroHit micHit = m_calculator_Tile->TileGeoG4SDCalc::GetTileMicroHit(aStep); - Identifier m_invalid_id; - - //Check if MicroHit is not in scintillator - if ((micHit.pmt_up == m_invalid_id) && (micHit.pmt_down == m_invalid_id)) { - std::cout <<"Invalid hit in Tile??"<<std::endl; - return;} - else { - // Store TileHits Information - //std::cout <<"ZH Step: Tile: "<<StepLength<<std::endl; - if ((micHit.pmt_up == m_invalid_id) || (micHit.pmt_down == m_invalid_id)) - { - //std::cout <<"Something wrong in identifier: One tile pmt: "<<micHit.pmt_up<<" "<<micHit.pmt_down<<std::endl; - //std::cout <<"E up: "<<micHit.e_up<<" E down: "<<micHit.e_down<<" T up: "<<micHit.time_up<<" T down: "<<micHit.time_down<<std::endl; - } - ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_up = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_up, micHit.e_up, micHit.time_up, true,1); - //Commented out version needs ISF_Event which is not yet in SVN.. - // ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_up = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_up, micHit.e_up, micHit.time_up, true,1,StepLength); - m_eventSteps->push_back(theInfo_Tile_up); - - ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_down = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_down, micHit.e_down,micHit.time_down , true,1); - //ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_down = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_down, micHit.e_down,micHit.time_down , true,1,StepLength); - m_eventSteps->push_back(theInfo_Tile_down); - - //std::cout << "GG: GetTileMicroHit: pmtID_up,pmtID_down,edep_up,edep_down,scin_Time_up,scin_Time_down:\t" << micHit.pmt_up <<";\t"<< micHit.pmt_down <<";\t"<< micHit.e_up <<";\t"<< micHit.e_down <<";\t" << micHit.time_up <<";\t"<< micHit.time_down << std::endl; - - } - - - } + { + //std::cout<<"GG: Hello" << std::endl; + + //calculation of MicroHit with aStep + TileMicroHit micHit = m_calculator_Tile->TileGeoG4SDCalc::GetTileMicroHit(aStep); + Identifier m_invalid_id; + + //Check if MicroHit is not in scintillator + if ((micHit.pmt_up == m_invalid_id) && (micHit.pmt_down == m_invalid_id)) { + std::cout <<"Invalid hit in Tile??"<<std::endl; + return;} + else { + // Store TileHits Information + //std::cout <<"ZH Step: Tile: "<<StepLength<<std::endl; + if ((micHit.pmt_up == m_invalid_id) || (micHit.pmt_down == m_invalid_id)) + { + //std::cout <<"Something wrong in identifier: One tile pmt: "<<micHit.pmt_up<<" "<<micHit.pmt_down<<std::endl; + //std::cout <<"E up: "<<micHit.e_up<<" E down: "<<micHit.e_down<<" T up: "<<micHit.time_up<<" T down: "<<micHit.time_down<<std::endl; + } + ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_up = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_up, micHit.e_up, micHit.time_up, true,1); + //Commented out version needs ISF_Event which is not yet in SVN.. + // ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_up = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_up, micHit.e_up, micHit.time_up, true,1,StepLength); + m_eventSteps->push_back(theInfo_Tile_up); + + ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_down = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_down, micHit.e_down,micHit.time_down , true,1); + //ISF_FCS_Parametrization::FCS_StepInfo* theInfo_Tile_down = new ISF_FCS_Parametrization::FCS_StepInfo(pos, micHit.pmt_down, micHit.e_down,micHit.time_down , true,1,StepLength); + m_eventSteps->push_back(theInfo_Tile_down); + + //std::cout << "GG: GetTileMicroHit: pmtID_up,pmtID_down,edep_up,edep_down,scin_Time_up,scin_Time_down:\t" << micHit.pmt_up <<";\t"<< micHit.pmt_down <<";\t"<< micHit.e_up <<";\t"<< micHit.e_down <<";\t" << micHit.time_up <<";\t"<< micHit.time_down << std::endl; + + } + + + } else - { - //Shouldn't be here anyway.. - G4cout <<"ZH ???"<<aStep->GetTotalEnergyDeposit() << G4endl; - } + { + //Shouldn't be here anyway.. + G4cout <<"ZH ???"<<aStep->GetTotalEnergyDeposit() << G4endl; + } //std::cout <<"End of step"<<std::endl; return; } return; - - - + + + } -} // namespace G4UA +} // namespace G4UA diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamActionTool.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamActionTool.cxx index a74198b85b71..da2f6d16278a 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamActionTool.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/FastCaloSimParamActionTool.cxx @@ -4,24 +4,82 @@ #include "CxxUtils/make_unique.h" #include "ISF_Geant4UserActions/FastCaloSimParamActionTool.h" +#include "LArG4Code/ILArCalculatorSvc.h" -namespace G4UA{ +namespace G4UA{ - FastCaloSimParamActionTool::FastCaloSimParamActionTool(const std::string& type, const std::string& name,const IInterface* parent): - ActionToolBase<FastCaloSimParamAction>(type, name, parent), m_config(){ + FastCaloSimParamActionTool::FastCaloSimParamActionTool(const std::string& type, const std::string& name,const IInterface* parent) + : ActionToolBase<FastCaloSimParamAction>(type, name, parent) + , m_config() + , m_emepiwcalc("EMECPosInnerWheelCalculator", name) + , m_emeniwcalc("EMECNegInnerWheelCalculator", name) + , m_emepowcalc("EMECPosOuterWheelCalculator", name) + , m_emenowcalc("EMECNegOuterWheelCalculator", name) + , m_emeobarcalc("EMECBackOuterBarretteCalculator", name) + , m_embcalc("EMBCalculator", name) + , m_fcal1calc("FCAL1Calculator", name) + , m_fcal2calc("FCAL2Calculator", name) + , m_fcal3calc("FCAL3Calculator", name) + , m_heccalc("HECWheelCalculator", name) + , m_pscalc("EMBPresamplerCalculator", name) + , m_emepscalc("EMECPresamplerCalculator", name) + { declareProperty("shift_lar_subhit",m_config.shift_lar_subhit, ""); declareProperty("shorten_lar_step",m_config.shorten_lar_step, ""); - + + declareProperty("EMECPosIWCalculator", m_emepiwcalc); + declareProperty("EMECNegIWCalculator", m_emeniwcalc); + declareProperty("EMECPosOWCalculator", m_emepowcalc); + declareProperty("EMECNegOWCalculator", m_emenowcalc); + declareProperty("EMECBOBCalculator", m_emeobarcalc); + declareProperty("EMBCalculator",m_embcalc); + declareProperty("FCAL1Calculator", m_fcal1calc); + declareProperty("FCAL2Calculator", m_fcal2calc); + declareProperty("FCAL3Calculator", m_fcal3calc); + declareProperty("HECWheelCalculator", m_heccalc); + declareProperty("EMBPSCalculator",m_pscalc); + declareProperty("EMECPSCalculator", m_emepscalc); + } + + StatusCode FastCaloSimParamActionTool::initialize() + { + ATH_CHECK(m_emepiwcalc.retrieve()); + ATH_CHECK(m_emeniwcalc.retrieve()); + ATH_CHECK(m_emepowcalc.retrieve()); + ATH_CHECK(m_emenowcalc.retrieve()); + ATH_CHECK(m_emeobarcalc.retrieve()); + ATH_CHECK(m_embcalc.retrieve()); + ATH_CHECK(m_fcal1calc.retrieve()); + ATH_CHECK(m_fcal2calc.retrieve()); + ATH_CHECK(m_fcal3calc.retrieve()); + ATH_CHECK(m_heccalc.retrieve()); + ATH_CHECK(m_pscalc.retrieve()); + ATH_CHECK(m_emepscalc.retrieve()); + m_config.calculator_EMECIW_pos = &*m_emepiwcalc; + m_config.calculator_EMECIW_neg = &*m_emeniwcalc; + m_config.calculator_EMECOW_pos = &*m_emepowcalc; + m_config.calculator_EMECOW_neg = &*m_emenowcalc; + m_config.calculator_BOB = &*m_emeobarcalc; + m_config.calculator_EMB = &*m_embcalc; + m_config.calculator_FCAL1 = &*m_fcal1calc; + m_config.calculator_FCAL2 = &*m_fcal2calc; + m_config.calculator_FCAL3 = &*m_fcal3calc; + m_config.calculator_HEC = &*m_heccalc; + m_config.calculator_EMBPS = &*m_pscalc; + m_config.calculator_EMEPS = &*m_emepscalc; + + return StatusCode::SUCCESS; } - std::unique_ptr<FastCaloSimParamAction> FastCaloSimParamActionTool::makeAction(){ + std::unique_ptr<FastCaloSimParamAction> FastCaloSimParamActionTool::makeAction() + { ATH_MSG_DEBUG("makeAction"); auto action = CxxUtils::make_unique<FastCaloSimParamAction>(m_config); return std::move(action); } - + StatusCode FastCaloSimParamActionTool::queryInterface(const InterfaceID& riid, void** ppvIf){ - + if(riid == IBeginRunActionTool::interfaceID()) { *ppvIf = (IBeginRunActionTool*) this; addRef(); @@ -49,5 +107,5 @@ namespace G4UA{ } return ActionToolBase<FastCaloSimParamAction>::queryInterface(riid, ppvIf); } - -} // namespace G4UA + +} // namespace G4UA diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.cxx index c29b1ffd39d1..b89569a8ddf4 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.cxx @@ -13,6 +13,7 @@ #include "TFile.h" #include "TTree.h" + #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/ISvcLocator.h" #include "GaudiKernel/IMessageSvc.h" diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.h b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.h index c857cf46c09f..8d7837e8e521 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.h +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4UserActions/src/TestBoundariesUserAction.h @@ -13,6 +13,7 @@ class TTree; class TFile; #include "TMath.h" + #include "G4AtlasInterfaces/IBeginRunAction.h" #include "G4AtlasInterfaces/IEndRunAction.h" #include "G4AtlasInterfaces/ISteppingAction.h" diff --git a/graphics/VP1/VP1Utils/src/SoVisualizeAction.cxx b/graphics/VP1/VP1Utils/src/SoVisualizeAction.cxx old mode 100644 new mode 100755 index 150fa20f6d6f..395c9beb478b --- a/graphics/VP1/VP1Utils/src/SoVisualizeAction.cxx +++ b/graphics/VP1/VP1Utils/src/SoVisualizeAction.cxx @@ -164,11 +164,11 @@ void SoVisualizeAction::handleLArCustom(const LArCustomShape *custom) SoLAr::initClass(); SoLAr *solar = new SoLAr(); const LArWheelCalculator *calc = custom->calculator(); - LArWheelCalculator::LArWheelCalculator_t type = calc->type(); - if (type==LArWheelCalculator::InnerAbsorberWheel || - type==LArWheelCalculator::InnerElectrodWheel || - type==LArWheelCalculator::InnerAbsorberModule || - type==LArWheelCalculator::InnerElectrodModule ) { + LArG4::LArWheelCalculator_t type = calc->type(); + if (type==LArG4::InnerAbsorberWheel || + type==LArG4::InnerElectrodWheel || + type==LArG4::InnerAbsorberModule || + type==LArG4::InnerElectrodModule ) { float zPlane[2],rInner[2],rOuter[2]; zPlane[0]=0; zPlane[1]=calc->GetWheelThickness(); @@ -188,10 +188,10 @@ void SoVisualizeAction::handleLArCustom(const LArCustomShape *custom) solar->fRmax.setValues(0,2,rOuter); solar->fDz.setValues (0,2,zPlane); } - else if (type==LArWheelCalculator::OuterAbsorberWheel || - type==LArWheelCalculator::OuterElectrodWheel || - type==LArWheelCalculator::OuterAbsorberModule || - type==LArWheelCalculator::OuterElectrodModule ) { + else if (type==LArG4::OuterAbsorberWheel || + type==LArG4::OuterElectrodWheel || + type==LArG4::OuterAbsorberModule || + type==LArG4::OuterElectrodModule ) { float zPlane[3], rInner[3], rOuter[3]; zPlane[0] = 0; zPlane[2] = calc->GetWheelThickness(); -- GitLab