From aa62fef83ec2a79c0305479ee62bf6b9698c66ed Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <frank.winklmeier@cern.ch> Date: Mon, 18 Mar 2019 08:43:05 +0000 Subject: [PATCH] Revert "Merge branch 'remove_old_calo' into 'master'" This reverts merge request !21910 --- .../TrigT2CaloCosmic/CMakeLists.txt | 33 + .../TrigT2CaloCosmic/CosmicHadEnFex.h | 47 + .../TrigT2CaloCosmic/CosmicSamp2Fex.h | 73 + .../TrigT2CaloCosmic/T2CaloCosmic.h | 77 + .../python/TrigT2CaloCosmicConfig.py | 91 + .../TrigT2CaloCosmic/python/__init__.py | 6 + .../TrigT2CaloCosmic/src/CosmicHadEnFex.cxx | 181 ++ .../TrigT2CaloCosmic/src/CosmicSamp2Fex.cxx | 184 ++ .../TrigT2CaloCosmic/src/T2CaloCosmic.cxx | 270 +++ .../components/TrigT2CaloCosmic_entries.cxx | 16 + .../TrigT2CaloJet/CMakeLists.txt | 57 + .../TrigT2CaloJet/EtaPhiSampleHash.h | 69 + .../TrigT2CaloJet/GridsHandler.h | 42 + .../TrigT2CaloJet/HashedTrig3Momentum.h | 39 + .../TrigT2CaloJet/T2AllRoiUnpacking.h | 233 +++ .../TrigT2CaloJet/T2CaloFastJet.h | 148 ++ .../TrigT2CaloJet/TrigT2CaloJet/T2CaloJet.h | 97 ++ .../TrigT2CaloJet/T2CaloJetBaseTool.h | 58 + .../TrigT2CaloJet/T2CaloJetCalibTool.h | 77 + .../TrigT2CaloJet/T2CaloJetConeTool.h | 77 + .../TrigT2CaloJet/T2CaloJetGridFromCells.h | 118 ++ .../T2CaloJetGridFromFEBHeader.h | 87 + .../TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h | 46 + .../TrigT2CaloJet/T2L1CaloFullScanJet.h | 95 + .../TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJet.h | 82 + .../TrigT2CaloJet/T2L1CaloJetCalibTool.h | 68 + .../T2L1CaloJetFullScanBaseTool.h | 54 + .../T2L1CaloJetFullScanFastJetTool.h | 128 ++ .../TrigT2CaloJet/TrigT2CaloJet/T2L1Tools.h | 136 ++ .../TrigT2CaloJet/T2L1ToolsDict.h | 10 + .../TrigT2CaloJet/T2L1TowerCalibTool.h | 69 + .../TrigT2CaloJet/T2L1Unpacking.h | 116 ++ .../TrigT2CaloJet/Trig3MomentumMerger.h | 33 + .../TrigT2CaloJet/TrigT2CaloJet/selection.xml | 3 + .../python/CalibrationFactorsL15.py | 126 ++ .../python/TrigT2CaloJetConfig.py | 1541 +++++++++++++++++ .../python/TrigT2CaloJetMonitoring.py | 630 +++++++ .../share/jobOfragment_TrigT2CaloJet.py | 139 ++ .../jobOfragment_TrigT2CaloJet_RomeCalib.py | 181 ++ .../TrigT2CaloJet/src/EtaPhiSampleHash.cxx | 84 + .../TrigT2CaloJet/src/GridsHandler.cxx | 72 + .../TrigT2CaloJet/src/HashedTrig3Momentum.cxx | 55 + .../TrigT2CaloJet/src/T2AllRoiUnpacking.cxx | 496 ++++++ .../TrigT2CaloJet/src/T2CaloFastJet.cxx | 824 +++++++++ .../TrigT2CaloJet/src/T2CaloJet.cxx | 491 ++++++ .../TrigT2CaloJet/src/T2CaloJetBaseTool.cxx | 61 + .../TrigT2CaloJet/src/T2CaloJetCalibTool.cxx | 422 +++++ .../TrigT2CaloJet/src/T2CaloJetConeTool.cxx | 352 ++++ .../src/T2CaloJetGridFromCells.cxx | 443 +++++ .../src/T2CaloJetGridFromFEBHeader.cxx | 381 ++++ .../src/T2CaloJetGridFromLvl1Ppr.cxx | 92 + .../TrigT2CaloJet/src/T2L1CaloFullScanJet.cxx | 322 ++++ .../TrigT2CaloJet/src/T2L1CaloJet.cxx | 371 ++++ .../src/T2L1CaloJetCalibTool.cxx | 236 +++ .../src/T2L1CaloJetFullScanBaseTool.cxx | 57 + .../src/T2L1CaloJetFullScanFastJetTool.cxx | 568 ++++++ .../TrigT2CaloJet/src/T2L1TowerCalibTool.cxx | 255 +++ .../TrigT2CaloJet/src/T2L1Unpacking.cxx | 649 +++++++ .../TrigT2CaloJet/src/Trig3MomentumMerger.cxx | 140 ++ .../src/components/TrigT2CaloJet_entries.cxx | 35 + .../TrigT2CaloTau/CMakeLists.txt | 42 + .../TrigT2CaloTau/T2CalibrationTau.h | 52 + .../TrigT2CaloTau/TrigT2CaloTau/T2CaloTau.h | 144 ++ .../TrigT2CaloTau/T2CaloTauErrorHandler.h | 25 + .../TrigT2CaloTau/T2CaloTauErrorMon.h | 53 + .../TrigT2CaloTau/TauAllCaloDRFex.h | 90 + .../TrigT2CaloTau/doc/packagedoc.h | 21 + .../python/TrigT2CaloTauConfig.py | 104 ++ .../python/TrigT2CaloTauMonitoring.py | 109 ++ .../TrigT2CaloTau/src/T2CaloTau.cxx | 663 +++++++ .../TrigT2CaloTau/src/TauAllCaloDRFex.cxx | 1186 +++++++++++++ .../src/components/TrigT2CaloTau_entries.cxx | 7 + .../TrigT2CaloTileMon/CMakeLists.txt | 36 + .../TrigT2CaloTileMon/T2CaloTileMon.h | 76 + .../TrigT2CaloTileMon/TileMonHadEnFex.h | 80 + .../TrigT2CaloTileMon/TrigT2TileJet.h | 50 + .../TrigT2CaloTileMon/TrigT2Tower.h | 80 + .../python/TrigT2CaloTileMonConfig.py | 36 + .../TrigT2CaloTileMon/src/T2CaloTileMon.cxx | 156 ++ .../TrigT2CaloTileMon/src/TileMonHadEnFex.cxx | 424 +++++ .../TrigT2CaloTileMon/src/TrigT2TileJet.cxx | 97 ++ .../TrigT2CaloTileMon/src/TrigT2Tower.cxx | 131 ++ .../components/TrigT2CaloTileMon_entries.cxx | 6 + 83 files changed, 15611 insertions(+) create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloCosmic/CMakeLists.txt create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicHadEnFex.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicSamp2Fex.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/T2CaloCosmic.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/TrigT2CaloCosmicConfig.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/__init__.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicHadEnFex.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicSamp2Fex.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/T2CaloCosmic.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/components/TrigT2CaloCosmic_entries.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/CMakeLists.txt create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/EtaPhiSampleHash.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/GridsHandler.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/HashedTrig3Momentum.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2AllRoiUnpacking.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloFastJet.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJet.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetBaseTool.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetCalibTool.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetConeTool.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromCells.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromFEBHeader.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloFullScanJet.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJet.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetCalibTool.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanFastJetTool.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Tools.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1ToolsDict.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1TowerCalibTool.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Unpacking.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/Trig3MomentumMerger.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/selection.xml create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/python/CalibrationFactorsL15.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetConfig.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetMonitoring.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet_RomeCalib.py create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/EtaPhiSampleHash.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/GridsHandler.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/HashedTrig3Momentum.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2AllRoiUnpacking.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloFastJet.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJet.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetBaseTool.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetCalibTool.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetConeTool.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromCells.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromFEBHeader.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromLvl1Ppr.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloFullScanJet.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJet.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetCalibTool.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanBaseTool.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanFastJetTool.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1TowerCalibTool.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1Unpacking.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/Trig3MomentumMerger.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloJet/src/components/TrigT2CaloJet_entries.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTau/CMakeLists.txt create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CalibrationTau.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTau.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorHandler.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorMon.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/TauAllCaloDRFex.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTau/doc/packagedoc.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauConfig.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauMonitoring.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTau/src/T2CaloTau.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTau/src/TauAllCaloDRFex.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTau/src/components/TrigT2CaloTau_entries.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTileMon/CMakeLists.txt create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/T2CaloTileMon.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TileMonHadEnFex.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2TileJet.h create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2Tower.h create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/python/TrigT2CaloTileMonConfig.py create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/T2CaloTileMon.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TileMonHadEnFex.cxx create mode 100755 Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2TileJet.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2Tower.cxx create mode 100644 Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/components/TrigT2CaloTileMon_entries.cxx diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/CMakeLists.txt b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/CMakeLists.txt new file mode 100644 index 00000000000..4991e6f18ca --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/CMakeLists.txt @@ -0,0 +1,33 @@ +################################################################################ +# Package: TrigT2CaloCosmic +################################################################################ + +# Declare the package name: +atlas_subdir( TrigT2CaloCosmic ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + DetectorDescription/IRegionSelector + GaudiKernel + Trigger/TrigAlgorithms/TrigT2CaloCommon + Trigger/TrigEvent/TrigCaloEvent + Trigger/TrigEvent/TrigSteeringEvent + PRIVATE + Calorimeter/CaloGeoHelpers + Calorimeter/CaloIdentifier + Trigger/TrigT1/TrigT1Interfaces ) + +# Component(s) in the package: +atlas_add_library( TrigT2CaloCosmicLib + src/*.cxx + PUBLIC_HEADERS TrigT2CaloCosmic + LINK_LIBRARIES IRegionSelector GaudiKernel TrigCaloEvent TrigSteeringEvent TrigT2CaloCommonLib + PRIVATE_LINK_LIBRARIES CaloGeoHelpers CaloIdentifier TrigT1Interfaces ) + +atlas_add_component( TrigT2CaloCosmic + src/components/*.cxx + LINK_LIBRARIES IRegionSelector GaudiKernel TrigT2CaloCommonLib TrigCaloEvent TrigSteeringEvent CaloGeoHelpers CaloIdentifier TrigT1Interfaces TrigT2CaloCosmicLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicHadEnFex.h b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicHadEnFex.h new file mode 100755 index 00000000000..ae55ad0e219 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicHadEnFex.h @@ -0,0 +1,47 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: CosmicHadEnFex.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCosmic + + AUTHOR: D.O.Damazio + + PURPOSE: Based on Cluster position defined in the second + EM Calorimeter layer, calculates total Had cluster + energy. + *******************************************************************/ + +#ifndef TRIGT2CALOCOSMIC_COSMICHADENFEX_H +#define TRIGT2CALOCOSMIC_COSMICHADENFEX_H + +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "GaudiKernel/AlgTool.h" + +/** Feature extraction Tool for LVL2 Calo. Hadronic EndCaps + and Tile Calorimeter. All Samples */ +class CosmicHadEnFex: public IAlgToolCalo { + public: + /** Constructor */ + CosmicHadEnFex(const std::string & type, const std::string & name, + const IInterface* parent); + /** Destructor */ + virtual ~CosmicHadEnFex(); + /** @brief execute feature extraction for the EM Calorimeter + * second layer + * @param[out] rtrigEmCluster is the output cluster. + * @param[in] eta/phi-min/max = RoI definition. + */ + using IAlgToolCalo::execute; + StatusCode execute(TrigEMCluster &rtrigEmCluster,double etamin, + double etamax, double phimin, double phimax); + private: + float m_THR_1; + float m_THR_2; + +}; + + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicSamp2Fex.h b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicSamp2Fex.h new file mode 100755 index 00000000000..7833b89ca7a --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/CosmicSamp2Fex.h @@ -0,0 +1,73 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: CosmicSamp2Fex.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCosmic + + AUTHOR: D.O. Damazio + + PURPOSE: Calculates energy weighted cluster position around + hottest cell in RoI for LAr second layer. + *******************************************************************/ + +#ifndef TRIGT2CALOCOSMIC_CALOSAMP2FEXCOSMIC_H +#define TRIGT2CALOCOSMIC_CALOSAMP2FEXCOSMIC_H + + +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "GaudiKernel/AlgTool.h" + +#include "IRegionSelector/IRoiDescriptor.h" + +/** Feature extraction Tool for LVL2 Calo. Second EM Calorimeter sample. */ +class CosmicSamp2Fex: public IAlgToolCalo { + public: + /** Constructor */ + CosmicSamp2Fex(const std::string & type, const std::string & name, + const IInterface* parent); + /** Destructor */ + virtual ~CosmicSamp2Fex(); + /** @brief execute feature extraction for the EM Calorimeter + * second layer + * @param[out] rtrigEmCluster is the output cluster. + * @param[in] eta/phi-min/max = RoI definition. + */ + using IAlgToolCalo::execute; + // StatusCode execute(TrigEMCluster &rtrigEmCluster,double etamin, + // double etamax, double phimin, double phimax); + StatusCode execute(TrigEMCluster &rtrigEmCluster, + const IRoiDescriptor& roi, + const CaloDetDescrElement*& /*caloDDE*/); + + /** Special initialize for Samp2 to include eta as a + trigger timer item monitored parameter. Important + to compare time performance as a function of cluster + position. + */ + StatusCode initialize() { + // Very important to call base class initialize + if ( IAlgToolCalo::initialize().isFailure() ) { + *(new MsgStream(AlgTool::msgSvc(), name())) + << MSG::FATAL + << "Could not init base class IAlgTooCalo" << endmsg; + } + std::string basename(name().substr(25,5)+"."); + if (m_timersvc) { + m_timer[0]->propName(basename+"Eta"); + } + return StatusCode::SUCCESS; + } + + private: + double etaSizeLArEMSamp2(const double eta, const int calo) const; + double phiSizeLArEMSamp2(const double eta, const int calo) const; + float m_THR_1; + float m_THR_2; + +}; + + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/T2CaloCosmic.h b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/T2CaloCosmic.h new file mode 100755 index 00000000000..944639bc794 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/TrigT2CaloCosmic/T2CaloCosmic.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: T2CaloCosmic.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCosmic + + AUTHOR: D.O. Damazio + + PURPOSE: Based on T2CaloBase works as main driver for the LVL2 + Calorimeter Cosmic Algorithm. Receives and decodes LVL1 + information (RoI position), creates the TrigEMCluster to + be the output of LVL2 Calo with extracted features. Call + IAlgToolCalos to perform FEX. + *******************************************************************/ + +#ifndef TRIGT2CALOCOSMIC_T2CALOCOSMIC_H +#define TRIGT2CALOCOSMIC_T2CALOCOSMIC_H + +#include <string> +#include "TrigT2CaloCommon/T2CaloBase.h" + +class IAlgToolCalo; +class T2CaloEgammaMon; +class MsgStream; +class TrigEMCluster; + +/** Main LVL2 Algorithm. Processes LVL1 information, call FEX + IAlgToolCalos and produces the TrigEMCluster output. */ +class T2CaloCosmic: public T2CaloBase { + + + public: + /** Constructor */ + T2CaloCosmic(const std::string & name, ISvcLocator* pSvcLocator); + /** Destructor */ + ~T2CaloCosmic(); + + /** hltExecute will call FEX IAlgToolCalo::execute() to process RoI. + called by the Steering per EMRoI. */ + HLT::ErrorCode hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE); + /** hltInitialize. Called by the Steering. */ + HLT::ErrorCode hltInitialize(); + /** hltFinalize. Called by the Steering. */ + HLT::ErrorCode hltFinalize(); + + private: + + /** Monitoring Tool */ + // T2CaloEgammaMon* m_monitoring; + /** To support new monitoring. Values must be copied to + this monitored Cluster for each RoI. */ + const TrigEMCluster* m_monitoredCluster; + /** To monitor rCore */ + float m_rCore; + /** To monitor eRatio */ + float m_eRatio; + /** Forced LVL1 eta */ + float m_l1eta; + /** Forced LVL1 phi */ + float m_l1phi; + + // Properties: + std::string m_trigEmClusterKey; + /** Will monitoring be used or not */ + //bool m_mon; + /** Coordinates to be used by the tools (in order by tool) */ + std::vector<float> m_etamin; + std::vector<float> m_etamax; + std::vector<float> m_phimin; + std::vector<float> m_phimax; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/TrigT2CaloCosmicConfig.py b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/TrigT2CaloCosmicConfig.py new file mode 100755 index 00000000000..0cae5c1d6b0 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/TrigT2CaloCosmicConfig.py @@ -0,0 +1,91 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +from TrigT2CaloCosmic.TrigT2CaloCosmicConf import CosmicSamp2Fex +from TrigT2CaloCosmic.TrigT2CaloCosmicConf import CosmicHadEnFex +from TrigT2CaloCosmic.TrigT2CaloCosmicConf import T2CaloCosmic + +#from TrigMonitorBase.TrigGenericMonitoringToolConfig import defineHistogram +#from TrigMonitorBase.TrigGenericMonitoringToolConfig import TrigGenericMonitoringToolConfig + +#from AthenaCommon.Constants import VERBOSE,DEBUG + +class CosmicHadEnFex1(CosmicHadEnFex): + __slots__ = [] + def __init__ (self, name="CosmicHadEnFex1"): + super(CosmicHadEnFex1,self).__init__(name) + self.THR_1=200 + +class CosmicHadEnFex2(CosmicHadEnFex): + __slots__ = [] + def __init__ (self, name="CosmicHadEnFex2"): + super(CosmicHadEnFex2,self).__init__(name) + self.THR_1=200 + +class CosmicSamp2Fex1(CosmicSamp2Fex): + __slots__ = [] + def __init__ (self, name="CosmicSamp2Fex1"): + super(CosmicSamp2Fex1,self).__init__(name) + self.THR_1=420 + +class CosmicSamp2Fex2(CosmicSamp2Fex): + __slots__ = [] + def __init__ (self, name="CosmicSamp2Fex2"): + super(CosmicSamp2Fex2,self).__init__(name) + self.THR_1=420 + + +class T2CaloCosmic_Cosmic (T2CaloCosmic): + __slots__ = [] + def __init__ (self, name="T2CaloCosmic_Cosmic"): + super(T2CaloCosmic_Cosmic, self).__init__(name) + # here put your customizations + self.IAlgToolList= [CosmicHadEnFex1(), + CosmicHadEnFex2(), + CosmicSamp2Fex1(), + CosmicSamp2Fex2()] + #self.EtaMin=[0.2,0,0.2,-1.0] + #self.EtaMax=[ 0.6, 1.0, 0.6, 0] + self.EtaMin=[1.0, 0.1, 0.1, -0.1] + self.EtaMax=[ 2.4, 2.4, 2.4, 2.4 ] + self.PhiMin=[1.3, -1.8, 1.3, -1.8] + self.PhiMax=[1.8, -1.3, 1.8, -1.3] + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.TimerNtuple="T2CaloCosmic.T2CaEgtTot" + self.TrigEMClusterKey="T2CaloCosmic" +# self.Monitoring=False +# self.OutputLevel = DEBUG +# self.AthenaMonTools = [ TrigT2CaloCosmicValMonitoring(), +# TrigT2CaloCosmicOnMonitoring() ] + +class T2CaloCosmic_Cosmic_NoHad (T2CaloCosmic): + __slots__ = [] + def __init__ (self, name="T2CaloCosmic_Cosmic_NoHad"): + super(T2CaloCosmic_Cosmic_NoHad, self).__init__(name) + # here put your customizations + self.IAlgToolList= [CosmicSamp2Fex()] + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.TimerNtuple="T2CaloCosmic.T2CaEgtTot" + self.TrigEMClusterKey="T2CaloTrigEMCluster" +# self.Monitoring=False +# self.OutputLevel = DEBUG +# self.AthenaMonTools = [ TrigT2CaloCosmicValMonitoring(), +# TrigT2CaloCosmicOnMonitoring() ] + +class T2CaloCosmic_Cosmic_NoEm (T2CaloCosmic): + __slots__ = [] + def __init__ (self, name="T2CaloCosmic_Cosmic_NoEm"): + super(T2CaloCosmic_Cosmic_NoEm, self).__init__(name) + # here put your customizations + self.IAlgToolList= [CosmicHadEnFex()] + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.TimerNtuple="T2CaloCosmic.T2CaEgtTot" + self.TrigEMClusterKey="T2CaloTrigEMCluster" +# self.Monitoring=False +# self.OutputLevel = DEBUG +# self.AthenaMonTools = [ TrigT2CaloCosmicValMonitoring(), +# TrigT2CaloCosmicOnMonitoring() ] + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/__init__.py b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/__init__.py new file mode 100755 index 00000000000..0cbf9c602df --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/python/__init__.py @@ -0,0 +1,6 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +__version__ = "1.0.0" +__author__ = "Denis.Oiveira.Damazio@cern.ch" +__all__ = [ "TrigT2CaloCosmicConfig" ] diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicHadEnFex.cxx b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicHadEnFex.cxx new file mode 100755 index 00000000000..35192b4467d --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicHadEnFex.cxx @@ -0,0 +1,181 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: CosmicHadEnFex.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCosmic +// +// AUTHOR: M.P. Casado +// +// REFERENCES: Based on Trigger/TrigT2CaloCosmic/T2EmHadAlgorithm.cxx +// +// ******************************************************************** + +#include "TrigCaloEvent/TrigEMCluster.h" +#include "CaloGeoHelpers/CaloSampling.h" + +#include "TrigT2CaloCosmic/CosmicHadEnFex.h" +#include "TrigT2CaloCommon/Calo_Def.h" + + +CosmicHadEnFex::CosmicHadEnFex(const std::string & type, const std::string & name, + const IInterface* parent): IAlgToolCalo(type, name, parent), + m_THR_1(400),m_THR_2(100) + { + declareProperty("THR_1",m_THR_1); + declareProperty("THR_2",m_THR_2); + //#ifndef NDEBUG +/* + // 1 -> CaloType HAD, 0 -> First Layer + m_geometry[0] = new T2Geometry(1,0); + // 1 -> CaloType HAD, 1 -> Second Layer + m_geometry[1] = new T2Geometry(1,1); + // 1 -> CaloType HAD, 2 -> Third Layer + m_geometry[2] = new T2Geometry(1,2); +*/ +//#endif +} + +CosmicHadEnFex::~CosmicHadEnFex(){ +} + +StatusCode CosmicHadEnFex::execute(TrigEMCluster &rtrigEmCluster,double etamin, + double etamax, double phimin, double phimax){ + + m_lardecoded=false; + m_tiledecoded=false; + // Time total AlgTool time + if (!m_timersvc.empty()) m_timer[0]->start(); + + // MsgStream log(msgSvc(), name()); + if (msgLvl(MSG::DEBUG)) ATH_MSG_DEBUG("in execute(TrigEMCluster &)"); + + double deta = 0.; // eta difference current cell - seed + double dphi = 0.; // phi difference current cell - seed + + CaloSampling::CaloSample samp; + + double energyEta = rtrigEmCluster.eta(); + double energyPhi = rtrigEmCluster.phi(); + rtrigEmCluster.set_ehad1(0.); + + // Dump eta-phi strip ranges into arrays + // Define variables here so that their scope covers both the Tile and HEC loops + // Use arrays of length 3 since there is no samp 0 in the HAD calorimeters + // this avoids wasting memory but makes the code slightly less clear + + // Time Region Selector + if (!m_timersvc.empty()) { + m_timer[1]->start(); + m_timer[1]->pause(); + m_timer[2]->start(); + m_timer[2]->pause(); + m_timer[3]->start(); + m_timer[3]->pause(); + m_timer[4]->start(); + m_timer[4]->pause(); + } + double seedEnergy = 0.; + double seedPhi = 0; + double seedEta = 999.; + + // TILECAL Assuming no knowledge about first sample + + // Time to access RegionSelector + if (!m_timersvc.empty()) m_timer[1]->resume(); + + // Region Selector, no sample needed + // Get detector offline ID's for Collections + m_data->RegionSelector(0,etamin,etamax,phimin,phimax,TILE); + + if (!m_timersvc.empty()) m_timer[1]->pause(); + + for (unsigned int iR=0;iR<m_data->TileContSize();iR++) { + + // Time to access Collection (and ByteStreamCnv ROBs) + if (!m_timersvc.empty()) m_timer[2]->resume(); + // For the first sample you will create the containers + // For the others no + if ( m_data->LoadCollections(m_itBegin,m_itEnd,iR,!iR).isFailure() ) + return StatusCode::FAILURE; + m_tiledecoded=true; + if ( m_saveCells ) IAlgToolCalo::storeCells(); + // Finished to access Collection + if (!m_timersvc.empty()) m_timer[2]->pause(); + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->resume(); + + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) { //loop over cells + + //double etaCell = (*m_itt)->eta(); + //double phiCell = (*m_itt)->phi(); + //double energyCell = (*m_itt)->energy(); + if ((*m_itt)->energy() > seedEnergy && (*m_itt)->energy() > m_THR_1) { + seedEnergy = (*m_itt)->energy(); + seedEta = (*m_itt)->eta(); + seedPhi = (*m_itt)->phi(); + } + } + if (!m_timersvc.empty()) m_timer[3]->pause(); + } + energyEta = seedEta; + energyPhi = seedPhi; + rtrigEmCluster.setEta(seedEta); + rtrigEmCluster.setPhi(seedPhi); + rtrigEmCluster.setEnergy(seedEnergy); + rtrigEmCluster.set_ehad1(0.); + rtrigEmCluster.set_e277(999); + rtrigEmCluster.set_e2tsts1(999); + + for (unsigned int iR=0;iR<m_data->TileContSize();iR++) { + + // Time to access Collection (and ByteStreamCnv ROBs) + if (!m_timersvc.empty()) m_timer[2]->resume(); + // For the first sample you will create the containers + // For the others no + if ( m_data->LoadCollections(m_itBegin,m_itEnd,iR,!iR).isFailure() ) + return StatusCode::FAILURE; + // Finished to access Collection + if (!m_timersvc.empty()) m_timer[2]->pause(); + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->resume(); + + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) { //loop over cells + + double etaCell = (*m_itt)->eta(); + double phiCell = (*m_itt)->phi(); + double energyCell = (*m_itt)->energy(); + + // find position of current cell w.r.t. seed + deta = fabs( etaCell - energyEta ); + dphi = fabs( phiCell - energyPhi ); + if ( dphi > M_PI ) dphi = 2.* M_PI - dphi; // wrap 0 -> 6.28 + // hadronic measurements: energy sum in 0.1*0.1 + if ( deta <= 0.1 && + dphi <= 0.1 && energyCell>m_THR_2){ + //samp = CaloSampling::getSampling(*(*m_itt)); + samp = (*m_itt)->caloDDE()->getSampling(); + rtrigEmCluster.setEnergy(samp,rtrigEmCluster.energy(samp) + energyCell); + rtrigEmCluster.setRawEnergy(samp,rtrigEmCluster.rawEnergy(samp) + energyCell); + } + + } // end of loop over cells + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->pause(); + + } // End of loop over TileCal drawers + + + // Stop all timers + if (!m_timersvc.empty()){ + m_timer[4]->stop(); + m_timer[3]->stop(); + m_timer[2]->stop(); + m_timer[1]->stop(); + m_timer[0]->stop(); + } + + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicSamp2Fex.cxx b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicSamp2Fex.cxx new file mode 100755 index 00000000000..985b61cc1a1 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/CosmicSamp2Fex.cxx @@ -0,0 +1,184 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: CosmicSamp2Fex.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCosmic +// +// AUTHOR: M.P. Casado +// +// +// ******************************************************************** + +#include "CaloIdentifier/LArEM_ID.h" + +#include "TrigCaloEvent/TrigEMCluster.h" +#include "CaloGeoHelpers/CaloSampling.h" + +#include "TrigT2CaloCosmic/CosmicSamp2Fex.h" +#include "TrigT2CaloCommon/Calo_Def.h" + + +CosmicSamp2Fex::CosmicSamp2Fex(const std::string & type, const std::string & name, + const IInterface* parent): IAlgToolCalo(type, name, parent) + { + declareProperty("THR_1",m_THR_1 = 400.0); + declareProperty("THR_2",m_THR_2 = 100.0); + //#ifndef NDEBUG + // Create Geometry object + // 0 -> CaloType EM, 2 -> Second Layer + // m_geometry[0] = new T2Geometry(0,2); + //#endif +} + +CosmicSamp2Fex::~CosmicSamp2Fex(){ +} + +StatusCode CosmicSamp2Fex::execute(TrigEMCluster &rtrigEmCluster, + const IRoiDescriptor& roi, + const CaloDetDescrElement*& /*caloDDE*/) { + + m_lardecoded=false; + m_tiledecoded=false; + // Time total AlgTool time + if (!m_timersvc.empty()) m_timer[0]->start(); + + if (msgLvl(MSG::DEBUG)) + ATH_MSG_DEBUG("in execute(TrigEMCluster&)"); + + // Time to access RegionSelector + if (!m_timersvc.empty()) m_timer[1]->start(); + + // Region Selector, sampling 2 + int sampling = 2; + // Get detector offline ID's for Collections + m_data->RegionSelector(sampling, roi); + + // Finished to access RegionSelector + if (!m_timersvc.empty()) m_timer[1]->stop(); + // Time to access Collection (and ByteStreamCnv ROBs) + if (!m_timersvc.empty()) m_timer[2]->start(); + + if ( m_data->LoadCollections(m_iBegin,m_iEnd).isFailure() ) + return StatusCode::FAILURE; + m_lardecoded=true; + if ( m_saveCells ) IAlgToolCalo::storeCells(); + // Finished to access Collection + if (!m_timersvc.empty()) m_timer[2]->stop(); + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->start(); + + //double energyEta = 0.; + //double energyPhi = 0.; + + // add these variables to take care of phi wrap-around + //double energyNegPhi = 0.; //SRA + //double energyNegPhiConv = 0.; //SRA + //double energyPosPhi = 0.; //SRA + + + // 1. Find seed cell (highest Et in ROI .. layer 2) + // 2. Find Et weighted eta, phi in 3*7 cell (layer 2) (photon + e id) + // 3. Find Et in cells of sizes 3*3, 3*7, 7*7 (layer 2 + strips) + // (3*7 for photon + e id) + // 4. Find cluster width in 3*5 cell, layer 2 (photon id, needs + // parabolic parametrisation) + // 5. Find strip energies and eta (2*5 window) + // 6. Find frac73 (photon id), (E1-E2)/(E1+E2) (e + photon id) + + double seedEnergy = 0.; + double seedPhi = 0.; + double seedEta = 999.; + + //const LArEM_ID* emID = m_larMgr->getEM_ID(); + for(m_it = m_iBegin;m_it != m_iEnd; ++m_it) { + if ((*m_it)->energy() > seedEnergy && (*m_it)->energy() > m_THR_1) { + seedEnergy = (*m_it)->energy(); + seedEta = (*m_it)->eta(); + seedPhi = (*m_it)->phi(); + } + } + + for(m_it = m_iBegin;m_it != m_iEnd; ++m_it) { + + double etaCell = (*m_it)->eta(); + double phiCell = (*m_it)->phi(); + double energyCell = (*m_it)->energy(); + + // find position of current cell w.r.t. seed + float deta = fabs( etaCell - seedEta ); + float dphi = fabs( phiCell - seedPhi ); + if ( dphi > M_PI ) dphi = 2.* M_PI - dphi; // wrap 0 -> 6.28 + // hadronic measurements: energy sum in 0.1*0.1 + if ( deta <= 0.1 && + dphi <= 0.1 && energyCell>m_THR_2){ + //CaloSampling::CaloSample samp = CaloSampling::getSampling(*(*m_it)); + CaloSampling::CaloSample samp = (*m_it)->caloDDE()->getSampling(); + rtrigEmCluster.setEnergy(samp,rtrigEmCluster.energy(samp) + energyCell); + rtrigEmCluster.setRawEnergy(samp,rtrigEmCluster.rawEnergy(samp) + energyCell); + } + } + + //double totalEnergy = 0; + //CaloSampling::CaloSample samp; + + + if (!m_timersvc.empty()) m_timer[3]->stop(); + // Save EMShowerMinimal time + if (!m_timersvc.empty()) m_timer[4]->start(); + + + // Update cluster Variables + + rtrigEmCluster.set_e277(999); + rtrigEmCluster.set_e2tsts1(999); + rtrigEmCluster.setRawEnergy( seedEnergy ); + rtrigEmCluster.setEnergy( seedEnergy ); + rtrigEmCluster.setEta(seedEta); + rtrigEmCluster.setPhi(seedPhi); + rtrigEmCluster.setRawEta(seedEta); + rtrigEmCluster.setRawPhi(seedPhi); + + // Finished save EMShowerMinimal time + if (!m_timersvc.empty()) m_timer[4]->stop(); + + + // Time total AlgTool time + if (!m_timersvc.empty()) m_timer[0]->stop(); + + return StatusCode::SUCCESS; +} + +double CosmicSamp2Fex::etaSizeLArEMSamp2(double cellEta, int calo) const{ + double sizeEta; + if( calo == Calorimeter::EMBAR ){ + if ( fabs(cellEta) < 1.4 ){ + sizeEta = 0.025; + }else{ + sizeEta = 0.075; + } + } else { + if ( fabs(cellEta) < 2.5 ){ + sizeEta = 0.025; + } else{ + sizeEta = 0.1; + } + } + return sizeEta; +} + +double CosmicSamp2Fex::phiSizeLArEMSamp2(double cellEta, int calo) const{ + double sizePhi; + if( calo == Calorimeter::EMBAR ){ + sizePhi = 0.025; + } else { + if ( fabs(cellEta) < 2.5 ){ + sizePhi = 0.025; + } else { + sizePhi = 0.1; + } + } + return sizePhi; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/T2CaloCosmic.cxx b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/T2CaloCosmic.cxx new file mode 100755 index 00000000000..ea59fd90b94 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/T2CaloCosmic.cxx @@ -0,0 +1,270 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloCosmic.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloCosmic +// +// AUTHOR: D.O. Damazio +// +// - Add variables for job option controlled region limits, set defaults +// to most likely values. +// - Add function EtaPhiRange to return the maximum and minimum eta or phi +// values to use when calculating energy sums over a region - R. Soluk +// ******************************************************************** + +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IToolSvc.h" +#include "GaudiKernel/StatusCode.h" + +#include "TrigT1Interfaces/RecEmTauRoI.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" +#include "TrigSteeringEvent/PhiHelper.h" + + +#include "TrigCaloEvent/TrigEMClusterContainer.h" + +#include "TrigT2CaloCosmic/T2CaloCosmic.h" +//#include "TrigT2CaloCosmic/T2CaloCosmicMon.h" +#include "TrigT2CaloCommon/IAlgToolCalo.h" + +class ISvcLocator; + +T2CaloCosmic::T2CaloCosmic(const std::string & name, ISvcLocator* pSvcLocator) + : T2CaloBase(name, pSvcLocator) +{ + declareProperty("TrigEMClusterKey",m_trigEmClusterKey = "T2CaloTrigEMCluster"); + declareProperty("L1ForceEta",m_l1eta = -10.0); + declareProperty("L1ForcePhi",m_l1phi = -10.0); + declareProperty("EtaMin",m_etamin); + declareProperty("EtaMax",m_etamax); + declareProperty("PhiMin",m_phimin); + declareProperty("PhiMax",m_phimax); +} + +T2CaloCosmic::~T2CaloCosmic() +{ +} + + +HLT::ErrorCode T2CaloCosmic::hltInitialize() +{ + // Support for new monitoring + declareMonitoredObject("Eta", + m_monitoredCluster,&TrigEMCluster::eta); + declareMonitoredObject("Phi", + m_monitoredCluster,&TrigEMCluster::phi); + declareMonitoredObject("Et", + m_monitoredCluster,&TrigEMCluster::et); + declareMonitoredObject("Had1Et", + m_monitoredCluster,&TrigEMCluster::ehad1); + declareMonitoredObject("weta2", + m_monitoredCluster,&TrigEMCluster::weta2); + // More complicated variables to be monitored + declareMonitoredVariable("Rcore", m_rCore ); + declareMonitoredVariable("Eratio",m_eRatio); + + return HLT::OK; +} + + +HLT::ErrorCode T2CaloCosmic::hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE) +{ + // Time total T2CaloCosmic execution time. + if ( m_timersvc ) m_timer[0]->start(); + + if (msgLvl(MSG::DEBUG)) + ATH_MSG_DEBUG("in execute()"); + + + //bool status = false; + + // Some debug output: + if (msgLvl(MSG::DEBUG)) { + msg (MSG::DEBUG) << "outputTE->getId(): " << outputTE->getId() << endmsg; + + msg(MSG::DEBUG) << "inputTE->getId(): " << inputTE->getId() << endmsg; + } + + const TrigRoiDescriptor* roiDescriptor = 0; + + HLT::ErrorCode hltStatus = getFeature(inputTE, roiDescriptor); + + if ( hltStatus == HLT::OK ) { + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << *roiDescriptor << endmsg; + } else { + msg(MSG::WARNING) << " Failed to find RoiDescriptor " << endmsg; + return hltStatus; + } + + // Some debug output: + + msg(MSG::DEBUG) << "Message to count events. LVL1 phi=" + << roiDescriptor->phi() + << " & LVL1 eta=" + << roiDescriptor->eta() + << endmsg; + + // End LVL1 part + double etamin, etamax, phimin, phimax; + double eta, phi; + + int roiword = roiDescriptor->roiWord(); + + // if ( !m_trustRoiLimits ) { + if ( (m_l1eta<-9.9)&&(m_l1phi<-9.9)){ + eta = roiDescriptor->eta(); + phi = roiDescriptor->phi(); + } + else { + eta = m_l1eta; + phi = HLT::wrapPhi(m_l1phi); + } + + etamin = std::max(-2.5, eta - m_etaWidth); + etamax = std::min( 2.5, eta + m_etaWidth); + phimin = HLT::wrapPhi( phi - m_phiWidth); + phimax = HLT::wrapPhi( phi + m_phiWidth); + + TrigRoiDescriptor* newroi = new TrigRoiDescriptor( eta, etamin, etamax, phi, phimin, phimax ); + attachFeature( outputTE, newroi, "T2CaloCosmic" ); + roiDescriptor = newroi; + + // } + + + + if (msgLvl(MSG::DEBUG)) { + msg(MSG::DEBUG) << " etamin = "<< *roiDescriptor << endmsg; + // (*m_log) << MSG::DEBUG << " etamin = "<< etamin << endmsg; + // (*m_log) << MSG::DEBUG << " etamax = "<< etamax << endmsg; + // (*m_log) << MSG::DEBUG << " phimin = "<< phimin << endmsg; + // (*m_log) << MSG::DEBUG << " phimax = "<< phimax << endmsg; + } + + + if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " Making TrigEMCluster "<< endmsg; + + std::vector<xAOD::TrigEMCluster*> vec_clus; + std::cout << "m_emAlgTools.size() = " << m_emAlgTools.size() << std::endl; + // Ok, ignoring LVL1 and forcing a position + int counter=0; + + ToolHandleArray<IAlgToolCalo>::iterator it = m_emAlgTools.begin(); + if ( m_timersvc ) m_timer[1]->start(); + for (; it < m_emAlgTools.end(); it++) { + xAOD::TrigEMCluster* ptrigEmCluster = new xAOD::TrigEMCluster(); + // It is a good idea to clear the energies + for(int i=0;i<MAXSIZE;i++) + ptrigEmCluster->setEnergy((CaloSampling::CaloSample )i,0.); + + // Add RoI word to TrigEMCluster + (*ptrigEmCluster).setRoIword(roiword); + (*ptrigEmCluster).setEta1(10+counter); + etamin=m_etamin[counter]; + etamax=m_etamax[counter]; + phimin=m_phimin[counter]; + phimax=m_phimax[counter]; + // if ((*it)->execute(*ptrigEmCluster,etamin,etamax,phimin,phimax).isFailure() ) { + if ((*it)->execute(*ptrigEmCluster,*roiDescriptor, caloDDENull).isFailure() ) { + ATH_MSG_WARNING("T2Calo AlgToolCosmic returned Failure"); + return HLT::TOOL_FAILURE; + } + // If you do not have any hot cell in top or bottom, stop algo + if ( (counter==0 || counter==1) && (*ptrigEmCluster).energy()==0) + return HLT::OK; + counter++; + vec_clus.push_back(ptrigEmCluster); + } + // support to new monitoring + m_rCore=0; + m_eRatio=0; +/* + if ( ptrigEmCluster->e277()!=0 ) + m_rCore = ptrigEmCluster->e237()/ptrigEmCluster->e277(); + if ( ptrigEmCluster->emaxs1()+ptrigEmCluster->e2tsts1() !=0){ + m_eRatio = ptrigEmCluster->emaxs1()-ptrigEmCluster->e2tsts1(); + m_eRatio /= ptrigEmCluster->emaxs1()+ptrigEmCluster->e2tsts1(); + } +*/ + if ( m_timersvc ) m_timer[1]->stop(); + for(size_t i=0;i<vec_clus.size();i++){ + xAOD::TrigEMCluster* ptrigEmCluster=vec_clus[i]; + + // Print out Cluster produced + msg(MSG::DEBUG) << " Values of Cluster produced: "<< endmsg; + msg(MSG::DEBUG) << " REGTEST: emEnergy = "<< (*ptrigEmCluster).energy() << endmsg; + msg(MSG::DEBUG) << " REGTEST: hadEnergy = "<< (*ptrigEmCluster).ehad1() << endmsg; + msg(MSG::DEBUG) << " REGTEST: rCore = " << ((*ptrigEmCluster).e237() )/ ((*ptrigEmCluster).e277()) << endmsg; + msg(MSG::DEBUG) << " REGTEST: energyRatio = " + << (((*ptrigEmCluster).emaxs1()-(*ptrigEmCluster).e2tsts1())/ + ((*ptrigEmCluster).emaxs1()+(*ptrigEmCluster).e2tsts1())) + << endmsg; + msg(MSG::DEBUG) << " REGTEST: clusterWidth = " << (*ptrigEmCluster).weta2() << endmsg; + msg(MSG::DEBUG) << " REGTEST: frac73 = " << (*ptrigEmCluster).fracs1() << endmsg; + msg(MSG::DEBUG) << " REGTEST: eta = "<< (*ptrigEmCluster).eta() << endmsg; + msg(MSG::DEBUG) << " REGTEST: phi = "<< (*ptrigEmCluster).phi() << endmsg; + msg(MSG::DEBUG) << " REGTEST: roiWord = " << (*ptrigEmCluster).RoIword() << endmsg; + + // Fill monitoring hists: +/* + if (m_mon) + if ( m_monitoring->fillT2CaloCosmicHists(ptrigEmCluster).isFailure() ) + (*m_log) << MSG::DEBUG << " Failled to Monitor" << endmsg; +*/ + + std::string key = ""; + + hltStatus = recordAndAttachFeature(outputTE, ptrigEmCluster, key, "TrigT2CaloCosmic"); + if (hltStatus != HLT::OK){ + if(msgLvl(MSG::DEBUG)) ATH_MSG_ERROR("Write of TrigEMCluster into outputTE failed"); + return hltStatus; + } + } + + // Create a new RoiDescriptor with updated eta and phi. + // Note that the steering will propagate l1Id and roiId automatically + // so no need to set them. +/* + TrigEMCluster* ptrigEmCluster = vec_clus[0]; + TrigRoiDescriptor* newRoiDescriptor = + new TrigRoiDescriptor(roiDescriptor->l1Id(), roiDescriptor->roiId(), + ptrigEmCluster->eta(), ptrigEmCluster->phi()); + + hltStatus = attachFeature(outputTE,newRoiDescriptor,"TrigT2CaloCosmic"); + + if ( hltStatus != HLT::OK ) { + (*m_log) << MSG::ERROR << "Write of update TrigRoiDescriptor into outputTE failed" + << endmsg; + return hltStatus; + } +*/ + +//#ifndef NDEBUG + // (*m_log) << MSG::DEBUG << "Recorded an RoiDescriptor " +// << " phi " << newRoiDescriptor->phi0() +// << " eta " << newRoiDescriptor->eta0() << endmsg; +//#endif + + // Some debug output: + if (msgLvl(MSG::DEBUG)) { + msg(MSG::DEBUG) << "We assume success, set TE with Id " + << outputTE->getId() << " active to signal positive result." + << endmsg; + } + + // Time total T2CaloCosmic execution time. + if ( m_timersvc ) m_timer[0]->stop(); + + return HLT::OK; +} + + +HLT::ErrorCode T2CaloCosmic::hltFinalize(){ + // if ( msgLvl() <= MSG::INFO ) + if (msgLvl(MSG::DEBUG)) ATH_MSG_DEBUG("in finalize()"); + return HLT::OK; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/components/TrigT2CaloCosmic_entries.cxx b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/components/TrigT2CaloCosmic_entries.cxx new file mode 100644 index 00000000000..f6ffcb69cfc --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloCosmic/src/components/TrigT2CaloCosmic_entries.cxx @@ -0,0 +1,16 @@ +#include "TrigT2CaloCosmic/T2CaloCosmic.h" +//#include "TrigT2CaloCosmic/T2CaloCosmicMon.h" +//#include "TrigT2CaloCosmic/T2CaloCosmicSamp1.h" +#include "TrigT2CaloCosmic/CosmicSamp2Fex.h" +//#include "TrigT2CaloCosmic/CosmicSamp1Fex.h" +//#include "TrigT2CaloCosmic/CosmicEmEnFex.h" +#include "TrigT2CaloCosmic/CosmicHadEnFex.h" + +DECLARE_COMPONENT( T2CaloCosmic ) +//DECLARE_COMPONENT( T2CaloCosmicSamp1 ) +DECLARE_COMPONENT( CosmicSamp2Fex ) +//DECLARE_COMPONENT( CosmicSamp1Fex ) +//DECLARE_COMPONENT( CosmicEmEnFex ) +DECLARE_COMPONENT( CosmicHadEnFex ) +//DECLARE_COMPONENT( T2CaloCosmicMon ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/CMakeLists.txt b/Trigger/TrigAlgorithms/TrigT2CaloJet/CMakeLists.txt new file mode 100644 index 00000000000..feea8bb7f8d --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/CMakeLists.txt @@ -0,0 +1,57 @@ +################################################################################ +# Package: TrigT2CaloJet +################################################################################ + +# Declare the package name: +atlas_subdir( TrigT2CaloJet ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Calorimeter/CaloInterface + Calorimeter/CaloRec + Control/AthContainers + DetectorDescription/IRegionSelector + GaudiKernel + Trigger/TrigAlgorithms/TrigT2CaloCommon + Trigger/TrigEvent/TrigCaloEvent + Trigger/TrigEvent/TrigParticle + Trigger/TrigEvent/TrigSteeringEvent + Trigger/TrigSteer/TrigInterfaces + Trigger/TrigTools/TrigT2CaloCalibration + Trigger/TrigTools/TrigTimeAlgs + PRIVATE + Calorimeter/CaloGeoHelpers + Control/AthenaKernel + Trigger/TrigT1/TrigT1CaloByteStream + Trigger/TrigT1/TrigT1CaloEvent + Trigger/TrigT1/TrigT1CaloToolInterfaces + Trigger/TrigT1/TrigT1Interfaces ) + +# External dependencies: +find_package( Boost COMPONENTS filesystem thread system ) +find_package( FastJet ) +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( TrigT2CaloJetLib + src/*.cxx + PUBLIC_HEADERS TrigT2CaloJet + INCLUDE_DIRS ${FASTJET_INCLUDE_DIRS} + PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${FASTJET_LIBRARIES} AthContainers IRegionSelector GaudiKernel TrigCaloEvent TrigParticle TrigSteeringEvent CaloRecLib TrigT2CaloCommonLib TrigInterfacesLib TrigT2CaloCalibrationLib TrigTimeAlgsLib TrigT1CaloEventLib + PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} CaloGeoHelpers AthenaKernel TrigT1CaloToolInterfaces TrigT1Interfaces ) + +atlas_add_component( TrigT2CaloJet + src/components/*.cxx + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${FASTJET_LIBRARIES} ${ROOT_LIBRARIES} CaloRecLib AthContainers IRegionSelector GaudiKernel TrigT2CaloCommonLib TrigCaloEvent TrigParticle TrigSteeringEvent TrigInterfacesLib TrigT2CaloCalibrationLib TrigTimeAlgsLib CaloGeoHelpers AthenaKernel TrigT1CaloEventLib TrigT1CaloToolInterfaces TrigT1Interfaces TrigT2CaloJetLib ) + +atlas_add_dictionary( T2L1ToolsDict + TrigT2CaloJet/T2L1ToolsDict.h + TrigT2CaloJet/selection.xml + INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${FASTJET_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${Boost_LIBRARIES} ${FASTJET_LIBRARIES} ${ROOT_LIBRARIES} CaloRecLib AthContainers IRegionSelector GaudiKernel TrigT2CaloCommonLib TrigCaloEvent TrigParticle TrigSteeringEvent TrigInterfacesLib TrigT2CaloCalibrationLib TrigTimeAlgsLib CaloGeoHelpers AthenaKernel TrigT1CaloEventLib TrigT1CaloToolInterfaces TrigT1Interfaces TrigT2CaloJetLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/EtaPhiSampleHash.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/EtaPhiSampleHash.h new file mode 100644 index 00000000000..39f6c5b4ba4 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/EtaPhiSampleHash.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include <stdlib.h> +#include <vector> + +#include "TrigCaloEvent/Trig3Momentum.h" // needed for CaloSample (no fwd decl for enum) + +class HashedTrig3Momentum; + + +/*! + @brief Class providing a map hash <--> (eta,phi,CaloSample). + + The function encoding (eta,phi,sample) into an int relies on a given + granularity in (eta,phi). All the points that fall in the same + 'tile' have the same hash. Currently using this with granularity + (eta x phi) = (0.1 x 0.1). Phi values are recorded in [-pi,+pi). Use + 'testEtaPhiSampleHash' to verify that it works also for your + granularity. + + This is the encoding of the 32-bit word (assumes int is 32-bit): + + 31 25 16 15 6 5 0 + +------+----------+----------+-------+ + |unused| phi | eta | sample| + +------+----------+----------+-------+ + + + */ +class EtaPhiSampleHash { +public: + static const u_short kMaxNetaBins = 1024; // 10 bits + static const u_short kMaxNphiBins = 1024; // 10 bits + static const u_short kMaxNsamples = 64; // 6 bits + static const u_int kTenBits = (kMaxNetaBins-1); + static const u_int kSixBits = (kMaxNsamples-1); + // Generalized (i.e. non-int) const must be assigned in the cpp if gcc<4.4 + static const double kMinEta; + static const double kMaxEta; + static const double kMinPhi; + static const double kMaxPhi; + +public: + EtaPhiSampleHash(const u_short &nEtaBins=100 /* 2*5.0/0.1*/, + const u_short &nPhiBins=64 /* 2*pi /0.1*/, + double minEta=kMinEta, double maxEta=kMaxEta, + double minPhi=kMinPhi, double maxPhi=kMaxPhi); + u_int hash(const double &eta, const double &phi, + const CaloSampling::CaloSample &sample) const; + u_int hash(const Trig3Momentum &t3m) const; + u_int hash(const HashedTrig3Momentum &mg) const; + bool etaPhiSample(const u_int &hash, double &eta, double &phi, + CaloSampling::CaloSample &sample) const; +private: + void checkValues(); +private: + double m_minEta; + double m_maxEta; + double m_minPhi; + double m_maxPhi; + double m_dEta; + double m_dPhi; + double m_invDeta; + double m_invDphi; + u_short m_nEtaBins; + u_short m_nPhiBins; +}; diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/GridsHandler.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/GridsHandler.h new file mode 100644 index 00000000000..afb1ae2d65b --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/GridsHandler.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_GRIDSHANDLER_H +#define TRIGT2CALOJET_GRIDSHANDLER_H + + +/*! + @brief Handles the separate grids for the different calorimeter compartments. + + April 2012 + davide.gerbaudo@gmail.com +*/ + +#include <stdlib.h> +#include <vector> +#include <map> +#include <algorithm> + +#include "TrigCaloEvent/Trig3Momentum.h" + +class HashedTrig3Momentum; + +typedef std::vector< HashedTrig3Momentum > Vmc; +typedef std::map< const CaloSampling::CaloSample, Vmc > CsVmcMap; +typedef std::pair<const CaloSampling::CaloSample, Vmc > CsVmcPair; +typedef std::vector< Trig3Momentum > Vt3m; + +class GridsHandler { + public: + GridsHandler(); + Vmc& grid(const CaloSampling::CaloSample &sample); + void clearAllGrids(); + void appendAllGrids(Vt3m &output) const; + private: + CsVmcMap m_grids; + std::vector< CaloSampling::CaloSample > m_allSamples; +}; + +#endif + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/HashedTrig3Momentum.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/HashedTrig3Momentum.h new file mode 100644 index 00000000000..754cb932645 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/HashedTrig3Momentum.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_HASHEDTRIG3MOMENTUM_H +#define TRIGT2CALOJET_HASHEDTRIG3MOMENTUM_H + +/*! + @brief Trig3Momentum with a hash; allows to merge energies from several Trig3Momentum. + + Eta and phi positions are computed as a weighted average of the + contributions from different locations in (eta,phi), where the + weight is abs(energy). + + April 2012 + davide.gerbaudo@gmail.com + */ + +#include "TrigCaloEvent/Trig3Momentum.h" + +typedef unsigned short u_short; +typedef unsigned u_int; + +class HashedTrig3Momentum : public Trig3Momentum { + public: + HashedTrig3Momentum(); + HashedTrig3Momentum(const Trig3Momentum &t3m, + const u_int &hash); + u_int hash() const {return m_hash;}; + void addE(const double &eta, const double &phi, const double &energy); + void addE(const Trig3Momentum &t3m); + void reset(); + private: + void updateWeightedCoord(const double &eta, const double &phi, const double &energy); + private: + u_int m_hash; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2AllRoiUnpacking.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2AllRoiUnpacking.h new file mode 100644 index 00000000000..14f644efa82 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2AllRoiUnpacking.h @@ -0,0 +1,233 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2AllRoiUnpacking.h +// PACKAGE: Trigger/TrigAlgorithms/T2AllRoiUnpacking +// +// AUTHOR: gerbaudo@cern.ch +// +// Description: Unpack several L2 calorimeter ROIs and store them in a single output grid. +// Used T2L1Unpacking (by Matthew Tamsett) as a template for this AllTEAlgo. +// Updates: +// Apr2012 (gerbaudo@cern.ch) +// add the option to merge EM cells to a coarser granularity. +// ******************************************************************** + +#ifndef TRIGT2CALOJET_T2ALLROIUNPACKING_H +#define TRIGT2CALOJET_T2ALLROIUNPACKING_H + +#include "TrigT2CaloJet/Trig3MomentumMerger.h" +#include "TrigT2CaloJet/T2CaloJetGridFromCells.h" +#include "TrigInterfaces/AllTEAlgo.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" +#include "GaudiKernel/ToolHandle.h" + +#include <ostream> + +class ITrigTimerSvc; +class TrigT2Jet; +class Trig3Momentum; +//class ITrigDataAccess; + +class T2AllRoiUnpacking: public HLT::AllTEAlgo { + + + public: + T2AllRoiUnpacking(const std::string & name, ISvcLocator* pSvcLocator); + ~T2AllRoiUnpacking(); + HLT::ErrorCode hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& input, + unsigned int output); + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize(); + //! N of elements initially allocated in the grid + /*! This is just a reasonable initial size for the vector (currently + using 2^13, which corresponds to ~10 ROI at low lumi after noise + suppr.). Also, this should be a static member (problems without + namespace?). + */ + const size_t kAllocatedGridCells_; + private: + // functions + //! Process one trigger element + /*! + Cells are stored in m_grid, which should be allocated beforehand. + @param te TriggerElement to be processed + @param grid where the cells are stored + */ + HLT::ErrorCode processTriggerElement(const HLT::TriggerElement *te, + std::vector<Trig3Momentum> *grid); + bool initializeTimers(); //!< initialize the timers + bool initializeHelperTools(); //!< initialize tools + void resetTimers(); //!< reset the monitoring timers + bool inputIsValid(const std::vector<std::vector<HLT::TriggerElement*> >& input) const; + HLT::TriggerElement* setupOutputTe(unsigned int type_out) ; //!< prepare the output trigger element + void storeTimers(); //!< store timings in the monitoring variables + HLT::ErrorCode finalizeOutput(HLT::TriggerElement* outputTE); //! finalize the output TE (allocate TrigT2Jet and attach its grid) + void finalizeAccessories(); //!< finalize everything that's not the output + void determineOverlaps(const EtaPhiRectangle &l2Roi); //!< determine overlaps and store them in m_overlapRegions + // Properties: + std::string m_jetOutputKey; + double m_roiEtaHalfWidth; //!< half width (in eta) of the L2 ROI that will be read out + double m_roiPhiHalfWidth; //!< half width (in phi) of the L2 ROI that will be read out + bool m_mergeEmCells; //!< whether or not the EM cells shoud be merged + // non-configurable datamembers (see T2CaloJetGridFromCells.cxx for details) + std::vector<Trig3Momentum> m_tmpGrid; //!< tmp grid used to extract before merge + std::vector<int> m_ttEmSamplings; //!< all possible EM samplings values + std::vector<int> m_ttHecSamplings; //!< all possible HEC samplings values + int m_tileSampling; //!< tilecal sampling + bool m_prepare; //!< prepare T2CaloJetGridFromCells + Trig3MomentumMerger m_tmm; //!< cell merger + + + protected: + ToolHandle< T2CaloJetGridFromCells > m_caloGridFromCellsTool; + bool m_retrievedGridTool; + std::vector<Trig3Momentum>* m_grid; + //! @f$ (\eta,\phi) @f$ regions that have been already processed + /*! This datamember is reset at each event */ + std::vector< EtaPhiRectangle > m_processedRegions; + //! @f$ (\eta,\phi) @f$ regions that overlap with regions that have already been processed + /*! This datamember is reset at each TriggerElement */ + std::vector< EtaPhiRectangle > m_overlapRegions; + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + TrigTimer *m_cell_unpacking_timer; //!< unpacking time ('addCell' only) + TrigTimer *m_unpacking_timer; //!< unpacking time (geometry, overlap, and 'addCell') + TrigTimer *m_RoI_timer; //!< time required to set up the output TE ('addRoI') + TrigTimer *m_merge_timer; //!< time required merge the EM cells ('mergeEmCells') + + // output + TrigT2Jet *m_jet; + + // Monitored Variables + float m_UnpckTime; //!< see corresponding timer for details + float m_cellUnpckTime; //!< see corresponding timer for details + float m_RoITime; //!< see corresponding timer for details + float m_mergeTime; //!< see corresponding timer for details +}; + +//---------------------------------------------------------- +// +// helper classes +// +//---------------------------------------------------------- + +/*! \brief A class describing a rectangle in @f$ \eta @f$, @f$ \phi @f$ + * + * An EtaPhiRectangle object can be used to keep track of a rectangle + * in these coordinates. It is meant to be a simple object that takes + * care of the @f$ 2\pi @f$ ambigiuties and that can perform simple operations + * such as compute the overlap between two rectangles. While the + * minimum and maximum @f$ \phi @f$ values can be provided in any range, + * internally all @f$ \phi angles @f$ are stored and handled within + * (@f$ -\pi @f$,@f$ +\pi @f$]. + * Maybe at some point you could use TVector2.h (but they store x,y) or gsl::polar. + */ + +//! \todo should probably define an EtaPhiPair instead of EtaPhiPoint...and use it everywhere +typedef std::pair< double, double > EtaPhiPoint; +//---------------------------------------------------------- +class EtaPhiRectangle{ + public: + //! default c'tor + EtaPhiRectangle(): + m_etaMin(0.), m_etaMax(0.), m_etaCen(0.), m_etaHw(0.), + m_phiMin(0.), m_phiMax(0.), m_phiCen(0.), m_phiHw(0.), + m_wrapsAroundPi(false) {}; + //! constructor: defined like this because these are usually the edges we get for an ROI + EtaPhiRectangle(const double &etaMin, const double &etaMax, + const double &phiMin, const double &phiMax); + double area() const { return 2.0*m_etaHw*2.0*m_phiHw; }; + double eta() const { return m_etaCen; }; + double phi() const { return m_phiCen; }; + double etaMin() const { return m_etaMin; }; + double etaMax() const { return m_etaMax; }; + double phiMin() const { return m_phiMin; }; + double phiMax() const { return m_phiMax; }; + double etaHalfWidth() const {return m_etaHw; }; + double phiHalfWidth() const {return m_phiHw; }; + //! determine whether a given point in (@f$ \eta @f$, @f$ \phi @f$) is inside this EtaPhiRectangle + bool contains(const EtaPhiPoint &point) const; + //! same as above, but less safe agaist eta-phi swap + bool contains(const double &eta, const double &phi) const { return contains(std::make_pair(eta,phi));}; + //! determine whether two rectangles overlap + static double overlappingArea(const EtaPhiRectangle &lhs, + const EtaPhiRectangle &rhs); + //! compute the rectangle corresponding to the overlapping area + static EtaPhiRectangle overlappingRectangle(const EtaPhiRectangle &lhs, + const EtaPhiRectangle &rhs); + //! convert any angle to its equivalent in ( @f$ -\pi @f$, @f$ +\pi @f$] + static double phi_mpi_pi(const double &val); + //! convert any angle to its equivalent in ( 0 , @f$ +2\pi @f$] + static double phi_zero_2pi(const double &val); + //! print the rectangle + void print(std::ostream& stream) const; + + protected: + //! compute the location of the center of the rectangle + /*! In fact this method is initializing the internal representation + of the rectangle, with center, half width, etc. + */ + void computeCenterCoord(); + private: + double m_etaMin; //!< minimum eta + double m_etaMax; //!< maximum eta + double m_etaCen; //!< central eta + double m_etaHw; //!< eta half width + double m_phiMin; //!< minimum phi + double m_phiMax; //!< maximum phi + double m_phiCen; //!< central phi + double m_phiHw; //!< phi half width + bool m_wrapsAroundPi; //!< whether the rectangle crosses over @f$ \phi = \pi @f$ + +}; // end EtaPhiRectangle + +std::ostream& operator<< (std::ostream& stream, const EtaPhiRectangle &epr); + +//---------------------------------------------------------- + +/*! \brief compute L2 roi boundaries + +Given a L1 ROI descriptor, compute the boundaries of a calorimeter +L2 ROI. We want to the ROI dimensions (halfWidths) to be +configurable, so we pass them in through the c'tor. The +calculation is done accounting for upper boundaries, and treating +for the FCAL in a special way. + +\param trd the L1 ROI descriptor +\param etaHalfWidth desired half width in eta at L2 (usually 0.5) +\param phiHalfWidth desired half width in phi at L2 (usually 0.5) +*/ +class L2CaloRoiBoundsCalculator { + public: + L2CaloRoiBoundsCalculator(const TrigRoiDescriptor* trd, + const double &etaHalfWidth, + const double &phiHalfWidth); + double etaMin() const {return m_etaMin; } ; + double etaMax() const {return m_etaMax; } ; + double phiMin() const {return m_phiMin; } ; + double phiMax() const {return m_phiMax; } ; + private: + //! actually compute and store the bounds + void computeBounds(const TrigRoiDescriptor* trd, + const double &etaHalfWidth, + const double &phiHalfWidth); + double m_etaMin, m_etaMax; //!< eta range + double m_phiMin, m_phiMax; //!< phi range + double m_roiEtaLimit; //!< a reasonable maximum in @f$ \eta @f$ (4.8, does not include FCAL) + double m_fcalEtaMin; //!< FCAL minumum @f$ \eta @f$ (3.0) + double m_fcalEtaMax; //!< FCAL maxumum @f$ \eta @f$ (5.0) + double m_minFcalEtaCenter; //!< if the \eta center is above this (3.2), then we think it's FCAL +}; // end L2CaloRoiBoundsCalculator + +//---------------------------------------------------------- + + +//---------------------------------------------------------- + + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloFastJet.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloFastJet.h new file mode 100644 index 00000000000..900db6ab578 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloFastJet.h @@ -0,0 +1,148 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloFastJet.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett, tamsett@cern.ch +// +// Description: Level 2 FastJet FEX algorithm. +// ******************************************************************** + +#ifndef TRIGT2CALOJET_T2CALOFASTJET_H +#define TRIGT2CALOJET_T2CALOFASTJET_H + +//#include "TrigInterfaces/FexAlgo.h" +#include "TrigInterfaces/AllTEAlgo.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" +#include "fastjet/JetDefinition.hh" +#include "fastjet/AreaDefinition.hh" +#include "fastjet/ClusterSequence.hh" +#include "fastjet/ClusterSequenceArea.hh" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigCaloEvent/TrigT2JetContainer.h" +#include "TrigT2CaloJet/T2L1Tools.h" + +namespace fastjet{ + class PseudoJet; + class JetDefinition; + class AreaDefinition; + class ClusterSequence; + class ClusterSequenceArea; +} + +class ITrigTimerSvc; +class TrigT2Jet; +class T2CaloJetBaseTool; +class T2L1Tools; + + + +//class T2CaloFastJet: public HLT::FexAlgo { +class T2CaloFastJet: public HLT::AllTEAlgo { + + public: + T2CaloFastJet(const std::string & name, ISvcLocator* pSvcLocator); + ~T2CaloFastJet(); + + //HLT::ErrorCode hltExecute(const HLT::TriggerElement* inputTE, + // HLT::TriggerElement* outputTE); + HLT::ErrorCode hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& input, + unsigned int output); + + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize(); + + private: + // Properties: + std::string m_jetInputKey; + std::string m_jetOutputKey; + int m_inputType; + int m_outputType; + int m_secondOutputType; // this is used to set a different RoI word for the subsequent algorithm + double m_cellMinEnergy; //!< minimum cell energy required + // Tools + ToolHandleArray< T2CaloJetBaseTool > m_tools; // for calibration + + protected: + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + ITrigTimerSvc *m_pTimerService; // pointer to Timer Service + //TrigTimer *m_total_timer; + TrigTimer *m_unpack_timer; + TrigTimer *m_fastjet_timer; + TrigTimer *m_pu_subtraction_timer; + TrigTimer *m_cleaning_timer; + TrigTimer *m_calibration_timer; + TrigTimer *m_RoI_timer; + + // fast jet + double m_distanceParameter; + double m_pTmin; + std::vector<fastjet::PseudoJet> m_particles; + fastjet::JetDefinition * m_jet_def; + std::vector<fastjet::PseudoJet> m_jets; + std::vector<fastjet::PseudoJet> m_constituents; + fastjet::ClusterSequence* m_cluster_sequence; + + // cleaning: + bool m_doCleaning; + bool m_doT2L1Cleaning; // L1.5 m_jets do not have provenance, quality or time defined so a simpler cleaning must be applied + float m_leadingCellFraction; + int m_cellQualityThresholdLAr; + std::vector<double> m_cellenergies; + + // navigation + bool m_writeMultipleOutputTEs; + /* Default behaviour is to write a single output TE with a vector of jets attached. + * This does not fit all use cases, so a switch is available which enables the writing of one output TE per jet. + */ + + // pileup subtraction switch + bool m_doPileupSubtraction; + //double m_pu_distanceParameter; + fastjet::JetDefinition * m_pu_jet_def; + fastjet::AreaDefinition * m_pu_area_def; + fastjet::ClusterSequenceArea* m_pu_cluster_sequence; + fastjet::ClusterSequenceArea* m_pu_area_cluster_sequence; + double m_rho; + double m_sigma; + double m_area; + + + // Monitored Variables + //float m_TotalTime; // The total time + float m_UnpackTime; // The time to unpack + float m_FastJetTime; // The time to run fast jet + float m_puSubTime; // The time to do pileup subtraction + float m_CleaningTime; // The time to clean the jets + float m_CalibrationTime;// The time to calibrate the jets + float m_RoITime; // The RoI making time + int m_nGrid; // The number of grid elements given + int m_nJets; // The number of jets found + std::vector<double> m_et; // transverse energy + std::vector<double> m_et_em; // electromagnetic transverse energy + std::vector<double> m_et_had; // hadronic transverse energy + std::vector<double> m_e; // energy + std::vector<double> m_e_em; // electromagnetic energy + std::vector<double> m_e_had; // hadronic energy + std::vector<double> m_em_frac; // electromagnetic fraction + std::vector<double> m_eta; // eta + std::vector<double> m_phi; // phi + std::vector<int> m_nLeadingTowers; // number of leading towers + + + // outputs + TrigT2Jet *m_jet; + + // L1.5 tools + T2L1Tools m_t2l1_tools; + +}; + +#endif + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJet.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJet.h new file mode 100755 index 00000000000..afe6b3ce1d2 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJet.h @@ -0,0 +1,97 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloJet.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Kyle Cranmer +// +// Description: Level2 Jet algorithm. Basically copied from L2 EM and +// Tau algs with some cleanup. +// ******************************************************************** + +#ifndef TRIGT2CALOJET_T2CALOJET_H +#define TRIGT2CALOJET_T2CALOJET_H + +#include <string> +#include "TrigT2CaloCommon/T2CaloBase.h" +#include "GaudiKernel/ToolHandle.h" +#include "TrigCaloEvent/TrigCaloCluster.h" + +class StoreGateSvc; +//class TriggerElement; +//class TrigRoiDescriptor; +class T2CaloJetBaseTool; +class TrigT2Jet; + +class T2CaloJet: public T2CaloBase { + + + public: + T2CaloJet(const std::string & name, ISvcLocator* pSvcLocator); + ~T2CaloJet(); + + HLT::ErrorCode hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE); + + + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize(); + + private: + + // double m_etamin, m_etamax, m_phimin, m_phimax; + // TriggerElement* m_inputTE ; + // TrigRoiDescriptor* m_roiDescriptor; + TrigT2Jet* m_jet; + TrigCaloCluster *m_layerInfo; + + //std::vector<T2CaloJetBaseTool*> m_tools; + ToolHandleArray< T2CaloJetBaseTool > m_tools; + + // Properties: + std::string m_jetOutputKey; + std::string m_clusterOutputKey; + //std::vector<std::string> m_toolNames; + bool m_clearJetGrid; + bool m_fillLayerInfo; + + // Monitored Variables + double m_dR; + double m_e; // total energy of the jet after calibration + double m_et; + double m_ehad0; // hadronic energy before calibration + double m_eem0; // electromagnetic energy before calibration + + double m_ethad0; // transverse energy : hadronic component before calibration + double m_etem0; // transverse energy : electromagnetic component before calibration + + double m_eta; + double m_phi; + + double m_etaIDWidth; + double m_phiIDWidth; + + unsigned int m_conversionError; + unsigned int m_algorithmError; + + + + protected: + + std::vector<TrigTimer*> m_timer; + const TrigTimer *m_timeLArUnpck; + const TrigTimer *m_timeTileUnpck; + const TrigTimer *m_timeHECUnpck; + + public: + + inline TrigT2Jet* GetTrigT2Jet() const {return m_jet;} +//inline TrigCaloCluster* GetTrigCaloCluster() const {return m_layerInfo;} + +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetBaseTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetBaseTool.h new file mode 100755 index 00000000000..ea63bbc43f3 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetBaseTool.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2CALOJETBASETOOL_H +#define TRIGT2CALOJET_T2CALOJETBASETOOL_H + +/******************************************************************** + +NAME: T2CaloJetBaseTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Base Tool for all T2CaloJet tools require + an T2CaloJet object as its input. The derived + tool must implement an execute(TrigT2Jet*) method. + +********************************************************************/ + +class TrigT2Jet; + + +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" + +#include "IRegionSelector/IRoiDescriptor.h" + +static const InterfaceID IID_T2CaloJetBaseTool("T2CaloJetBaseTool", 1, 0); + +class T2CaloJetBaseTool : public IAlgToolCalo +{ + public: + + T2CaloJetBaseTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2CaloJetBaseTool(); + + virtual StatusCode initialize(); + using IAlgToolCalo::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + // virtual StatusCode execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax); + + virtual StatusCode execute(TrigT2Jet* jet, const IRoiDescriptor& roi, + const CaloDetDescrElement*& /*caloDDE*/); + + virtual TrigTimer* getTimer(const std::string& /*name*/){ return 0;}; + + static const InterfaceID& interfaceID() { return IID_T2CaloJetBaseTool; } + + +}; + +#endif // TRIGT2CALOJET_T2CALOJETBASETOOL diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetCalibTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetCalibTool.h new file mode 100755 index 00000000000..0201d2382de --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetCalibTool.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2CALOJETCALIBTOOL_H +#define TRIGT2CALOJET_T2CALOJETCALIBTOOL_H + +/******************************************************************** + +NAME: T2CaloJetCalibTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Patricia Conde Muino <Patricia.Conde.Muino@cern.ch> + Nuno Anjos <Nuno.Anjos@cern.ch> +CREATED: May 2006 + +PURPOSE: Calibration tool for LVL2 jets. + It uses T2JESCalibTool / T2GSCalibTool / T2SamplingCalibTool + from TrigTools/TrigT2CaloCalibration. + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/ToolHandle.h" +#include "TrigT2CaloCalibration/IT2HadCalibTool.h" +//#include "TrigCaloEvent/TrigCaloCluster.h" + +class TrigT2Jet; + +class T2CaloJetCalibTool : public T2CaloJetBaseTool +{ + public: + + T2CaloJetCalibTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2CaloJetCalibTool(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual StatusCode execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax); + + private: + + MsgStream * m_log; + int m_outputLevel; + + ToolHandle < IT2HadCalibTool > m_t2JetCalibTool; + ToolHandle < IT2HadCalibTool > m_t2JetCorrToolTile1; + ToolHandle < IT2HadCalibTool > m_t2JetCorrToolFcal1; + ToolHandle < IT2HadCalibTool > m_t2JetCorrToolEm3Bar; + ToolHandle < IT2HadCalibTool > m_t2JetCorrToolHec0; + ToolHandle < IT2HadCalibTool > m_t2JetCorrToolEm3Fwd; + ToolHandle < IT2HadCalibTool > m_t2JetCorrToolPsBar; + + bool m_useFEBJets; +//bool m_fillLayerInfo; + bool m_doJetCalib; + bool m_doJetCorrTile1; + bool m_doJetCorrFcal1; + bool m_doJetCorrEm3Bar; + bool m_doJetCorrHec0; + bool m_doJetCorrEm3Fwd; + bool m_doJetCorrPsBar; + +//TrigCaloCluster *m_layer_info; + +// StatusCode calculateHadEMEnergy(TrigT2Jet* Jet, double *HadEnergy, double *EMEnergy); + StatusCode calculateLayerFracs(TrigT2Jet* Jet, double *fTile1, double *fFcal1, double *fEm3, double *fHec0, double *fPs); + +}; + +#endif // TRIGT2CALOJET_T2CALOJETCALIBTOOL diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetConeTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetConeTool.h new file mode 100755 index 00000000000..a5818522849 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetConeTool.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2CALOJETCONETOOL_H +#define TRIGT2CALOJET_T2CALOJETCONETOOL_H + +/******************************************************************** + +NAME: T2CaloJetConeTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Cone Tool for all T2CaloJet. Does simple cone alg after data + preparation. + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/AlgTool.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" + +class TrigT2Jet; + +class T2CaloJetConeTool : public T2CaloJetBaseTool +{ + public: + + T2CaloJetConeTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2CaloJetConeTool(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + //virtual StatusCode execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax); + virtual StatusCode execute(TrigT2Jet* jet, const IRoiDescriptor& roi); + + void coneIteration(TrigT2Jet* jet, int coneIter); + + private: + int m_nIterations; + double m_coneRadius; + //int niterations; + //double etot_jet; + //Cell check + int m_inCone, m_outCone, m_totalCell; + // cleaning: + int m_cellQualityThresholdLAr; + float m_leadingCellFraction; + + std::vector<double> m_datav; + std::vector<double> m_range1; + std::vector<double> m_range2; + std::vector<int> m_ndiv; + std::vector<std::string> m_dataObject; + std::vector<std::string> m_dataaxis; + + //New timers + ITrigTimerSvc *m_pTimerService; // pointer to Timer Service + TrigTimer *m_fcal_timer; + TrigTimer *m_other_timer; + + //FCal cone sizes + std::vector<double> m_fj_cone_sizes; + + // cleaning: + std::vector<double> m_cellenergies; + +}; + +#endif // TRIGT2CALOJET_T2CALOJETCONETOOL diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromCells.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromCells.h new file mode 100644 index 00000000000..3ff3ff22a1d --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromCells.h @@ -0,0 +1,118 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2CALOJETGRIDFROMCELLS_H +#define TRIGT2CALOJET_T2CALOJETGRIDFROMCELLS_H + +/******************************************************************** + +NAME: T2CaloJetGridFromCells.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Data preparation from cells, uses the + TrigT2CaloCommon/CommonAccessTool + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/AlgTool.h" + +//#include "LArRecEvent/LArCellCollection.h" +//#include "TileEvent/TileCellIDC.h" +//#include "LArRecEvent/LArCellIDC.h" +//#include "LArRawUtils/LArTT_Selector.h" +//#include "TrigT2CaloCommon/LArCellCont.h" +#include "TrigT2CaloCommon/TrigDataAccess.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" +#include "GaudiKernel/MsgStream.h" +#include "CaloInterface/ICalorimeterNoiseTool.h" + +class TrigT2Jet; +class Trig3Momentum; +class ITrigDataAccess; +class EtaPhiRectangle; + +class T2CaloJetGridFromCells : public T2CaloJetBaseTool +{ + public: + T2CaloJetGridFromCells(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2CaloJetGridFromCells(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + +// virtual StatusCode execute(TrigT2Jet* jet,double etamin, double etamax, +// double phimin, double phimax); + virtual StatusCode execute(TrigT2Jet * jet,const IRoiDescriptor& roi ); + + virtual TrigTimer* getTimer(const std::string& name); + + StatusCode addAllCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid); + + + StatusCode addLArCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool prepare); + + StatusCode addTileCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool prepare); + //! set the regions to be skipped + void setForbiddenRegions(const std::vector< EtaPhiRectangle > ®ions) { m_forbiddenRegions = regions; } ; + private: + bool isInVetoRegion(const double &eta, const double &phi); + private: + Trig3Momentum* m_gridElement; + + + // New way with TrigDataAccess doing BS conversion + // iterators to LArCells. Note the different type from the above + LArTT_Selector<LArCellCont>::const_iterator m_iBegin; + LArTT_Selector<LArCellCont>::const_iterator m_iEnd; + LArTT_Selector<LArCellCont>::const_iterator m_it; + + TileCellCollection::const_iterator m_itBegin; + TileCellCollection::const_iterator m_itEnd; + TileCellCollection::const_iterator m_itt; + + + + //int ncell_roi; + //int nnegcell_roi; + //double eem_roi; + //double etot_roi; + + bool m_applyNoiseCut; + double m_noiseCutValue; + // cell based jet cleaning: + bool m_doHECcellQualityCleaning; + int m_cellQualityThresholdHEC; + + ToolHandle<LArCablingLegacyService> m_cablingSvc; + ToolHandle<ICalorimeterNoiseTool> m_noiseTool; + std::vector< EtaPhiRectangle > m_forbiddenRegions; //!< regions to be skipped + + protected: + + ITrigTimerSvc* m_timerSvc; + /** Timer Items for the main algorithms. */ + std::map<std::string, TrigTimer*> m_timers; + + bool m_doTiming; +}; + +#endif // TRIGT2CALOJET_T2CALOJETGRIDFROMCELLS diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromFEBHeader.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromFEBHeader.h new file mode 100755 index 00000000000..cfc9eecd375 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromFEBHeader.h @@ -0,0 +1,87 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2CALOJETGRIDFROMFEBHEADER_H +#define TRIGT2CALOJET_T2CALOJETGRIDFROMFEBHEADER_H + +/******************************************************************** + +NAME: T2CaloJetGridFromFEBHeader.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> + Ignacio Aracena <ignacio.aracena@cern.ch> +CREATED: November, 2005 + +PURPOSE: Data preparation from FEB Headers (Ex/Ey) + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/AlgTool.h" +//#include "LArRecEvent/LArFebEnergyIDC.h" +#include "TrigT2CaloCommon/TrigDataAccess.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" +#include "GaudiKernel/MsgStream.h" + +class TrigT2Jet; +class Trig3Momentum; +class ITrigDataAccess; + +class T2CaloJetGridFromFEBHeader : public T2CaloJetBaseTool +{ + public: + + T2CaloJetGridFromFEBHeader(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2CaloJetGridFromFEBHeader(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual TrigTimer* getTimer(const std::string& name); + + virtual StatusCode execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax); + + StatusCode addFebEnergies(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid); + + StatusCode addLArFebEnergy(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool prepare); + + StatusCode addTileCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool prepare); + private: + // ITrigDataAccess *m_data; + Trig3Momentum* m_gridElement; + std::vector<int>* m_usedfeb; + std::map<std::string, TrigTimer*> m_timers; + +protected: + ITrigTimerSvc* m_timerSvc; + bool m_doTiming; + + // New way with TrigDataAccess doing BS conversion + // iterators to LArFEBEnergy. Note the different type from the above + LArFebEnergyCollection::const_iterator m_iFebBegin; + LArFebEnergyCollection::const_iterator m_iFebEnd; + LArFebEnergyCollection::const_iterator m_Febit; + + TileCellCollection::const_iterator m_itBegin; + TileCellCollection::const_iterator m_itEnd; + TileCellCollection::const_iterator m_itt; + +}; + +#endif // TRIGT2CALOJET_T2CALOJETGRIDFROMFEBHEADER diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h new file mode 100755 index 00000000000..8e05ce47911 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2CALOJETGRIDFROMLVL1PPR_H +#define TRIGT2CALOJET_T2CALOJETGRIDFROMLVL1PPR_H + +/******************************************************************** + +NAME: T2CaloJetGridFromLvl1Ppr.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Data preparation tool from Lvl1 Trigger Towers (accessed via Lvl1 PPr Bytestream) + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/AlgTool.h" + +class TrigT2Jet; +class Trig3Momentum; + +class T2CaloJetGridFromLvl1Ppr : public T2CaloJetBaseTool +{ + public: + + T2CaloJetGridFromLvl1Ppr(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2CaloJetGridFromLvl1Ppr(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual StatusCode execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax); + private: + Trig3Momentum* m_gridElement; + +}; + +#endif // TRIGT2CALOJET_T2CALOJETGRIDFROMLVL1PPR diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloFullScanJet.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloFullScanJet.h new file mode 100644 index 00000000000..2c781d5f906 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloFullScanJet.h @@ -0,0 +1,95 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2L1CaloFullScanJet.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett +// +// Description: Level2 Jet Full scan algorithm. Based on L2 MET +// ******************************************************************** + +#ifndef TRIGT2CALOJET_T2L1CaloFullScanJet_H +#define TRIGT2CALOJET_T2L1CaloFullScanJet_H + +#include "TrigInterfaces/AllTEAlgo.h" +#include <vector> + +#include <string> +#include "GaudiKernel/ToolHandle.h" +#include "TrigT2CaloCommon/T2CaloBase.h" +#include "TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h" + +class StoreGateSvc; +class TrigT2Jet; +class ITrigTimerSvc; + +namespace LVL1BS{ + class ITrigT1CaloDataAccess; +} + +namespace LVL1{ + class IL1JetTools; +} + +class T2L1CaloFullScanJet: public HLT::AllTEAlgo { + + + public: + T2L1CaloFullScanJet(const std::string & name, ISvcLocator* pSvcLocator); + ~T2L1CaloFullScanJet(); + + HLT::ErrorCode hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& input, + unsigned int output); + + + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize(); + + private: + + const TrigT2Jet* m_jet; + DataVector<TrigT2Jet>* m_jets; + ToolHandleArray< T2L1CaloJetFullScanBaseTool > m_tools; + + // Properties: + std::string m_jetOutputKey; + bool m_recordOutput; + + // Monitored Variables + int m_nJets; // The number of jets found + int m_nTowers; // The number of trigger towers + float m_UnpckTime; // The unpacking time, includes L1 unpack + tower storage time + float m_L1_UnpckTime; // The L1 unpacking time + float m_FastJetTime; // The FastJet time + float m_JetFindingTime; // The complete jet finding time + float m_TotalTime; // The total time + float m_RoITime; // The RoI making time + std::vector<double> m_e; // energy + std::vector<double> m_et; // transverse energy + std::vector<double> m_ehad; // hadronic energy + std::vector<double> m_eem; // electromagnetic energy + std::vector<double> m_ethad; // hadronic transverse energy + std::vector<double> m_etem; // electromagnetic transverse energy + std::vector<double> m_emfrac; // electromagnetic fraction + std::vector<double> m_eta; // eta + std::vector<double> m_phi; // phi + std::vector<int> m_nLeadingTowers; // number of leading towers + + + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + + + protected: + + std::vector<TrigTimer*> m_timer; + + +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJet.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJet.h new file mode 100755 index 00000000000..50d1b428819 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJet.h @@ -0,0 +1,82 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloJet.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Kyle Cranmer +// +// Description: Level2 Jet algorithm. Basically copied from L2 EM and +// Tau algs with some cleanup. +// ******************************************************************** + +#ifndef TRIGT2CALOJET_T2L1CALOJET_H +#define TRIGT2CALOJET_T2L1CALOJET_H + +#include <string> +#include "TrigInterfaces/FexAlgo.h" +#include "AthContainers/ConstDataVector.h" +#include "GaudiKernel/ToolHandle.h" + +class StoreGateSvc; +class TrigT2Jet; + +namespace LVL1BS{ + class ITrigT1CaloDataAccess; +} +namespace LVL1{ + class IL1JetTools; + class JetElement; +} + +class T2L1CaloJet: public HLT::FexAlgo { + + + public: + T2L1CaloJet(const std::string & name, ISvcLocator* pSvcLocator); + ~T2L1CaloJet(); + + HLT::ErrorCode hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE); + + + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize(); + + private: + + TrigT2Jet* m_jet; + + + // Properties: + std::string m_jetOutputKey; + + // Monitored Variables + double m_e; // total energy of the jet after calibration + double m_et; + //double m_ehad0; // hadronic energy before calibration + //double m_eem0; // electromagnetic energy before calibration + double m_eta; + double m_phi; + + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + + + + protected: + + std::vector<TrigTimer*> m_timer; + ToolHandle< LVL1BS::ITrigT1CaloDataAccess > m_dataL1; + ToolHandle< LVL1::IL1JetTools > m_jetL1Tools; + ConstDataVector<DataVector<LVL1::JetElement> >* m_storedJEs; + bool m_retrievedJetTool; + + +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetCalibTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetCalibTool.h new file mode 100644 index 00000000000..8959104891f --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetCalibTool.h @@ -0,0 +1,68 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2L1CALOJETTOOL_H +#define TRIGT2CALOJET_T2L1CALOJETTOOL_H + +/******************************************************************** + +NAME: T2L1CaloJetCalibTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett <tamsett@cern.ch>, Carlos Sandoval <csandova@mail.cern.ch> +CREATED: December 2010 + + +PURPOSE: Calibration tool for L1 towers. + + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/AlgTool.h" +#include "CaloRec/ToolWithConstantsMixin.h" + +class TrigT2Jet; +class Trig3Momentum; + +class T2L1CaloJetCalibTool : public T2CaloJetBaseTool, + public CaloRec::ToolWithConstantsMixin +{ + public: + + T2L1CaloJetCalibTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2L1CaloJetCalibTool(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual StatusCode execute(TrigT2Jet* jet,double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/); + + using AlgTool::setProperty; + virtual StatusCode setProperty (const std::string& propname, + const std::string& value); + virtual StatusCode setProperty (const Property& p); + + protected: + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + int GetEtaBin(double jet_eta); + double GetCalibFactor(int etabin, double energy); + + CaloRec::Array<2> m_CalibConstants; + + // Bins + std::vector<double> m_eta_bin_lower_edges; + + +}; + +#endif // TRIGT2CALOJET_T2L1CALOJETTOOL diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h new file mode 100644 index 00000000000..36e9437485b --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h @@ -0,0 +1,54 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2L1CALOJETFULLSCANBASETOOL_H +#define TRIGT2CALOJET_T2L1CALOJETFULLSCANBASETOOL_H + +/******************************************************************** + +NAME: T2L1CaloJetFullScanBaseTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett +CREATED: July, 2011 + +PURPOSE: Base Tool for all T2L1CaloJet tools that require + a vector of T2CaloJet objects as its input. The derived + tool must implement an execute(vector<T2CaloJet*>) method. + + +********************************************************************/ + +class TrigT2Jet; + + +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" + +static const InterfaceID IID_T2L1CaloJetFullScanBaseTool("T2L1CaloJetFullScanBaseTool", 1, 0); + +class T2L1CaloJetFullScanBaseTool : public IAlgToolCalo +{ + public: + + T2L1CaloJetFullScanBaseTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2L1CaloJetFullScanBaseTool(); + + virtual StatusCode initialize(); + using IAlgToolCalo::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual StatusCode execute(DataVector<TrigT2Jet>*, int&, float&, float&, float&, float&); + + virtual TrigTimer* getTimer(const std::string& /*name*/){ return 0;}; + + static const InterfaceID& interfaceID() { return IID_T2L1CaloJetFullScanBaseTool; } + + +}; + +#endif // TRIGT2CALOJET_T2L1CaloJetFullScanBaseTool diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanFastJetTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanFastJetTool.h new file mode 100644 index 00000000000..beb50ef75d7 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1CaloJetFullScanFastJetTool.h @@ -0,0 +1,128 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2L1CALOJETFULLSCANFASTJETTOOL_H +#define TRIGT2CALOJET_T2L1CALOJETFULLSCANFASTJETTOOL_H + +/******************************************************************** + +NAME: T2L1CaloJetFullScanFastJetTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett +CREATED: July, 2011 + +PURPOSE: FastJet Tool for all T2L1CaloJet tools that require + a vector of T2CaloJet objects as its input. The derived + tool must implement an execute(vector<T2CaloJet*>) method. + + +********************************************************************/ + +class TrigT2Jet; +class ITrigTimerSvc; + +namespace LVL1BS{ + class ITrigT1CaloDataAccess; +} + +namespace LVL1{ + class IL1JetTools; + class JetElement; + class TriggerTower; +} + +namespace fastjet{ + class PseudoJet; + class JetDefinition; + class ClusterSequence; +} + +// Extra tools for the RoI IDs +namespace T2L1{ + enum roi_types_enums { + NONE = 0x01, + L1SW8x8 = 0x02, + A4TT = 0x04, + A10TT = 0x08, + A4JE = 0x10, + A10JE = 0x20, + UNKNOWN = 0x40, + INPUT = 0x10000, + OUTPUT = 0x100, + BLANKWORD = 0x70000000 + }; +} + +#include "TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h" +#include "GaudiKernel/AlgTool.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" + +#include "fastjet/JetDefinition.hh" + +#include <vector> + +class T2L1CaloJetFullScanFastJetTool : public T2L1CaloJetFullScanBaseTool +{ + public: + + T2L1CaloJetFullScanFastJetTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2L1CaloJetFullScanFastJetTool(); + + virtual StatusCode initialize(); + using T2L1CaloJetFullScanBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual StatusCode execute(DataVector<TrigT2Jet>*, int&, float&, float&, float&, float&); + + protected: + ToolHandle< LVL1BS::ITrigT1CaloDataAccess > m_dataL1; + + double m_coneRadius; + double m_pTmin; + bool m_retrievedJetTool; + int m_inputType; + + TrigT2Jet* m_jet; + std::vector<float> m_l1_tower_information; + + double m_etaMin; + double m_etaMax; + double m_phiMin; + double m_phiMax; + bool m_fullScan; + + + ITrigTimerSvc *m_pTimerService; // pointer to Timer Service + TrigTimer *m_total_timer; + TrigTimer *m_unpacking_timer; + TrigTimer *m_load_collection_timer; + TrigTimer *m_jet_finding_timer; + TrigTimer *m_fastjet_timer; + + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + bool m_doTriggerTowers; // bool to switch to trigger towers mode, default mode is Jet Elements + // fast jet + std::vector<fastjet::PseudoJet> m_particles; + fastjet::JetDefinition * m_jet_def; + //fastjet::ClusterSequence cs; + std::vector<fastjet::PseudoJet> m_jets; + std::vector<fastjet::PseudoJet> m_constituents; + + // cleaning: + float m_leadingCellFraction; + std::vector<double> m_cellenergies; + + // debug + bool m_doCleaning; + bool m_doJetFinding; + +}; + +#endif // TRIGT2CALOJET_T2L1CaloJetFullScanFastJetTool diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Tools.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Tools.h new file mode 100644 index 00000000000..502e621bdef --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Tools.h @@ -0,0 +1,136 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2L1Tools.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett, tamsett@cern.ch +// +// Description: Common tools and definitions for the L1.5 jet trigger +// ******************************************************************** +#ifndef TRIGT2CALOJET_T2L1TOOLS_H +# define TRIGT2CALOJET_T2L1TOOLS_H 1 +#ifndef GAUDIKERNEL_CLASSID_H +# include "GaudiKernel/ClassID.h" +#endif + +#include <string> +#include <map> + + +class T2L1Tools{ + public: + + enum roi_types_enums { + NONE = 0x01, + L1SW8x8 = 0x02, + L2CONE = 0x03, + A4TT = 0x04, + A4TT_JES = 0x05, + A4TT_TC = 0x06, + A4TT_TC_JES = 0x07, + A4TT_PU_SUB = 0x08, + A10TT = 0x09, + A4JE = 0x10, + A4JE_JES = 0x11, + A4JE_TC = 0x12, + A4JE_TC_JES = 0x13, + A4JE_PU_SUB = 0x14, + A4CC = 0x15, + A4CC_JES = 0x16, + A10JE = 0x20, + UNCALIBRATED = 0x30, + CALIBRATED = 0x31, + UNKNOWN = 0x40, + SET_INPUT = 0x10000, + GET_INPUT = 0x10000*255, + SET_OUTPUT = 0x100, + GET_OUTPUT = 0x100*255, + BLANKWORD = 0x70000000 + }; + + int MapStringToEnum(std::string name_string){ + + std::map <std::string, int> L15NameMap; + L15NameMap["NONE"] = NONE; + L15NameMap["L1SW8x8"] = L1SW8x8; + L15NameMap["L2CONE"] = L2CONE; + L15NameMap["A4TT"] = A4TT; + L15NameMap["A4TT_JES"] = A4TT_JES; + L15NameMap["A4TT_TC"] = A4TT_TC; + L15NameMap["A4TT_TC_JES"] = A4TT_TC_JES; + L15NameMap["A4TT_PU_SUB"] = A4TT_PU_SUB; + L15NameMap["A10TT"] = A10TT; + L15NameMap["A4JE"] = A4JE; + L15NameMap["A4JE_JES"] = A4JE_JES; + L15NameMap["A4JE_TC"] = A4JE_TC; + L15NameMap["A4JE_TC_JES"] = A4JE_TC_JES; + L15NameMap["A4JE_PU_SUB"] = A4JE_PU_SUB; + L15NameMap["A10JE"] = A10JE; + L15NameMap["A4CC"] = A4CC; + L15NameMap["A4CC_JES"] = A4CC_JES; + L15NameMap["CALIBRATED"] = CALIBRATED; + L15NameMap["UNCALIBRATED"] = UNCALIBRATED; + + std::map <std::string, int>::const_iterator mask_map_iterator = L15NameMap.find(name_string); + if (mask_map_iterator == L15NameMap.end()){ + return UNKNOWN; + } else { + return mask_map_iterator->second; + } + } + + std::string MapEnumToString(int enum_int){ + + std::map <int, std::string> L15NameMap; + L15NameMap[NONE] = "NONE"; + L15NameMap[L1SW8x8] = "L1SW8x8"; + L15NameMap[L2CONE] = "L2CONE"; + L15NameMap[A4TT] = "A4TT"; + L15NameMap[A4TT_JES] = "A4TT_JES"; + L15NameMap[A4TT_TC] = "A4TT_TC"; + L15NameMap[A4TT_TC_JES] = "A4TT_TC_JES"; + L15NameMap[A4TT_PU_SUB] = "A4TT_PU_SUB"; + L15NameMap[A10TT] = "A10TT"; + L15NameMap[A4JE] = "A4JE"; + L15NameMap[A4JE_JES] = "A4JE_JES"; + L15NameMap[A4JE_TC] = "A4JE_TC"; + L15NameMap[A4JE_TC_JES] = "A4JE_TC_JES"; + L15NameMap[A4JE_PU_SUB] = "A4JE_PU_SUB"; + L15NameMap[A10JE] = "A10JE"; + L15NameMap[A4CC] = "A4CC"; + L15NameMap[A4CC_JES] = "A4CC_JES"; + L15NameMap[CALIBRATED] = "CALIBRATED"; + L15NameMap[UNCALIBRATED] = "UNCALIBRATED"; + + std::map <int, std::string>::const_iterator mask_map_iterator = L15NameMap.find(enum_int); + if (mask_map_iterator == L15NameMap.end()){ + return "UNKNOWN"; + } else { + return mask_map_iterator->second; + } + } + + void RoIWordToStrings(int RoIWord, std::string & input_type_string, std::string & output_type_string, int & counter){ + if ( (RoIWord & BLANKWORD) == BLANKWORD) { // L1.5 jets + unsigned int output_enum = (RoIWord >> 8) & 255 ; + unsigned int input_enum = (RoIWord >> 16) & 255 ; + input_type_string = MapEnumToString(input_enum); + output_type_string = MapEnumToString(output_enum); + counter = RoIWord & 255; + } else { // others, probably L2 jets + input_type_string = "NON_L15"; + output_type_string = "L2CONE"; + counter = 0; + } + + } + + +}; // end of class + + +#endif // TRIGT2CALOJET_T2L1TOOLS_H diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1ToolsDict.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1ToolsDict.h new file mode 100644 index 00000000000..45c7641f696 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1ToolsDict.h @@ -0,0 +1,10 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2L1TOOLSDICT_H +#define TRIGT2CALOJET_T2L1TOOLSDICT_H 1 + +#include "TrigT2CaloJet/T2L1Tools.h" + +#endif // TRIGT2CALOJET_T2L1TOOLSDICT_H diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1TowerCalibTool.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1TowerCalibTool.h new file mode 100644 index 00000000000..695b0198783 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1TowerCalibTool.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_T2L1TOWERCALIBTOOL_H +#define TRIGT2CALOJET_T2L1TOWERCALIBTOOL_H + +/******************************************************************** + +NAME: T2L1TowerCalibTool.h +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett <tamsett@cern.ch>, Carlos Sandoval <csandova@mail.cern.ch> +CREATED: December 2010 + + +PURPOSE: Calibration tool for L1 towers. + + +********************************************************************/ + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "GaudiKernel/ToolHandle.h" +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/AlgTool.h" +#include "CaloRec/ToolWithConstantsMixin.h" + +class TrigT2Jet; +class Trig3Momentum; + +class T2L1TowerCalibTool : public T2CaloJetBaseTool, + public CaloRec::ToolWithConstantsMixin +{ + public: + + T2L1TowerCalibTool(const std::string& type, const std::string& name, + const IInterface* parent); + + ~T2L1TowerCalibTool(); + + virtual StatusCode initialize(); + using T2CaloJetBaseTool::execute; + virtual StatusCode execute(); + virtual StatusCode finalize(); + + virtual StatusCode execute(TrigT2Jet* jet,double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/); + + using AlgTool::setProperty; + virtual StatusCode setProperty (const std::string& propname, + const std::string& value); + virtual StatusCode setProperty (const Property& p); + + protected: + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + Trig3Momentum *m_grid_element; + + int GetEtaBin(double jet_eta); + int GetPhiBin(double jet_phi); + int GetEtBin(double jet_et); + double GetEtaCalibFactor(int etabin, int phibin, int etbin); + + CaloRec::Array<2> m_CalibConstants; + + +}; + +#endif // TRIGT2CALOJET_T2L1TOWERCALIBTOOL diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Unpacking.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Unpacking.h new file mode 100644 index 00000000000..404196dc569 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/T2L1Unpacking.h @@ -0,0 +1,116 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2L1Unpacking.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett +// +// Description: Unpack the L1Calo towers for use with L1.5 +// ******************************************************************** + +#ifndef TRIGT2CALOJET_T2L1UNPACKING_H +#define TRIGT2CALOJET_T2L1UNPACKING_H + +#include "TrigInterfaces/AllTEAlgo.h" +#include "TrigTimeAlgs/TrigTimerSvc.h" +#include "GaudiKernel/ToolHandle.h" +#include "TrigT2CaloCommon/TrigDataAccess.h" + + +class ITrigTimerSvc; +class TrigT2Jet; +class Trig3Momentum; +class T2CaloJetBaseTool; + +namespace LVL1BS{ + class ITrigT1CaloDataAccess; +} + +namespace LVL1{ + class IL1JetTools; + class JetElement; + class TriggerTower; +} + + +class T2L1Unpacking: public HLT::AllTEAlgo { + + + public: + T2L1Unpacking(const std::string & name, ISvcLocator* pSvcLocator); + ~T2L1Unpacking(); + + HLT::ErrorCode hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& input, + unsigned int output); + + + HLT::ErrorCode hltInitialize(); + HLT::ErrorCode hltFinalize(); + + CaloSampling::CaloSample determineCaloSampling(double fabs_eta, bool isEM); + double determineTriggerTowerEta(double eta, bool isEM); + + private: + // Properties: + std::string m_jetOutputKey; + //int m_outputType; // record the type of output towers, e.g. calibrated, uncalibrated + //std::string m_outputString; // mapped to enum in initalize, this should be changed so that its directly configured in the config + bool m_doTriggerTowers; // bool to switch to trigger towers mode, default mode is Jet Elements + // Tools + ToolHandleArray< T2CaloJetBaseTool > m_tools; // for calibration + + protected: + /** For Logging, in all tools we should use (*m_log) to avoid recalling of the MsgStream all the time. */ + MsgStream* m_log; + + ITrigTimerSvc *m_pTimerService; // pointer to Timer Service + //TrigTimer *m_total_timer; + TrigTimer *m_l1_unpacking_timer; + TrigTimer *m_unpacking_timer; + TrigTimer *m_calibration_timer; + TrigTimer *m_RoI_timer; + + ToolHandle< LVL1BS::ITrigT1CaloDataAccess > m_dataL1; + bool m_retrievedJetTool; + + /// no longer needed - the the RoiDescriptor directly !! + double m_etaMin; + double m_etaMax; + double m_phiMin; + double m_phiMax; + bool m_fullScan; + + // output + TrigT2Jet *m_jet; + Trig3Momentum *m_grid_element; + + // Monitored Variables + float m_UnpckTime; // The total unpacking time + float m_L1UnpckTime; // The L1 unpacking time + float m_CalibrationTime;// The time to calibrate the jets + //float m_TotalTime; // The total time + float m_RoITime; // The RoI making time + int m_nTowers; // The number of towers found + int m_nEMTowers; // The number of EM towers found + int m_nHADTowers; // The number of HAD towers found + std::vector<double> m_et; // transverse energy + std::vector<double> m_et_had; // hadronic transverse energy + std::vector<double> m_et_em; // electromagnetic transverse energy + std::vector<double> m_eta; // eta + std::vector<double> m_eta_em; // eta of EM towers + std::vector<double> m_eta_had; // eta of HAD towers + std::vector<double> m_phi; // phi + std::vector<double> m_phi_em; // phi of EM towers + std::vector<double> m_phi_had; // phi of HAD towers + + + + + +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/Trig3MomentumMerger.h b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/Trig3MomentumMerger.h new file mode 100644 index 00000000000..7f60a0c817a --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/Trig3MomentumMerger.h @@ -0,0 +1,33 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOJET_TRIG3MOMENTUMMERGER_H +#define TRIGT2CALOJET_TRIG3MOMENTUMMERGER_H + +#include "TrigT2CaloJet/GridsHandler.h" +#include "TrigT2CaloJet/EtaPhiSampleHash.h" +#include "TrigT2CaloJet/HashedTrig3Momentum.h" + +/*! + @brief Merge Trig3Momentum to a finite granularity + + Merge some input Trig3Momentum collection into an output + Trig3Momentum collection with a predefined granularity. + + April 2012 + davide.gerbaudo@gmail.com +*/ + +class Trig3MomentumMerger { + public: + Trig3MomentumMerger(); + bool mergeCells(const Vt3m &input, Vt3m &output); + private: + unsigned int expectedLength(const Vt3m &input); + private: + EtaPhiSampleHash m_hashMap; + GridsHandler m_gridsHandler; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/selection.xml b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/selection.xml new file mode 100644 index 00000000000..b87b09fad7a --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/TrigT2CaloJet/selection.xml @@ -0,0 +1,3 @@ +<lcgdict> + <class name="T2L1Tools" /> +</lcgdict> diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/python/CalibrationFactorsL15.py b/Trigger/TrigAlgorithms/TrigT2CaloJet/python/CalibrationFactorsL15.py new file mode 100644 index 00000000000..1c2ad9602e2 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/python/CalibrationFactorsL15.py @@ -0,0 +1,126 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +binEdgeDict = {} +binEdgeDict[ 'L2FS_em_residual_factors_eta' ] = [-4.9, -4.0, -3.2, -2.5, -1.6, -0.8, 0.0, 0.8, 1.6, 2.5, 3.2, 4.0, 4.9] + + +energyCorrDict= {} +## L2FS EM scale residual corrections +# Matthew Tamsett <tamsett@cern.ch> +# Rajivalochan Subramaniam <rajiv.lochan@cern.ch> +# [i]: eta: -4.9, -4.0, -3.2, -2.5, -1.6, -0.8, 0.0, 0.8, 1.6, 2.5, 3.2, 4.0, 4.9 +## Jet energy calibration +## [0]+[1]*(log10(x)^-1)+[2]*(log10(x)^-1)^2+... +energyCorrDict[ 'L2FS_em_residual_factors' ] = [ + [1.50000e-01, 1.50000e-01, -7.56261e-01, 1.32880e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 0 -4.9< eta <-4.0 + [-2.50000e-02, -2.50000e-02, -2.50000e-02, -2.50000e-02, -2.34682e-01 , 0.0000e+00, 0.0000e+00], ## bin 1 -4.0< eta <-3.2 + [-4.47860e-02, 1.91685e-01, -4.59624e-01, 0.0000e+00, 0.0000e+00 , 0.0000e+00, 0.0000e+00], ## bin 2 -3.2<eta -2.5 + [6.03751e-02, -9.63390e-02, -3.05565e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 3 -2.5<eta<-1.6 + [-8.89929e-03, 2.22643e-02, -3.83097e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 4 -1.6<eta<-0.8 + [5.73233e-02, -5.45971e-02, -3.30586e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 5 -0.8<eta< 0 + [5.73233e-02, -5.45971e-02, -3.30586e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 6 0.0<eta< 0.8 + [-8.89929e-03, 2.22643e-02, -3.83097e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 7 0.8<eta< 1.6 + [6.03751e-02, -9.63390e-02, -3.05565e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 8 1.6<eta<2.5 + [-4.47860e-02, 1.91685e-01, -4.59624e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 9 2.5<eta<3.2 + [-2.50000e-02, -2.50000e-02, -2.50000e-02, -2.50000e-02, -2.34682e-01 , 0.0000e+00, 0.0000e+00], ## bin 10 3.2< eta <4 + [1.50000e-01, 1.50000e-01, -7.56261e-01, 1.32880e-01, 0.0000e+00, 0.0000e+00, 0.0000e+00], ## bin 11 4.0< eta<4.9 +] + + +## Jet element calibration +energyCorrDict[ 'JE_factors' ] = [ +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 0.732649, 0.657187, 0.582351, 0.568978, 0.787708, 0.797072, 0.788461, 0.758857, 0.709569, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[0.963072, 0.917165, 0.858138, 0.788752, 0.790744, 0.934746, 0.899513, 0.890402, 0.871661, 0.793681, 0.807622, 0.94587, 0.922921, 0.903774, 0.894499, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1.01831, 0.995006, 0.930382, 0.869178, 0.874385, 0.990226, 0.938528, 0.933349, 0.92158, 0.827567, 0.838162, 0.966597, 0.949608, 0.952079, 0.942151, 0.923921, 1, 1, 1, 1, 1], +[1.04632, 1.0065, 0.998164, 0.943681, 0.991454, 1.01259, 0.989524, 0.975407, 0.954918, 0.853876, 0.870036, 0.97283, 0.96642, 0.968738, 0.963785, 0.954188, 0.909048, 1, 1, 0.758403, 1], +[1.03808, 1.02677, 1.02914, 0.9612, 1.01392, 1.02696, 0.997101, 0.9781, 0.950607, 0.861182, 0.875115, 0.975573, 0.966072, 0.964686, 0.950734, 0.94877, 0.930003, 0.968884, 1, 0.673215, 1], +[1.05728, 1.04072, 1.03521, 0.971556, 1.00436, 1.02207, 0.997667, 0.976948, 0.960568, 0.862825, 0.877273, 0.971429, 0.966273, 0.967753, 0.965021, 0.963443, 0.957007, 0.907368, 1, 0.777622, 1], +[1.0335, 1.04651, 1.01774, 1.01502, 1.01123, 1.00854, 0.992301, 0.974068, 0.957547, 0.863424, 0.876279, 0.967542, 0.96582, 0.968138, 0.965577, 0.963099, 0.955318, 0.953505, 0.969231, 0.811548, 1], +[1.05667, 1.07414, 1.12747, 1.17586, 1.0306, 1.05539, 1.04156, 1.0482, 1.01271, 1.00957, 0.986511, 1.00956, 1.00419, 0.997957, 0.990016, 0.980192, 0.972004, 0.964872, 0.969231, 0.841827, 1], +[1.06822, 1.13373, 1.22308, 1.16611, 1.01388, 1.06828, 1.06539, 1.08269, 1.08061, 1.08864, 0.975235, 1.02304, 1.02052, 1.0031, 0.990162, 0.986197, 0.980423, 0.968884, 0.876923, 0.853859, 1], +[1.088, 1.08228, 1.15033, 1.16992, 1.02095, 1.05037, 1.04923, 1.05511, 1.03741, 1.04549, 0.998608, 1.04065, 1.04638, 1.04287, 1.03978, 1.03551, 1.03327, 1.01964, 0.969231, 0.928778, 1], +[1.06134, 1.07087, 1.13335, 1.1473, 1.01166, 1.05035, 1.03923, 1.05272, 1.03184, 1.02643, 0.985362, 1.03035, 1.03848, 1.03402, 1.03025, 1.02781, 1.02005, 1.01456, 1.04615, 0.947696, 1], +[1.02439, 1.02975, 1.03728, 1.09439, 0.974983, 1.00738, 1.00662, 1.016, 0.999814, 0.975261, 0.958696, 0.999569, 1.00895, 1.00741, 1.00495, 1.00166, 0.999155, 0.993898, 0.992308, 0.97022, 1], +[1.00698, 1.00495, 0.991761, 1.01249, 0.981476, 0.999528, 0.99939, 1.00238, 0.99601, 0.96414, 0.987203, 0.998647, 1.00389, 1.00354, 1.00338, 1.00247, 1.00239, 1.00077, 1.00879, 0.979493, 1], +[1.01036, 1.00545, 1.0073, 1.01002, 0.986233, 1.00075, 1.00497, 0.997815, 0.999706, 0.982039, 1.00018, 1.00176, 1.00353, 1.0034, 1.00322, 1.00395, 1.00239, 1.00677, 0.995604, 1.00742, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1.00326, 1.00893, 0.981908, 1.00688, 0.983689, 1.00378, 0.998563, 0.995499, 1.00682, 0.997098, 0.992604, 0.994677, 0.998323, 0.997436, 0.997583, 0.997269, 0.995517, 0.990071, 0.984615, 0.997593, 1], +[1.00419, 0.99139, 0.988142, 0.989949, 0.987665, 0.993987, 0.995894, 0.989736, 0.987683, 0.984006, 0.99745, 0.991238, 0.99326, 0.992002, 0.9916, 0.992211, 0.988493, 0.989086, 0.982657, 0.995758, 1], +[1.00033, 0.999973, 0.986212, 0.992648, 0.990341, 0.996469, 0.990997, 0.98742, 0.982071, 0.966529, 0.996929, 0.988278, 0.99071, 0.990932, 0.990534, 0.990377, 0.991391, 0.986356, 0.986982, 0.995863, 1], +[0.997823, 0.997993, 0.996516, 0.980383, 0.973388, 0.988612, 0.992555, 0.990589, 0.98603, 0.955803, 0.982497, 0.985134, 0.989585, 0.989439, 0.98986, 0.987933, 0.988564, 0.983245, 0.988811, 0.975359, 1], +[1.00145, 1.00299, 1.01761, 1.03578, 0.971403, 0.991637, 1.001, 0.996646, 0.978679, 0.98986, 0.961125, 0.985624, 0.993008, 0.991249, 0.98943, 0.986799, 0.987093, 0.976908, 1, 0.95216, 1], +[1.02765, 1.05224, 1.08272, 1.12208, 0.995723, 1.0241, 1.02565, 1.0367, 1.01459, 1.03169, 0.985472, 1.02033, 1.02764, 1.02175, 1.01865, 1.01438, 1.00701, 1.01059, 0.976923, 0.938199, 1], +[1.0787, 1.08527, 1.10586, 1.15524, 1.02656, 1.03945, 1.04886, 1.04752, 1.03223, 1.00483, 1.00023, 1.03519, 1.03736, 1.03311, 1.02905, 1.02496, 1.01955, 1.00925, 1.03077, 0.928851, 1], +[1.05407, 1.07286, 1.14085, 1.13365, 1.00321, 1.04376, 1.04587, 1.05198, 1.04193, 1.05515, 0.976433, 1.01714, 1.01288, 0.994341, 0.979535, 0.976823, 0.978074, 0.949956, 0.923077, 0.837593, 1], +[1.06226, 1.12014, 1.17891, 1.18049, 1.03381, 1.07113, 1.05943, 1.05496, 1.04184, 1.04432, 1.00074, 1.01669, 1.00968, 1.00158, 0.991343, 0.981698, 0.971028, 0.963456, 1, 0.853603, 1], +[1.0421, 1.04362, 1.03215, 1.00733, 1.00688, 1.01012, 0.995392, 0.975134, 0.961122, 0.859542, 0.894761, 0.968768, 0.968193, 0.971021, 0.968925, 0.966411, 0.963923, 0.962293, 1, 0.810748, 1], +[1.05884, 1.04375, 1.03846, 1.01044, 1.01915, 1.01851, 1.0016, 0.986813, 0.966459, 0.867083, 0.886514, 0.973076, 0.970679, 0.972459, 0.970648, 0.96881, 0.972509, 0.968884, 1, 0.774462, 1], +[1.05683, 1.0476, 1.0008, 0.97346, 1.02024, 1.02595, 0.994583, 0.98965, 0.959866, 0.867563, 0.885586, 0.975321, 0.969133, 0.970606, 0.968159, 0.961191, 0.957472, 1, 1, 0.728722, 1], +[1.0544, 1.021, 1.02373, 0.981706, 1.00512, 1.01978, 0.989929, 0.974602, 0.95836, 0.854214, 0.865464, 0.972314, 0.965047, 0.967045, 0.961512, 0.947749, 0.83201, 1, 1, 0.656396, 1], +[1.0136, 0.986109, 0.94201, 0.874168, 0.89865, 0.987246, 0.936149, 0.93741, 0.92277, 0.831139, 0.848595, 0.973952, 0.952389, 0.952801, 0.940302, 0.93932, 1, 1, 1, 0.709617, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[0.957084, 0.91684, 0.85538, 0.78333, 0.773765, 0.931254, 0.895317, 0.88877, 0.877844, 0.796638, 0.797414, 0.944883, 0.920993, 0.903721, 0.774315, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 0.832556, 0.698693, 0.639456, 0.692557, 0.777771, 0.792767, 0.849111, 0.708267, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] +] + +## Trigger Towers +energyCorrDict[ 'TT_factors' ] = [ +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 0.732649, 0.657187, 0.582351, 0.568978, 0.787708, 0.797072, 0.788461, 0.758857, 0.709569, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[0.963072, 0.917165, 0.858138, 0.788752, 0.790744, 0.934746, 0.899513, 0.890402, 0.871661, 0.793681, 0.807622, 0.94587, 0.922921, 0.903774, 0.894499, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1.01831, 0.995006, 0.930382, 0.869178, 0.874385, 0.990226, 0.938528, 0.933349, 0.92158, 0.827567, 0.838162, 0.966597, 0.949608, 0.952079, 0.942151, 0.923921, 1, 1, 1, 1, 1], +[1.04632, 1.0065, 0.998164, 0.943681, 0.991454, 1.01259, 0.989524, 0.975407, 0.954918, 0.853876, 0.870036, 0.97283, 0.96642, 0.968738, 0.963785, 0.954188, 0.909048, 1, 1, 0.758403, 1], +[1.03808, 1.02677, 1.02914, 0.9612, 1.01392, 1.02696, 0.997101, 0.9781, 0.950607, 0.861182, 0.875115, 0.975573, 0.966072, 0.964686, 0.950734, 0.94877, 0.930003, 0.968884, 1, 0.673215, 1], +[1.05728, 1.04072, 1.03521, 0.971556, 1.00436, 1.02207, 0.997667, 0.976948, 0.960568, 0.862825, 0.877273, 0.971429, 0.966273, 0.967753, 0.965021, 0.963443, 0.957007, 0.907368, 1, 0.777622, 1], +[1.0335, 1.04651, 1.01774, 1.01502, 1.01123, 1.00854, 0.992301, 0.974068, 0.957547, 0.863424, 0.876279, 0.967542, 0.96582, 0.968138, 0.965577, 0.963099, 0.955318, 0.953505, 0.969231, 0.811548, 1], +[1.05667, 1.07414, 1.12747, 1.17586, 1.0306, 1.05539, 1.04156, 1.0482, 1.01271, 1.00957, 0.986511, 1.00956, 1.00419, 0.997957, 0.990016, 0.980192, 0.972004, 0.964872, 0.969231, 0.841827, 1], +[1.06822, 1.13373, 1.22308, 1.16611, 1.01388, 1.06828, 1.06539, 1.08269, 1.08061, 1.08864, 0.975235, 1.02304, 1.02052, 1.0031, 0.990162, 0.986197, 0.980423, 0.968884, 0.876923, 0.853859, 1], +[1.088, 1.08228, 1.15033, 1.16992, 1.02095, 1.05037, 1.04923, 1.05511, 1.03741, 1.04549, 0.998608, 1.04065, 1.04638, 1.04287, 1.03978, 1.03551, 1.03327, 1.01964, 0.969231, 0.928778, 1], +[1.06134, 1.07087, 1.13335, 1.1473, 1.01166, 1.05035, 1.03923, 1.05272, 1.03184, 1.02643, 0.985362, 1.03035, 1.03848, 1.03402, 1.03025, 1.02781, 1.02005, 1.01456, 1.04615, 0.947696, 1], +[1.02439, 1.02975, 1.03728, 1.09439, 0.974983, 1.00738, 1.00662, 1.016, 0.999814, 0.975261, 0.958696, 0.999569, 1.00895, 1.00741, 1.00495, 1.00166, 0.999155, 0.993898, 0.992308, 0.97022, 1], +[1.00698, 1.00495, 0.991761, 1.01249, 0.981476, 0.999528, 0.99939, 1.00238, 0.99601, 0.96414, 0.987203, 0.998647, 1.00389, 1.00354, 1.00338, 1.00247, 1.00239, 1.00077, 1.00879, 0.979493, 1], +[1.01036, 1.00545, 1.0073, 1.01002, 0.986233, 1.00075, 1.00497, 0.997815, 0.999706, 0.982039, 1.00018, 1.00176, 1.00353, 1.0034, 1.00322, 1.00395, 1.00239, 1.00677, 0.995604, 1.00742, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1.00326, 1.00893, 0.981908, 1.00688, 0.983689, 1.00378, 0.998563, 0.995499, 1.00682, 0.997098, 0.992604, 0.994677, 0.998323, 0.997436, 0.997583, 0.997269, 0.995517, 0.990071, 0.984615, 0.997593, 1], +[1.00419, 0.99139, 0.988142, 0.989949, 0.987665, 0.993987, 0.995894, 0.989736, 0.987683, 0.984006, 0.99745, 0.991238, 0.99326, 0.992002, 0.9916, 0.992211, 0.988493, 0.989086, 0.982657, 0.995758, 1], +[1.00033, 0.999973, 0.986212, 0.992648, 0.990341, 0.996469, 0.990997, 0.98742, 0.982071, 0.966529, 0.996929, 0.988278, 0.99071, 0.990932, 0.990534, 0.990377, 0.991391, 0.986356, 0.986982, 0.995863, 1], +[0.997823, 0.997993, 0.996516, 0.980383, 0.973388, 0.988612, 0.992555, 0.990589, 0.98603, 0.955803, 0.982497, 0.985134, 0.989585, 0.989439, 0.98986, 0.987933, 0.988564, 0.983245, 0.988811, 0.975359, 1], +[1.00145, 1.00299, 1.01761, 1.03578, 0.971403, 0.991637, 1.001, 0.996646, 0.978679, 0.98986, 0.961125, 0.985624, 0.993008, 0.991249, 0.98943, 0.986799, 0.987093, 0.976908, 1, 0.95216, 1], +[1.02765, 1.05224, 1.08272, 1.12208, 0.995723, 1.0241, 1.02565, 1.0367, 1.01459, 1.03169, 0.985472, 1.02033, 1.02764, 1.02175, 1.01865, 1.01438, 1.00701, 1.01059, 0.976923, 0.938199, 1], +[1.0787, 1.08527, 1.10586, 1.15524, 1.02656, 1.03945, 1.04886, 1.04752, 1.03223, 1.00483, 1.00023, 1.03519, 1.03736, 1.03311, 1.02905, 1.02496, 1.01955, 1.00925, 1.03077, 0.928851, 1], +[1.05407, 1.07286, 1.14085, 1.13365, 1.00321, 1.04376, 1.04587, 1.05198, 1.04193, 1.05515, 0.976433, 1.01714, 1.01288, 0.994341, 0.979535, 0.976823, 0.978074, 0.949956, 0.923077, 0.837593, 1], +[1.06226, 1.12014, 1.17891, 1.18049, 1.03381, 1.07113, 1.05943, 1.05496, 1.04184, 1.04432, 1.00074, 1.01669, 1.00968, 1.00158, 0.991343, 0.981698, 0.971028, 0.963456, 1, 0.853603, 1], +[1.0421, 1.04362, 1.03215, 1.00733, 1.00688, 1.01012, 0.995392, 0.975134, 0.961122, 0.859542, 0.894761, 0.968768, 0.968193, 0.971021, 0.968925, 0.966411, 0.963923, 0.962293, 1, 0.810748, 1], +[1.05884, 1.04375, 1.03846, 1.01044, 1.01915, 1.01851, 1.0016, 0.986813, 0.966459, 0.867083, 0.886514, 0.973076, 0.970679, 0.972459, 0.970648, 0.96881, 0.972509, 0.968884, 1, 0.774462, 1], +[1.05683, 1.0476, 1.0008, 0.97346, 1.02024, 1.02595, 0.994583, 0.98965, 0.959866, 0.867563, 0.885586, 0.975321, 0.969133, 0.970606, 0.968159, 0.961191, 0.957472, 1, 1, 0.728722, 1], +[1.0544, 1.021, 1.02373, 0.981706, 1.00512, 1.01978, 0.989929, 0.974602, 0.95836, 0.854214, 0.865464, 0.972314, 0.965047, 0.967045, 0.961512, 0.947749, 0.83201, 1, 1, 0.656396, 1], +[1.0136, 0.986109, 0.94201, 0.874168, 0.89865, 0.987246, 0.936149, 0.93741, 0.92277, 0.831139, 0.848595, 0.973952, 0.952389, 0.952801, 0.940302, 0.93932, 1, 1, 1, 0.709617, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[0.957084, 0.91684, 0.85538, 0.78333, 0.773765, 0.931254, 0.895317, 0.88877, 0.877844, 0.796638, 0.797414, 0.944883, 0.920993, 0.903721, 0.774315, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 0.832556, 0.698693, 0.639456, 0.692557, 0.777771, 0.792767, 0.849111, 0.708267, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], +[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] +] diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetConfig.py b/Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetConfig.py new file mode 100755 index 00000000000..0d6f6473dd8 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetConfig.py @@ -0,0 +1,1541 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +# Monitoring classes are loaded for each algorithm + +from AthenaCommon.Logging import logging +from TrigT2CaloJet.TrigT2CaloJetConf import T2CaloJetGridFromCells +from TrigT2CaloJet.TrigT2CaloJetConf import T2CaloJetGridFromFEBHeader +from TrigT2CaloJet.TrigT2CaloJetConf import T2CaloJetConeTool +from TrigT2CaloJet.TrigT2CaloJetConf import T2CaloJetCalibTool +from TrigT2CaloJet.TrigT2CaloJetConf import T2L1CaloJet +from TrigT2CaloJet.TrigT2CaloJetConf import T2L1CaloFullScanJet +from TrigT2CaloJet.TrigT2CaloJetConf import T2L1CaloJetFullScanFastJetTool +from TrigT2CaloJet.TrigT2CaloJetConf import T2L1Unpacking +from TrigT2CaloJet.TrigT2CaloJetConf import T2AllRoiUnpacking +from TrigT2CaloJet.TrigT2CaloJetConf import T2CaloFastJet +from TrigT2CaloJet.TrigT2CaloJetConf import T2CaloJet +from TrigT2CaloJet.TrigT2CaloJetConf import T2L1TowerCalibTool +from TrigT2CaloJet.TrigT2CaloJetConf import T2L1CaloJetCalibTool + +import TrigT2CaloJet.CalibrationFactorsL15 as CalibrationFactorsL15 + +from TrigT2CaloCalibration.TrigT2CaloCalibrationConf import T2SampCalibTool +from TrigT2CaloCalibration.TrigT2CaloCalibrationConf import T2JESCalibTool +from TrigT2CaloCalibration.TrigT2CaloCalibrationConf import T2GSCalibTool + +#import JetCalibTools.EtaMassEnergyFactors as EtaMassEnergyFactors +#import JetCalibTools.Tile1FractionConstants as Tile1FractionConstants +#import JetCalibTools.HEC0FractionConstants as HEC0FractionConstants +#import JetCalibTools.EM3FractionConstants as EM3FractionConstants +#import JetCalibTools.FCAL1FractionConstants as FCAL1FractionConstants +#import JetCalibTools.PresamplerFractionConstants as PresamplerFractionConstants + +from AthenaCommon.Constants import VERBOSE,DEBUG,INFO +from AthenaPython import PyAthena # for L1.5 enums + +class T2AllRoiUnpacking_test(T2AllRoiUnpacking): + __slots__ = [] + def __init__(self, name="T2AllRoiUnpacking_test", noisecut=2.): + super( T2AllRoiUnpacking_test, self ).__init__(name) + from TrigT2CaloJet.TrigT2CaloJetMonitoring import T2AllRoiUnpackingTimeOnlineMonitoring, T2AllRoiUnpackingTimeValidationMonitoring + online = T2AllRoiUnpackingTimeOnlineMonitoring() + validation = T2AllRoiUnpackingTimeValidationMonitoring() + self.AthenaMonTools = [online, validation, ] + self.doTiming=True + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2CaloJetGridFromCells() + from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault + theNoiseTool = CaloNoiseToolDefault() + ToolSvc += theNoiseTool + # add the tool used to get & fill the calorimeter cells + t2calojetgridfromcellsTool = T2CaloJetGridFromCells() + t2calojetgridfromcellsTool.doTiming = True + t2calojetgridfromcellsTool.doHECcellQualityCleaning = False + t2calojetgridfromcellsTool.applyNoiseCut = True # gerbaudo@cern.ch: should I set also the threshold? (default is 2.0) + t2calojetgridfromcellsTool.noiseTool = theNoiseTool + t2calojetgridfromcellsTool.applyNoiseCut = True + t2calojetgridfromcellsTool.noiseCutValue = noisecut + + self.GridFromCellsTool = t2calojetgridfromcellsTool + # here put your customizations + self.L2RoiEtaHalfWidth = 0.5 + self.L2RoiPhiHalfWidth = 0.5 + #self.MergeEmCells=False #default True + +## L1.5 unpackers +class T2L1Unpacking_Base (T2L1Unpacking): + __slots__ = [] + def __init__(self, name): + super( T2L1Unpacking_Base, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2L1UnpackingValidationMonitoring, TrigT2L1UnpackingOnlineMonitoring, TrigT2L1UnpackingCosmicMonitoring + validation = TrigT2L1UnpackingValidationMonitoring() + online = TrigT2L1UnpackingOnlineMonitoring() + cosmic = TrigT2L1UnpackingCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2L1Unpacking_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + +class T2L1Unpacking_TT (T2L1Unpacking_Base): + __slots__ = [] + def __init__(self, name="T2L1Unpacking_TT"): + super( T2L1Unpacking_TT, self ).__init__(name) + # here put your customizations + self.doTriggerTowers = True + +class T2L1Unpacking_TT_TowerCalib (T2L1Unpacking_Base): + __slots__ = [] + def __init__(self, name="T2L1Unpacking_TT_TowerCalib"): + super( T2L1Unpacking_TT_TowerCalib, self ).__init__(name) + # here put your customizations + self.doTriggerTowers = True + # add in the calibration tool + t2l1towercalibtool = T2L1TowerCalibTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1TowerCalibTool() + energyCorr = [ [ ] ] + energyCorr = CalibrationFactorsL15.energyCorrDict['TT_factors'] + t2l1towercalibtool.Calib_Factors = str(energyCorr) + self.T2JetTools = [t2l1towercalibtool] + +class T2L1Unpacking_JE (T2L1Unpacking_Base): + __slots__ = [] + def __init__(self, name="T2L1Unpacking_JE"): + super( T2L1Unpacking_JE, self ).__init__(name) + # here put your customizations + self.doTriggerTowers = False + +class T2L1Unpacking_JE_TowerCalib (T2L1Unpacking_Base): + __slots__ = [] + def __init__(self, name="T2L1Unpacking_JE_TowerCalib"): + super( T2L1Unpacking_JE_TowerCalib, self ).__init__(name) + # here put your customizations + self.doTriggerTowers = False + # add in the calibration tool + t2l1towercalibtool = T2L1TowerCalibTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1TowerCalibTool() + energyCorr = [ [ ] ] + energyCorr = CalibrationFactorsL15.energyCorrDict['JE_factors'] + t2l1towercalibtool.Calib_Factors = str(energyCorr) + self.T2JetTools = [t2l1towercalibtool] + +class T2CaloFastJet_CC (T2CaloFastJet): + "T2CaloFastJet FEX to be used with calorimeter cells" + __slots__ = [] + def __init__(self, name="T2CaloFastJet_CC"): + super( T2CaloFastJet_CC, self ).__init__(name) + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2CaloFastJetValidationMonitoring, TrigT2CaloFastJetOnlineMonitoring, TrigT2CaloFastJetCosmicMonitoring + validation = TrigT2CaloFastJetValidationMonitoring() + online = TrigT2CaloFastJetOnlineMonitoring() + cosmic = TrigT2CaloFastJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2CaloFastJet_CC_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + + # here put your customizations + self.doCleaning = True + self.doT2L1Cleaning = False # do the regular cell-based cleaning + self.outputType = PyAthena.T2L1Tools.A4CC + +class T2CaloFastJet_CC_JESCalib (T2CaloFastJet_CC): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_CC_JESCalib"): + super( T2CaloFastJet_CC_JESCalib, self ).__init__(name) + # here put your customizations + self.outputType = PyAthena.T2L1Tools.A4CC_JES + # add in the calibration tool + t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + t2jescalibtool.MinEtCut = 1 + # Jet calibration factors + energyCorr = [ [ ] ] +# energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] # as a test, eventually we'll have our own constants + t2jescalibtool.JES_Factors = str(energyCorr) + t2calojetcalibtool = T2CaloJetCalibTool() + t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + t2calojetcalibtool.doJetCalib = True + t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + self.T2JetTools = [t2calojetcalibtool] + +class T2CaloFastJet_CC_JESCalib_L15 (T2CaloFastJet_CC_JESCalib): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_CC_JESCalib_L15"): + super( T2CaloFastJet_CC_JESCalib_L15, self ).__init__(name) + # here put your customizations + self.inputType = PyAthena.T2L1Tools.A4TT +class T2CaloFastJet_CC_JESCalib_L15had (T2CaloFastJet_CC_JESCalib): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_CC_JESCalib_L15had"): + super( T2CaloFastJet_CC_JESCalib_L15had, self ).__init__(name) + # here put your customizations + self.inputType = PyAthena.T2L1Tools.A4TT_JES + + +## L1.5 FastJet FEXes +class T2CaloFastJet_Base (T2CaloFastJet): + __slots__ = [] + def __init__(self, name): + super( T2CaloFastJet_Base, self ).__init__(name) + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2CaloFastJetValidationMonitoring, TrigT2CaloFastJetOnlineMonitoring, TrigT2CaloFastJetCosmicMonitoring + validation = TrigT2CaloFastJetValidationMonitoring() + online = TrigT2CaloFastJetOnlineMonitoring() + cosmic = TrigT2CaloFastJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2CaloFastJet_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + +############### +# All non-multiple output TE algorithms should not be used with current L1.5 L2 interface +############### +#class T2CaloFastJet_a4JE (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4JE"): + #super( T2CaloFastJet_a4JE, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.outputType = PyAthena.T2L1Tools.A4JE + +#class T2CaloFastJet_a4JE_TowerCalib (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4JE_TowerCalib"): + #super( T2CaloFastJet_a4JE_TowerCalib, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.inputType = PyAthena.T2L1Tools.CALIBRATED + #self.outputType = PyAthena.T2L1Tools.A4JE_TC + + +#class T2CaloFastJet_a4JE_JESCalib (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4JE_JESCalib"): + #super( T2CaloFastJet_a4JE_JESCalib, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.outputType = PyAthena.T2L1Tools.A4JE_JES + + ## add in the calibration tool + #t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + #t2jescalibtool.MinEtCut = 1 + ## Jet calibration factors + #energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] # as a test, eventually we'll have our own constants + #t2jescalibtool.JES_Factors = str(energyCorr) + + #t2calojetcalibtool = T2CaloJetCalibTool() + #t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + #t2calojetcalibtool.doJetCalib = True + #t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + #self.T2JetTools = [t2calojetcalibtool] + + +#class T2CaloFastJet_a4JE_TowerCalib_JESCalib (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4JE_TowerCalib_JESCalib"): + #super( T2CaloFastJet_a4JE_TowerCalib_JESCalib, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.inputType = PyAthena.T2L1Tools.CALIBRATED + #self.outputType = PyAthena.T2L1Tools.A4JE_TC_JES + + ## add in the calibration tool + #t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + #t2jescalibtool.MinEtCut = 1 + ## Jet calibration factors + #energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] # as a test, eventually we'll have our own constants + #t2jescalibtool.JES_Factors = str(energyCorr) + + #t2calojetcalibtool = T2CaloJetCalibTool() + #t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + #t2calojetcalibtool.doJetCalib = True + #t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + #self.T2JetTools = [t2calojetcalibtool] + + +#class T2CaloFastJet_a10JE (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a10JE"): + #super( T2CaloFastJet_a10JE, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.distanceParameter = 1.0 + #self.outputType = PyAthena.T2L1Tools.A10JE + +class T2CaloFastJet_a4JE (T2CaloFastJet_Base): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_a4JE"): + super( T2CaloFastJet_a4JE, self ).__init__(name) + # here put your customizations + self.doCleaning = True + self.doT2L1Cleaning = True + self.outputType = PyAthena.T2L1Tools.A4JE + self.writeMultipleOutputTEs = True + self.secondOutputType = PyAthena.T2L1Tools.L2CONE +class T2CaloFastJet_a10JE (T2CaloFastJet_Base): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_a10JE"): + super( T2CaloFastJet_a10JE, self ).__init__(name) + # here put your customizations + self.doCleaning = True + self.doT2L1Cleaning = True + self.outputType = PyAthena.T2L1Tools.A10JE + self.distanceParameter = 1.0 + self.writeMultipleOutputTEs = True + self.secondOutputType = PyAthena.T2L1Tools.L2CONE +############### +# All non-multiple output TE algorithms should not be used with current L1.5 L2 interface +############### +#class T2CaloFastJet_a4JE_PileupSubtraction (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4JE_PileupSubtraction"): + #super( T2CaloFastJet_a4JE_PileupSubtraction, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.outputType = PyAthena.T2L1Tools.A4JE_PU_SUB + #self.doPileupSubtraction = True + +#class T2CaloFastJet_a4TT (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4TT"): + #super( T2CaloFastJet_a4TT, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.outputType = PyAthena.T2L1Tools.A4TT + +#class T2CaloFastJet_a4TT_TowerCalib (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4TT_TowerCalib"): + #super( T2CaloFastJet_a4TT_TowerCalib, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.inputType = PyAthena.T2L1Tools.CALIBRATED + #self.outputType = PyAthena.T2L1Tools.A4TT_TC + + +#class T2CaloFastJet_a4TT_JESCalib (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4TT_JESCalib"): + #super( T2CaloFastJet_a4TT_JESCalib, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.outputType = PyAthena.T2L1Tools.A4TT_JES + + ## add in the calibration tool + #t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + #t2jescalibtool.MinEtCut = 1 + ## Jet calibration factors + #energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] # as a test, eventually we'll have our own constants + #t2jescalibtool.JES_Factors = str(energyCorr) + + #t2calojetcalibtool = T2CaloJetCalibTool() + #t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + #t2calojetcalibtool.doJetCalib = True + #t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + #self.T2JetTools = [t2calojetcalibtool] + + +#class T2CaloFastJet_a4TT_TowerCalib_JESCalib (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4TT_TowerCalib_JESCalib"): + #super( T2CaloFastJet_a4TT_TowerCalib_JESCalib, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.inputType = PyAthena.T2L1Tools.CALIBRATED + #self.outputType = PyAthena.T2L1Tools.A4TT_TC_JES + + ## add in the calibration tool + #t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + #t2jescalibtool.MinEtCut = 1 + ## Jet calibration factors + #energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] # as a test, eventually we'll have our own constants + #t2jescalibtool.JES_Factors = str(energyCorr) + + #t2calojetcalibtool = T2CaloJetCalibTool() + #t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + #t2calojetcalibtool.doJetCalib = True + #t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + #t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + #self.T2JetTools = [t2calojetcalibtool] + + +#class T2CaloFastJet_a10TT (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a10TT"): + #super( T2CaloFastJet_a10TT, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.distanceParameter = 1.0 + #self.outputType = PyAthena.T2L1Tools.A10TT + + +class T2CaloFastJet_a4TT (T2CaloFastJet_Base): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_a4TT"): + super( T2CaloFastJet_a4TT, self ).__init__(name) + # here put your customizations + self.doCleaning = True + self.doT2L1Cleaning = True + self.outputType = PyAthena.T2L1Tools.A4TT + self.writeMultipleOutputTEs = True + self.secondOutputType = PyAthena.T2L1Tools.L2CONE + +class T2CaloFastJet_a10TT (T2CaloFastJet_Base): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_a10TT"): + super( T2CaloFastJet_a10TT, self ).__init__(name) + # here put your customizations + self.doCleaning = True + self.doT2L1Cleaning = True + self.outputType = PyAthena.T2L1Tools.A10TT + self.distanceParameter = 1.0 + self.writeMultipleOutputTEs = True + self.secondOutputType = PyAthena.T2L1Tools.L2CONE + +class T2CaloFastJet_a4TT_JESCalib (T2CaloFastJet_Base): + __slots__ = [] + def __init__(self, name="T2CaloFastJet_a4TT_JESCalib"): + super( T2CaloFastJet_a4TT_JESCalib, self ).__init__(name) + # here put your customizations + self.doCleaning = True + self.doT2L1Cleaning = True + self.outputType = PyAthena.T2L1Tools.A4TT_JES + self.pTmin = 10000. # here we could lower the pTmin cut so we can calibrate jets up. + + # add in the calibration tool + t2l1calojetcalibtool = T2L1CaloJetCalibTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1CaloJetCalibTool() + # Jet calibration factors + energyCorr = [ [ ] ] + energyCorr = CalibrationFactorsL15.energyCorrDict['L2FS_em_residual_factors'] ### DEBUG FACTORS replace with real ones + Eta_bins = CalibrationFactorsL15.binEdgeDict['L2FS_em_residual_factors_eta'] + t2l1calojetcalibtool.Calib_Factors = str(energyCorr) + t2l1calojetcalibtool.Eta_bin_edges = Eta_bins + assert len(Eta_bins)-1 == len(energyCorr), "T2CaloFastJet_a4TT_JESCalib eta bin length %i-1 != number of x bins in energy correction matrix %i"%(len(Eta_bins),len(energyCorr)) + + # add in the calibration tool + t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + t2jescalibtool.MinEtCut = 1 + # Jet calibration factors + energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] # as a test, eventually we'll have our own constants + t2jescalibtool.JES_Factors = str(energyCorr) + t2calojetcalibtool = T2CaloJetCalibTool() + t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + t2calojetcalibtool.doJetCalib = True + t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + self.T2JetTools = [t2l1calojetcalibtool,t2calojetcalibtool] + + self.writeMultipleOutputTEs = True + self.secondOutputType = PyAthena.T2L1Tools.L2CONE + +#class T2CaloFastJet_a4TT_PileupSubtraction (T2CaloFastJet_Base): + #__slots__ = [] + #def __init__(self, name="T2CaloFastJet_a4TT_PileupSubtraction"): + #super( T2CaloFastJet_a4TT_PileupSubtraction, self ).__init__(name) + ## here put your customizations + #self.doCleaning = True + #self.doT2L1Cleaning = True + #self.outputType = PyAthena.T2L1Tools.A4TT_PU_SUB + #self.doPileupSubtraction = True + +## depreciated L1.5 FEXes +class T2L1CaloFullScanFastJet_JE_Jet (T2L1CaloFullScanJet): + __slots__ = [] + def __init__(self, name="T2L1CaloFullScanFastJet_JE_Jet"): + super( T2L1CaloFullScanFastJet_JE_Jet, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2L1CaloJetValidationMonitoring, TrigT2L1CaloJetOnlineMonitoring, TrigT2L1CaloJetCosmicMonitoring + validation = TrigT2L1CaloJetValidationMonitoring() + online = TrigT2L1CaloJetOnlineMonitoring() + cosmic = TrigT2L1CaloJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2L1CaloFullScanJet_JE_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + + # here put your customizations + t2l1fullscanfastjettool = T2L1CaloJetFullScanFastJetTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1CaloJetFullScanFastJetTool() + t2l1fullscanfastjettool.coneRadius = 0.4 + t2l1fullscanfastjettool.doTriggerTowers = False + t2l1fullscanfastjettool.doCleaning = True + + self.T2JetTools = [t2l1fullscanfastjettool] + +class T2L1CaloFullScanFastJet_TT_Jet (T2L1CaloFullScanJet): + __slots__ = [] + def __init__(self, name="T2L1CaloFullScanFastJet_TT_Jet"): + super( T2L1CaloFullScanFastJet_TT_Jet, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2L1CaloJetValidationMonitoring, TrigT2L1CaloJetOnlineMonitoring, TrigT2L1CaloJetCosmicMonitoring + validation = TrigT2L1CaloJetValidationMonitoring() + online = TrigT2L1CaloJetOnlineMonitoring() + cosmic = TrigT2L1CaloJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2L1CaloFullScanJet_TT_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + + # here put your customizations + t2l1fullscanfastjettool = T2L1CaloJetFullScanFastJetTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1CaloJetFullScanFastJetTool() + t2l1fullscanfastjettool.coneRadius = 0.4 + t2l1fullscanfastjettool.doTriggerTowers = True + t2l1fullscanfastjettool.doCleaning = True + t2l1fullscanfastjettool.doJetFinding = True + + self.T2JetTools = [t2l1fullscanfastjettool] + + # debug + self.recordOutput = True + +class T2L1CaloFullScanFastJet_10_TT_Jet (T2L1CaloFullScanJet): + __slots__ = [] + def __init__(self, name="T2L1CaloFullScanFastJet_10_TT_Jet"): + super( T2L1CaloFullScanFastJet_10_TT_Jet, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2L1CaloJetValidationMonitoring, TrigT2L1CaloJetOnlineMonitoring, TrigT2L1CaloJetCosmicMonitoring + validation = TrigT2L1CaloJetValidationMonitoring() + online = TrigT2L1CaloJetOnlineMonitoring() + cosmic = TrigT2L1CaloJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2L1CaloFullScanJet_10_TT_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + + # here put your customizations + t2l1fullscanfastjettool = T2L1CaloJetFullScanFastJetTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1CaloJetFullScanFastJetTool() + t2l1fullscanfastjettool.coneRadius = 1.0 + t2l1fullscanfastjettool.doTriggerTowers = True + + self.T2JetTools = [t2l1fullscanfastjettool] + + +class T2L1CaloFullScanFastJet_10_JE_Jet (T2L1CaloFullScanJet): + __slots__ = [] + def __init__(self, name="T2L1CaloFullScanFastJet_10_JE_Jet"): + super( T2L1CaloFullScanFastJet_10_JE_Jet, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2L1CaloJetValidationMonitoring, TrigT2L1CaloJetOnlineMonitoring, TrigT2L1CaloJetCosmicMonitoring + validation = TrigT2L1CaloJetValidationMonitoring() + online = TrigT2L1CaloJetOnlineMonitoring() + cosmic = TrigT2L1CaloJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2L1CaloFullScanJet_10_JE_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + + # here put your customizations + t2l1fullscanfastjettool = T2L1CaloJetFullScanFastJetTool() + from AthenaCommon.AppMgr import ToolSvc + ToolSvc += T2L1CaloJetFullScanFastJetTool() + t2l1fullscanfastjettool.coneRadius = 1.0 + t2l1fullscanfastjettool.doTriggerTowers = False + + self.T2JetTools = [t2l1fullscanfastjettool] + + +class T2L1CaloJet_Jet (T2L1CaloJet): + __slots__ = [] + def __init__(self, name="T2L1CaloJet_Jet"): + super( T2L1CaloJet_Jet, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2VirtualL1CaloJetValidationMonitoring, TrigT2VirtualL1CaloJetOnlineMonitoring, TrigT2VirtualL1CaloJetCosmicMonitoring + validation = TrigT2VirtualL1CaloJetValidationMonitoring() + online = TrigT2VirtualL1CaloJetOnlineMonitoring() + cosmic = TrigT2VirtualL1CaloJetCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2L1CaloJet_Time") + time.TimerHistLimits = [0,20] + self.doTiming=True + + self.AthenaMonTools = [ validation, online, time, cosmic] + + +class T2CaloJetBase (T2CaloJet): + __slots__ = [] + def __init__(self, name): + super( T2CaloJetBase, self ).__init__(name) + + from TrigT2CaloJet.TrigT2CaloJetMonitoring import TrigT2CaloJetValidationMonitoring, TrigT2CaloJetOnlineMonitoring, TrigT2CaloJetCosmicMonitoring, TrigT2CaloJetTimeMonitoring + validation = TrigT2CaloJetValidationMonitoring() + online = TrigT2CaloJetOnlineMonitoring() + cosmic = TrigT2CaloJetCosmicMonitoring() + timeUnp = TrigT2CaloJetTimeMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("T2CaloJet_Time") + + self.AthenaMonTools = [ validation, online, time, timeUnp, cosmic] + + # are these the correct widths for the jets ?? + # really the best thing to do would be for T2CaloJet + # to determine the jet size *itself*, perhaps even on + # a jet-by-jet basis + self.EtaIDWidth = 0.2 + self.PhiIDWidth = 0.2 + + +### Classes for non-calibrated L2 jets #### + +class T2CaloJet_Jet_noCalib (T2CaloJetBase): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noCalib"): + super(T2CaloJet_Jet_noCalib, self).__init__(name) + + # here put your customizations + t2calojetconetool = T2CaloJetConeTool() + t2calojetconetool.coneRadius = 0.4 + t2calojetconetool.numberOfIterations = 3 + t2calojetconetool.coneFJRadius=[1.0,0.7,0.4] + t2calojetconetool.cellQualityThresholdLAr = 4000 + t2calojetconetool.leadingCellFraction = 0.9 + + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.clearJetGrid = False + #self.OutputLevel = INFO + + t2calojetgridfromcells = T2CaloJetGridFromCells() + t2calojetgridfromcells.doTiming = True + t2calojetgridfromcells.doHECcellQualityCleaning = False + + self.jetOutputKey = "TrigT2CaloJet" + + self.T2JetTools = [t2calojetgridfromcells, + t2calojetconetool + ] + +class T2CaloJet_Jet_noCalib_cellCleaning (T2CaloJet_Jet_noCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noCalib_cellCleaning"): + super(T2CaloJet_Jet_noCalib_cellCleaning, self).__init__(name) + + t2calojetgridfromcells = T2CaloJetGridFromCells("T2CaloJetGridFromCells_cellCleaning") + t2calojetgridfromcells.doHECcellQualityCleaning = True + t2calojetgridfromcells.cellQualityThresholdHEC = 65535 + + +class T2CaloJet_Jet_noCalib_noiseCut (T2CaloJet_Jet_noCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noCalib_noiseCut",noisecut=2.): + mlog = logging.getLogger( 'T2CaloJet_Jet_noCalib_noiseCut:' ) + try: + from AthenaCommon.AppMgr import ToolSvc + from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault + theNoiseTool = CaloNoiseToolDefault() + ToolSvc += theNoiseTool + #cellTool.CaloNoiseTool=theCaloNoiseTool + except Exception: + mlog.error("could not get handle to CaloNoiseToolDefault") + print traceback.format_exc() + return False + + super(T2CaloJet_Jet_noCalib_noiseCut, self).__init__(name) + #self.t2calojetgridfromcells = T2CaloJetGridFromCells() + self.T2JetTools[0].noiseTool = theNoiseTool + self.T2JetTools[0].applyNoiseCut = True + self.T2JetTools[0].noiseCutValue = noisecut + +### Classes for L2 jets calibrated with the offline JES correction ### + +class T2CaloJet_Jet_JESCalib (T2CaloJetBase): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_JESCalib"): + super(T2CaloJet_Jet_JESCalib, self).__init__(name) + + # here put your customizations + t2calojetconetool = T2CaloJetConeTool() + t2calojetconetool.coneRadius = 0.4 + t2calojetconetool.numberOfIterations = 3 + t2calojetconetool.coneFJRadius=[1.0,0.7,0.4] + t2calojetconetool.cellQualityThresholdLAr = 4000 + t2calojetconetool.leadingCellFraction = 0.9 + + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.clearJetGrid = False + #self.OutputLevel = INFO + + t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + t2jescalibtool.MinEtCut = 1 + # Jet calibration factors + energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] + t2jescalibtool.JES_Factors = str(energyCorr) + + t2calojetcalibtool = T2CaloJetCalibTool() + t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + t2calojetcalibtool.doJetCalib = True + t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + t2calojetgridfromcells = T2CaloJetGridFromCells() + t2calojetgridfromcells.doTiming = True + t2calojetgridfromcells.doHECcellQualityCleaning = False + + self.jetOutputKey = "TrigT2CaloJet" + + self.T2JetTools = [t2calojetgridfromcells, + t2calojetconetool, + t2calojetcalibtool] + +class T2CaloJet_Jet_JESCalib_cellCleaning (T2CaloJet_Jet_JESCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_JESCalib_cellCleaning"): + + t2calojetgridfromcells = T2CaloJetGridFromCells("T2CaloJetGridFromCells_cellCleaning") + t2calojetgridfromcells.doHECcellQualityCleaning = True + t2calojetgridfromcells.cellQualityThresholdHEC = 65535 + + +class T2CaloJet_Jet_JESCalib_noiseCut (T2CaloJet_Jet_JESCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_JESCalib_noiseCut",noisecut=2.): + mlog = logging.getLogger( 'T2CaloJet_Jet_JESCalib_noiseCut:' ) + try: + from AthenaCommon.AppMgr import ToolSvc + from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault + theNoiseTool = CaloNoiseToolDefault() + ToolSvc += theNoiseTool + #cellTool.CaloNoiseTool=theCaloNoiseTool + except Exception: + mlog.error("could not get handle to CaloNoiseToolDefault") + print traceback.format_exc() + return False + + super(T2CaloJet_Jet_JESCalib_noiseCut, self).__init__(name) + #self.t2calojetgridfromcells = T2CaloJetGridFromCells() + self.T2JetTools[0].noiseTool = theNoiseTool + self.T2JetTools[0].applyNoiseCut = True + self.T2JetTools[0].noiseCutValue = noisecut + +class T2CaloJet_Jet_JESCalib_writeLayers (T2CaloJet_Jet_JESCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_JESCalib_writeLayers"): + super(T2CaloJet_Jet_JESCalib_writeLayers, self).__init__(name) + self.fillLayerInfo = True + +class T2CaloJet_Jet_JESCalib_cellCleaning_writeLayers (T2CaloJet_Jet_JESCalib_cellCleaning): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_JESCalib_cellCleaning_writeLayers"): + super(T2CaloJet_Jet_JESCalib_cellCleaning_writeLayers, self).__init__(name) + self.fillLayerInfo = True + +class T2CaloJet_Jet_JESCalib_noiseCut_writeLayers (T2CaloJet_Jet_JESCalib_noiseCut): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_JESCalib_noiseCut_writeLayers"): + super(T2CaloJet_Jet_JESCalib_noiseCut_writeLayers, self).__init__(name) + self.fillLayerInfo = True + +### Classes for jets calibrated with the offline GSC procedure ### + +class T2CaloJet_Jet_GSCalib (T2CaloJetBase): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_GSCalib"): + super(T2CaloJet_Jet_GSCalib, self).__init__(name) + + # here put your customizations + t2calojetconetool = T2CaloJetConeTool() + t2calojetconetool.coneRadius = 0.4 + t2calojetconetool.numberOfIterations = 3 + t2calojetconetool.coneFJRadius=[1.0,0.7,0.4] + t2calojetconetool.cellQualityThresholdLAr = 4000 + t2calojetconetool.leadingCellFraction = 0.9 + + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.clearJetGrid = False + #self.OutputLevel = INFO + + t2jescalibtool = T2JESCalibTool("T2JESCalibTool_Jet") + t2jescalibtool.MinEtCut = 1 + energyCorr = [ [ ] ] + #energyCorr = EtaMassEnergyFactors.energyCorrDict['AntiKt4TopoJets_EM'] + t2jescalibtool.JES_Factors = str(energyCorr) + + t2gscalibtooltile1 = T2GSCalibTool("T2GSCalibToolTile1_Jet") + etaFit = [] + etabins = [] + ptbins = [] + layerFracBins = [] + #etaFit = Tile1FractionConstants.tile1EtaFitDict['AntiKt4TopoJets'] + #etabins = Tile1FractionConstants.tile1EtaBinsDict['AntiKt4TopoJets'] + #ptbins = Tile1FractionConstants.tile1PtBinsDict['AntiKt4TopoJets'] + #layerFracBins = Tile1FractionConstants.tile1LayerFracBinsDict['AntiKt4TopoJets'] + t2gscalibtooltile1.CalibConstants = str(etaFit) + t2gscalibtooltile1.EtaBins = etabins + t2gscalibtooltile1.EtaMin = -1.7 + t2gscalibtooltile1.EtaMax = 1.7 + t2gscalibtooltile1.PtBins = ptbins + t2gscalibtooltile1.PtMin = 1000.0 + t2gscalibtooltile1.JetPropertyBins = layerFracBins + + t2gscalibtoolfcal1 = T2GSCalibTool("T2GSCalibToolFcal1_Jet") + etaFit = [] + etabins = [] + ptbins = [] + layerFracBins = [] + #etaFit = FCAL1FractionConstants.fcal1EtaFitDict['AntiKt4TopoJets'] + #etabins = FCAL1FractionConstants.fcal1EtaBinsDict['AntiKt4TopoJets'] + #ptbins = FCAL1FractionConstants.fcal1PtBinsDict['AntiKt4TopoJets'] + #layerFracBins = FCAL1FractionConstants.fcal1LayerFracBinsDict['AntiKt4TopoJets'] + t2gscalibtoolfcal1.CalibConstants = str(etaFit) + t2gscalibtoolfcal1.EtaBins = etabins + t2gscalibtoolfcal1.EtaMin = -4.4 + t2gscalibtoolfcal1.EtaGapMin = -3.5 + t2gscalibtoolfcal1.EtaGapMax = 3.5 + t2gscalibtoolfcal1.EtaMax = 4.4 + t2gscalibtoolfcal1.PtBins = ptbins + t2gscalibtoolfcal1.PtMin = 1000.0 + t2gscalibtoolfcal1.JetPropertyBins = layerFracBins + + t2gscalibtoolem3bar = T2GSCalibTool("T2GSCalibToolEm3Bar_Jet") + t2gscalibtoolem3fwd = T2GSCalibTool("T2GSCalibToolEm3Fwd_Jet") + etaFit = [] + etabins = [] + ptbins = [] + layerFracBins = [] + #etaFit = EM3FractionConstants.em3EtaFitDict['AntiKt4TopoJets'] + #etabins = EM3FractionConstants.em3EtaBinsDict['AntiKt4TopoJets'] + #ptbins = EM3FractionConstants.em3PtBinsDict['AntiKt4TopoJets'] + #layerFracBins = EM3FractionConstants.em3LayerFracBinsDict['AntiKt4TopoJets'] + t2gscalibtoolem3bar.CalibConstants = str(etaFit) + t2gscalibtoolem3bar.EtaBins = etabins + t2gscalibtoolem3bar.EtaMin = -1.2 + t2gscalibtoolem3bar.EtaMax = 1.2 + t2gscalibtoolem3bar.PtBins = ptbins + t2gscalibtoolem3bar.PtMin = 1000 + t2gscalibtoolem3bar.JetPropertyBins = layerFracBins + t2gscalibtoolem3fwd.CalibConstants = str(etaFit) + t2gscalibtoolem3fwd.EtaBins = etabins + t2gscalibtoolem3fwd.EtaMin = -3.0 + t2gscalibtoolem3fwd.EtaGapMin = -1.7 + t2gscalibtoolem3fwd.EtaGapMax = 1.7 + t2gscalibtoolem3fwd.EtaMax = 3.0 + t2gscalibtoolem3fwd.PtBins = ptbins + t2gscalibtoolem3fwd.PtMin = 1000.0 + t2gscalibtoolem3fwd.JetPropertyBins = layerFracBins + + t2gscalibtoolhec0 = T2GSCalibTool("T2GSCalibToolHec0_Jet") + etaFit = [] + etabins = [] + ptbins = [] + layerFracBins = [] + #etaFit = HEC0FractionConstants.hec0EtaFitDict['AntiKt4TopoJets'] + #etabins = HEC0FractionConstants.hec0EtaBinsDict['AntiKt4TopoJets'] + #ptbins = HEC0FractionConstants.hec0PtBinsDict['AntiKt4TopoJets'] + #layerFracBins = HEC0FractionConstants.hec0LayerFracBinsDict['AntiKt4TopoJets'] + t2gscalibtoolhec0.CalibConstants = str(etaFit) + t2gscalibtoolhec0.EtaBins = etabins + t2gscalibtoolhec0.EtaMin = -3.0 + t2gscalibtoolhec0.EtaGapMin = -1.4 + t2gscalibtoolhec0.EtaGapMax = 1.4 + t2gscalibtoolhec0.EtaMax = 3.0 + t2gscalibtoolhec0.PtBins = ptbins + t2gscalibtoolhec0.PtMin = 1000.0 + t2gscalibtoolhec0.JetPropertyBins = layerFracBins + + t2gscalibtoolpsbar = T2GSCalibTool("T2GSCalibToolPsBar_Jet") + etaFit = [] + etabins = [] + ptbins = [] + layerFracBins = [] + #etaFit = PresamplerFractionConstants.presEtaFitDict['AntiKt4TopoJets'] + #etabins = PresamplerFractionConstants.presEtaBinsDict['AntiKt4TopoJets'] + #ptbins = PresamplerFractionConstants.presPtBinsDict['AntiKt4TopoJets'] + #layerFracBins = PresamplerFractionConstants.presLayerFracBinsDict['AntiKt4TopoJets'] + t2gscalibtoolpsbar.CalibConstants = str(etaFit) + t2gscalibtoolpsbar.EtaBins = etabins + t2gscalibtoolpsbar.EtaMin = -1.7 + t2gscalibtoolpsbar.EtaMax = 1.7 + t2gscalibtoolpsbar.PtBins = ptbins + t2gscalibtoolpsbar.PtMin = 1000.0 + t2gscalibtoolpsbar.JetPropertyBins = layerFracBins + + t2calojetcalibtool = T2CaloJetCalibTool() + t2calojetcalibtool.T2JetCalibTool = t2jescalibtool + t2calojetcalibtool.T2JetCorrToolTile1 = t2gscalibtooltile1 + t2calojetcalibtool.T2JetCorrToolFcal1 = t2gscalibtoolfcal1 + t2calojetcalibtool.T2JetCorrToolEm3Bar = t2gscalibtoolem3bar + t2calojetcalibtool.T2JetCorrToolHec0 = t2gscalibtoolhec0 + t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2gscalibtoolem3fwd + t2calojetcalibtool.T2JetCorrToolPsBar = t2gscalibtoolpsbar + t2calojetcalibtool.doJetCalib = True + t2calojetcalibtool.doJetCorrTile1 = True + t2calojetcalibtool.doJetCorrFcal1 = True + t2calojetcalibtool.doJetCorrEm3Bar = True + t2calojetcalibtool.doJetCorrHec0 = True + t2calojetcalibtool.doJetCorrEm3Fwd = True + t2calojetcalibtool.doJetCorrPsBar = True + + t2calojetgridfromcells = T2CaloJetGridFromCells() + t2calojetgridfromcells.doTiming = True + t2calojetgridfromcells.doHECcellQualityCleaning = False + + self.jetOutputKey = "TrigT2CaloJet" + self.jetOutputKey = "TrigT2Calo" + + self.T2JetTools = [t2calojetgridfromcells, + t2calojetconetool, + t2calojetcalibtool] + + +class T2CaloJet_Jet_GSCalib_cellCleaning (T2CaloJet_Jet_GSCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_GSCalib_cellCleaning"): + + t2calojetgridfromcells = T2CaloJetGridFromCells("T2CaloJetGridFromCells_cellCleaning") + t2calojetgridfromcells.doHECcellQualityCleaning = True + t2calojetgridfromcells.cellQualityThresholdHEC = 65535 + + +class T2CaloJet_Jet_GSCalib_noiseCut (T2CaloJet_Jet_GSCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_GSCalib_noiseCut",noisecut=2.): + mlog = logging.getLogger( 'T2CaloJet_Jet_GSCalib_noiseCut:' ) + try: + from AthenaCommon.AppMgr import ToolSvc + from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault + theNoiseTool = CaloNoiseToolDefault() + ToolSvc += theNoiseTool + #cellTool.CaloNoiseTool=theCaloNoiseTool + except Exception: + mlog.error("could not get handle to CaloNoiseToolDefault") + print traceback.format_exc() + return False + + super(T2CaloJet_Jet_GSCalib_noiseCut, self).__init__(name) + #self.t2calojetgridfromcells = T2CaloJetGridFromCells() + self.T2JetTools[0].noiseTool = theNoiseTool + self.T2JetTools[0].applyNoiseCut = True + self.T2JetTools[0].noiseCutValue = noisecut + +class T2CaloJet_Jet_GSCalib_writeLayers (T2CaloJet_Jet_GSCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_GSCalib_writeLayers"): + super(T2CaloJet_Jet_GSCalib_writeLayers, self).__init__(name) + self.fillLayerInfo = True + +class T2CaloJet_Jet_GSCalib_cellCleaning_writeLayers (T2CaloJet_Jet_GSCalib_cellCleaning): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_GSCalib_cellCleaning_writeLayers"): + super(T2CaloJet_Jet_GSCalib_cellCleaning_writeLayers, self).__init__(name) + self.fillLayerInfo = True + +class T2CaloJet_Jet_GSCalib_noiseCut_writeLayers (T2CaloJet_Jet_GSCalib_noiseCut): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_GSCalib_noiseCut_writeLayers"): + super(T2CaloJet_Jet_GSCalib_noiseCut_writeLayers, self).__init__(name) + self.fillLayerInfo = True + +### Classes for jets calibrated with the dedicated sampling method #### + +class T2CaloJet_Jet_sampCalib (T2CaloJetBase): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_sampCalib"): + super(T2CaloJet_Jet_sampCalib, self).__init__(name) + + # here put your customizations + t2calojetconetool = T2CaloJetConeTool() + t2calojetconetool.coneRadius = 0.4 + t2calojetconetool.numberOfIterations = 3 + t2calojetconetool.coneFJRadius=[1.0,0.7,0.4] + t2calojetconetool.cellQualityThresholdLAr = 4000 + t2calojetconetool.leadingCellFraction = 0.9 + + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.clearJetGrid = False + #self.OutputLevel = INFO + + t2sampcalibtool = T2SampCalibTool("T2SampCalibTool_Jet") + t2sampcalibtool.MinEtCut = 1 + t2sampcalibtool.nEtaBin = 50 + t2sampcalibtool.EtRegionLimit = 5000 + #New database tag + t2sampcalibtool.CreateDbObject=False + t2sampcalibtool.ReadFromDB=True + L2CalibFolder = "/CALO/T2CaloCalib/T2CaloJetCalib" + L2CalibTag = "L2JetCalib-10TeV-Ideal-01" + from IOVDbSvc.CondDB import conddb + conddb.addFolder("CALO",L2CalibFolder+"<tag>"+L2CalibTag+"</tag>") + + ############################################################# + ## THESE VALUES ARE NOT USED !!! # + ## ONLY USED AS A REFERENCE FOR WHAT WAS PUT IN THIS DB TAG # + ############################################################# + + t2sampcalibtool.EtaReg=[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9, + 1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9, + 2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9, + 3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9, + 4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0] + + t2sampcalibtool.VECut=[ 1.0, 1.00500, 1.02006, 1.04534, 1.08107, + 1.12763, 1.18547, 1.25517, 1.33743, 1.43308, + 1.54308, 1.66852, 1.81065, 1.97091, 2.15090, + 2.35240, 2.57746, 2.82832, 3.10748, 3.41774, + 3.76220, 4.14432, 4.56790, 5.03722, 5.55694, + 6.13228, 6.76900, 7.47346, 8.25272, 9.11458, + 10.0677, 11.1215, 12.2866, 13.5748, 14.9987, + 16.5728, 18.3128, 20.2360, 22.3618, 24.7114, + 27.3082, 30.1784, 33.3507, 36.8567, 40.7316, + 1.0, 1.0, 1.0, 1.0, 1.0] + + t2sampcalibtool.Weights=[ + 1.71736, -0.0775919, 1., 0., + 1.68115, -0.0298649, 1., 0., + 1.72263, -0.0820785, 1., 0., + 1.59158, -0.0349583, 1., 0., + 1.71384, -0.0825993, 1., 0., + 1.56296, -0.0334272, 1., 0., + 1.71196, -0.0823075, 1., 0., + 1.55044, -0.0300373, 1., 0., + 1.73526, -0.0858796, 1., 0., + 1.52924, -0.0275084, 1., 0., + 1.74496, -0.0858104, 1., 0., + 1.61094, -0.032966, 1., 0., + 1.77075, -0.0874956, 1., 0., + 1.69556, -0.0399038, 1., 0., + 1.85845, -0.100017, 1., 0., + 1.63193, -0.0292829, 1., 0., + 1.92108, -0.108746, 1., 0., + 1.60507, -0.0185852, 1., 0., + 1.90991, -0.109427, 1., 0., + 1.73985, -0.0214682, 1., 0., + 1.97429, -0.114934, 1., 0., + 1.49217, -0.0234559, 1., 0., + 1.97011, -0.117122, 1., 0., + 1.40092, -0.0201076, 1., 0., + 1.96164, -0.119639, 1., 0., + 1.63634, -0.0399844, 1., 0., + 1.95562, -0.11617, 1., 0., + 1.81431, -0.0515824, 1., 0., + 1.96964, -0.105079, 1., 0., + 1.86882, -0.0653143, 1., 0., + 2.0155, -0.146639, 1., 0., + 1.60657, -0.00444997, 1., 0., + 1.82239, -0.111195, 1., 0., + 1.69562, -0.0408746, 1., 0., + 1.78718, -0.107874, 1., 0., + 1.6367, -0.0480624, 1., 0., + 1.73745, -0.100309, 1., 0., + 1.54562, -0.0400314, 1., 0., + 1.70874, -0.0979269, 1., 0., + 1.53771, -0.0414734, 1., 0., + 1.68658, -0.0964409, 1., 0., + 1.53234, -0.037261, 1., 0., + 1.62871, -0.0876685, 1., 0., + 1.5901, -0.0464532, 1., 0., + 1.60288, -0.0850231, 1., 0., + 1.51135, -0.0319969, 1., 0., + 1.55495, -0.0760847, 1., 0., + 1.60024, -0.0493416, 1., 0., + 1.61099, -0.0871627, 1., 0., + 1.56848, -0.0372076, 1., 0., + 1.61012, -0.080997, 1., 0., + 1.51628, -0.031721, 1., 0., + 1.5527, -0.0745029, 1., 0., + 1.68515, -0.0610052, 1., 0., + 1.54251, -0.0749989, 1., 0., + 1.75605, -0.0614183, 1., 0., + 1.5972, -0.0847241, 1., 0., + 1.83407, -0.0712398, 1., 0., + 1.63888, -0.085407, 1., 0., + 2.15163, -0.111614, 1., 0., + 1.86924, -0.127399, 1., 0., + 2.04718, -0.021142, 1., 0., + 1.93682, -0.114535, 1., 0., + 2.42857, -0.0398346, 1., 0., + 2.05425, -0.0634181, 1., 0., + 2.31097, -0.17624, 1., 0., + 2.3425, -0.134324, 1., 0., + 1.25573, 0.0160847, 1., 0., + 2.22724, -0.190316, 1., 0., + 1.59135, -0.0403045, 1., 0., + 1.70013, -0.105121, 1., 0., + 2.18796, -0.184129, 1., 0., + 1.46967, -0.0542641, 1., 0., + 1.40854, -0.00397349, 1., 0., + 1.7066, -0.103722, 1., 0., + 2.02067, -0.133273, 1., 0., + 2.3121, -0.244998, 1., 0., + -0.0145766, 0.362844, 1., 0., + 1.62273, -0.0687159, 1., 0., + 2.01868, -0.120886, 1., 0., + 1.07068, 0.0528097, 1., 0., + 3.34939, -0.412248, 1., 0., + 1.18681, 0.0214479, 1., 0., + 0.91684, 0.149364, 1., 0., + 0.377452, 0.214947, 1., 0., + 10.9671, -2.31455, 1., 0., + 2.77778, -0.372772, 1., 0., + -6.52839, 2.00992, 1., 0., + -5.04373, 1.62889, 1., 0., + -9.22444, 2.66876, 1., 0., + #46; Eta range [min,max]: [4.5,4.6] + #NEntries: 413 + 3.33217,-0.26788,1,0, + 3.66022,-0.303515,1,0, + #47; Eta range [min,max]: [4.6,4.7] + #NEntries: 292 + 3.64624,-0.30498,1,0, + 3.732,-0.297252,1,0, + #48; Eta range [min,max]: [4.7,4.8] + #NEntries: 207 + 5.74177,-0.587572,1,0, + 6.30603,-0.649457,1,0, + #49; Eta range [min,max]: [4.8,4.9] + #NEntries: 100 + 6.00682,-0.589085,1,0, + 16.6035,-2.09057,1,0, + #50; Eta range [min,max]: [4.9,5] + #NEntries: 4 + 1.42662,-0.0942826,1,0, + 8.93293,-0.0674104,1,0 + ] + + t2calojetcalibtool = T2CaloJetCalibTool() + t2calojetcalibtool.T2JetCalibTool = t2sampcalibtool + t2calojetcalibtool.doJetCalib = True + t2calojetcalibtool.T2JetCorrToolTile1 = t2sampcalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolFcal1 = t2sampcalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Bar = t2sampcalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolHec0 = t2sampcalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2sampcalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolPsBar = t2sampcalibtool #dummy config + + t2calojetgridfromcells = T2CaloJetGridFromCells() + t2calojetgridfromcells.doTiming = True + t2calojetgridfromcells.doHECcellQualityCleaning = False + + self.jetOutputKey = "TrigT2CaloJet" + + self.T2JetTools = [t2calojetgridfromcells, + t2calojetconetool, + t2calojetcalibtool] + +class T2CaloJet_Jet_sampCalib_cellCleaning (T2CaloJet_Jet_sampCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_sampCalib_cellCleaning"): + + t2calojetgridfromcells = T2CaloJetGridFromCells("T2CaloJetGridFromCells_cellCleaning") + t2calojetgridfromcells.doHECcellQualityCleaning = True + t2calojetgridfromcells.cellQualityThresholdHEC = 65535 + + +class T2CaloJet_Jet_sampCalib_noiseCut (T2CaloJet_Jet_sampCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_sampCalib_noiseCut",noisecut=2.): + mlog = logging.getLogger( 'T2CaloJet_Jet_sampCalib_noiseCut:' ) + try: + from AthenaCommon.AppMgr import ToolSvc + from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault + theNoiseTool = CaloNoiseToolDefault() + ToolSvc += theNoiseTool + #cellTool.CaloNoiseTool=theCaloNoiseTool + except Exception: + mlog.error("could not get handle to CaloNoiseToolDefault") + print traceback.format_exc() + return False + + super(T2CaloJet_Jet_sampCalib_noiseCut, self).__init__(name) + #self.t2calojetgridfromcells = T2CaloJetGridFromCells() + self.T2JetTools[0].noiseTool = theNoiseTool + self.T2JetTools[0].applyNoiseCut = True + self.T2JetTools[0].noiseCutValue = noisecut + +### Legacy classes: use only one calibration option, disallow the others #### + +L2Calib="noCalib" +#L2Calib="JESCalib" +#L2Calib="JESCalib_LayerInfo" +#L2Calib="GSCalib" +#L2Calib="GSCalib_LayerInfo" +#L2Calib="sampCalib" + +if L2Calib=="JESCalib" : +### Use L2 jets calibrated with offline JES correction ### + class T2CaloJet_Jet (T2CaloJet_Jet_JESCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet"): + super(T2CaloJet_Jet, self).__init__(name) + class T2CaloJet_Jet_noise (T2CaloJet_Jet_JESCalib_noiseCut): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noise"): + super(T2CaloJet_Jet_noise, self).__init__(name) + class T2CaloJet_Jet_cellCleaning (T2CaloJet_Jet_JESCalib_cellCleaning): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_cellCleaning"): + super(T2CaloJet_Jet_cellCleaning, self).__init__(name) + class T2CaloJet_Jet_L15 (T2CaloJet_Jet_JESCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_L15"): + super(T2CaloJet_Jet_L15, self).__init__(name) + #self.jetOutputKey = "TrigT2CaloJet" +elif L2Calib=="JESCalib_LayerInfo" : +### Use L2 jets calibrated with offline JES correction and write Layer energy ### + class T2CaloJet_Jet (T2CaloJet_Jet_JESCalib_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet"): + super(T2CaloJet_Jet, self).__init__(name) + class T2CaloJet_Jet_noise (T2CaloJet_Jet_JESCalib_noiseCut_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noise"): + super(T2CaloJet_Jet_noise, self).__init__(name) + class T2CaloJet_Jet_cellCleaning (T2CaloJet_Jet_JESCalib_cellCleaning_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_cellCleaning"): + super(T2CaloJet_Jet_cellCleaning, self).__init__(name) + class T2CaloJet_Jet_L15 (T2CaloJet_Jet_JESCalib_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_L15"): + super(T2CaloJet_Jet_L15, self).__init__(name) + #self.jetOutputKey = "TrigT2CaloJet" +elif L2Calib=="GSCalib" : +### Use L2 jets calibrated with offline GSC procedure ### + class T2CaloJet_Jet (T2CaloJet_Jet_GSCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet"): + super(T2CaloJet_Jet, self).__init__(name) + class T2CaloJet_Jet_noise (T2CaloJet_Jet_GSCalib_noiseCut): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noise"): + super(T2CaloJet_Jet_noise, self).__init__(name) + class T2CaloJet_Jet_cellCleaning (T2CaloJet_Jet_GSCalib_cellCleaning): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_cellCleaning"): + super(T2CaloJet_Jet_cellCleaning, self).__init__(name) + class T2CaloJet_Jet_L15 (T2CaloJet_Jet_GSCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_L15"): + super(T2CaloJet_Jet_L15, self).__init__(name) + #self.jetOutputKey = "TrigT2CaloJet" +elif L2Calib=="GSCalib_LayerInfo" : +### Use L2 jets calibrated with offline GSC procedure and write Layer energy ### + class T2CaloJet_Jet (T2CaloJet_Jet_GSCalib_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet"): + super(T2CaloJet_Jet, self).__init__(name) + class T2CaloJet_Jet_noise (T2CaloJet_Jet_GSCalib_noiseCut_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noise"): + super(T2CaloJet_Jet_noise, self).__init__(name) + class T2CaloJet_Jet_cellCleaning (T2CaloJet_Jet_GSCalib_cellCleaning_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_cellCleaning"): + super(T2CaloJet_Jet_cellCleaning, self).__init__(name) + class T2CaloJet_Jet_L15 (T2CaloJet_Jet_GSCalib_writeLayers): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_L15"): + super(T2CaloJet_Jet_L15, self).__init__(name) + #self.jetOutputKey = "TrigT2CaloJet" +elif L2Calib=="sampCalib" : +### Use L2 jets calibrated with dedicated sampling method ### + class T2CaloJet_Jet (T2CaloJet_Jet_sampCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet"): + super(T2CaloJet_Jet, self).__init__(name) + class T2CaloJet_Jet_noise (T2CaloJet_Jet_sampCalib_noiseCut): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noise"): + super(T2CaloJet_Jet_noise, self).__init__(name) + class T2CaloJet_Jet_cellCleaning (T2CaloJet_Jet_sampCalib_cellCleaning): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_cellCleaning"): + super(T2CaloJet_Jet_cellCleaning, self).__init__(name) + class T2CaloJet_Jet_L15 (T2CaloJet_Jet_sampCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_L15"): + super(T2CaloJet_Jet_L15, self).__init__(name) + #self.jetOutputKey = "TrigT2CaloJet" +else: +### Use non-calibrated L2 jets + class T2CaloJet_Jet (T2CaloJet_Jet_noCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet"): + super(T2CaloJet_Jet, self).__init__(name) + class T2CaloJet_Jet_noise (T2CaloJet_Jet_noCalib_noiseCut): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_noise"): + super(T2CaloJet_Jet_noise, self).__init__(name) + class T2CaloJet_Jet_cellCleaning (T2CaloJet_Jet_noCalib_cellCleaning): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_cellCleaning"): + super(T2CaloJet_Jet_cellCleaning, self).__init__(name) + class T2CaloJet_Jet_L15 (T2CaloJet_Jet_noCalib): + __slots__ = [] + def __init__ (self, name="T2CaloJet_Jet_L15"): + super(T2CaloJet_Jet_L15, self).__init__(name) + #self.jetOutputKey = "TrigT2CaloJet" + +### L2 Jets from Front-End Buffers ### + +class T2CaloJet_FEBJet (T2CaloJetBase): + __slots__ = [] + def __init__ (self, name="T2CaloJet_FEBJet"): + super(T2CaloJet_FEBJet, self).__init__(name) + + # here put your customizations + t2calojetconetool = T2CaloJetConeTool() + t2calojetconetool.coneRadius = 0.4 + t2calojetconetool.numberOfIterations = 3 + t2calojetconetool.coneFJRadius=[1.0,0.7,0.4] + + self.EtaWidth = 0.5 + self.PhiWidth = 0.5 + self.clearJetGrid = False + #self.OutputLevel = INFO + + t2sampcalibtool = T2SampCalibTool("T2SampCalibTool_Jet") + t2sampcalibtool.MinEtCut = 1 + t2sampcalibtool.nEtaBin = 50 + t2sampcalibtool.EtRegionLimit = 5000 + #New database tag + t2sampcalibtool.CreateDbObject=False + t2sampcalibtool.ReadFromDB=True + L2CalibFolder = "/CALO/T2CaloCalib/T2CaloJetCalib" + L2CalibTag = "L2JetCalib-10TeV-Ideal-01" + from IOVDbSvc.CondDB import conddb + conddb.addFolder("CALO",L2CalibFolder+"<tag>"+L2CalibTag+"</tag>") + + ############################################################# + ## THESE VALUES ARE NOT USED !!! # + ## ONLY USED AS A REFERENCE FOR WHAT WAS PUT IN THIS DB TAG # + ############################################################# + + t2sampcalibtool.EtaReg=[0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9, + 1.0,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9, + 2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9, + 3.0,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9, + 4.0,4.1,4.2,4.3,4.4,4.5,4.6,4.7,4.8,4.9,5.0] + + t2sampcalibtool.VECut=[ 1.0, 1.00500, 1.02006, 1.04534, 1.08107, + 1.12763, 1.18547, 1.25517, 1.33743, 1.43308, + 1.54308, 1.66852, 1.81065, 1.97091, 2.15090, + 2.35240, 2.57746, 2.82832, 3.10748, 3.41774, + 3.76220, 4.14432, 4.56790, 5.03722, 5.55694, + 6.13228, 6.76900, 7.47346, 8.25272, 9.11458, + 10.0677, 11.1215, 12.2866, 13.5748, 14.9987, + 16.5728, 18.3128, 20.2360, 22.3618, 24.7114, + 27.3082, 30.1784, 33.3507, 36.8567, 40.7316, + 1.0, 1.0, 1.0, 1.0, 1.0] + + t2sampcalibtool.Weights=[ + 1.71736, -0.0775919, 1., 0., + 1.68115, -0.0298649, 1., 0., + 1.72263, -0.0820785, 1., 0., + 1.59158, -0.0349583, 1., 0., + 1.71384, -0.0825993, 1., 0., + 1.56296, -0.0334272, 1., 0., + 1.71196, -0.0823075, 1., 0., + 1.55044, -0.0300373, 1., 0., + 1.73526, -0.0858796, 1., 0., + 1.52924, -0.0275084, 1., 0., + 1.74496, -0.0858104, 1., 0., + 1.61094, -0.032966, 1., 0., + 1.77075, -0.0874956, 1., 0., + 1.69556, -0.0399038, 1., 0., + 1.85845, -0.100017, 1., 0., + 1.63193, -0.0292829, 1., 0., + 1.92108, -0.108746, 1., 0., + 1.60507, -0.0185852, 1., 0., + 1.90991, -0.109427, 1., 0., + 1.73985, -0.0214682, 1., 0., + 1.97429, -0.114934, 1., 0., + 1.49217, -0.0234559, 1., 0., + 1.97011, -0.117122, 1., 0., + 1.40092, -0.0201076, 1., 0., + 1.96164, -0.119639, 1., 0., + 1.63634, -0.0399844, 1., 0., + 1.95562, -0.11617, 1., 0., + 1.81431, -0.0515824, 1., 0., + 1.96964, -0.105079, 1., 0., + 1.86882, -0.0653143, 1., 0., + 2.0155, -0.146639, 1., 0., + 1.60657, -0.00444997, 1., 0., + 1.82239, -0.111195, 1., 0., + 1.69562, -0.0408746, 1., 0., + 1.78718, -0.107874, 1., 0., + 1.6367, -0.0480624, 1., 0., + 1.73745, -0.100309, 1., 0., + 1.54562, -0.0400314, 1., 0., + 1.70874, -0.0979269, 1., 0., + 1.53771, -0.0414734, 1., 0., + 1.68658, -0.0964409, 1., 0., + 1.53234, -0.037261, 1., 0., + 1.62871, -0.0876685, 1., 0., + 1.5901, -0.0464532, 1., 0., + 1.60288, -0.0850231, 1., 0., + 1.51135, -0.0319969, 1., 0., + 1.55495, -0.0760847, 1., 0., + 1.60024, -0.0493416, 1., 0., + 1.61099, -0.0871627, 1., 0., + 1.56848, -0.0372076, 1., 0., + 1.61012, -0.080997, 1., 0., + 1.51628, -0.031721, 1., 0., + 1.5527, -0.0745029, 1., 0., + 1.68515, -0.0610052, 1., 0., + 1.54251, -0.0749989, 1., 0., + 1.75605, -0.0614183, 1., 0., + 1.5972, -0.0847241, 1., 0., + 1.83407, -0.0712398, 1., 0., + 1.63888, -0.085407, 1., 0., + 2.15163, -0.111614, 1., 0., + 1.86924, -0.127399, 1., 0., + 2.04718, -0.021142, 1., 0., + 1.93682, -0.114535, 1., 0., + 2.42857, -0.0398346, 1., 0., + 2.05425, -0.0634181, 1., 0., + 2.31097, -0.17624, 1., 0., + 2.3425, -0.134324, 1., 0., + 1.25573, 0.0160847, 1., 0., + 2.22724, -0.190316, 1., 0., + 1.59135, -0.0403045, 1., 0., + 1.70013, -0.105121, 1., 0., + 2.18796, -0.184129, 1., 0., + 1.46967, -0.0542641, 1., 0., + 1.40854, -0.00397349, 1., 0., + 1.7066, -0.103722, 1., 0., + 2.02067, -0.133273, 1., 0., + 2.3121, -0.244998, 1., 0., + -0.0145766, 0.362844, 1., 0., + 1.62273, -0.0687159, 1., 0., + 2.01868, -0.120886, 1., 0., + 1.07068, 0.0528097, 1., 0., + 3.34939, -0.412248, 1., 0., + 1.18681, 0.0214479, 1., 0., + 0.91684, 0.149364, 1., 0., + 0.377452, 0.214947, 1., 0., + 10.9671, -2.31455, 1., 0., + 2.77778, -0.372772, 1., 0., + -6.52839, 2.00992, 1., 0., + -5.04373, 1.62889, 1., 0., + -9.22444, 2.66876, 1., 0., + #46; Eta range [min,max]: [4.5,4.6] + #NEntries: 413 + 3.33217,-0.26788,1,0, + 3.66022,-0.303515,1,0, + #47; Eta range [min,max]: [4.6,4.7] + #NEntries: 292 + 3.64624,-0.30498,1,0, + 3.732,-0.297252,1,0, + #48; Eta range [min,max]: [4.7,4.8] + #NEntries: 207 + 5.74177,-0.587572,1,0, + 6.30603,-0.649457,1,0, + #49; Eta range [min,max]: [4.8,4.9] + #NEntries: 100 + 6.00682,-0.589085,1,0, + 16.6035,-2.09057,1,0, + #50; Eta range [min,max]: [4.9,5] + #NEntries: 4 + 1.42662,-0.0942826,1,0, + 8.93293,-0.0674104,1,0 + ] + + t2calojetcalibtool = T2CaloJetCalibTool() + t2calojetcalibtool.T2SampCalibTool = t2sampcalibtool + t2calojetcalibtool.UseFebJets = True + t2calojetcalibtool.doJetCalib = False + t2calojetcalibtool.T2JetCorrToolTile1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolFcal1 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Bar = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolHec0 = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolEm3Fwd = t2jescalibtool #dummy config + t2calojetcalibtool.T2JetCorrToolPsBar = t2jescalibtool #dummy config + + t2calojetgridfromfebs = T2CaloJetGridFromFEBHeader() + t2calojetgridfromfebs.doTiming = True + + self.jetOutputKey = "TrigT2CaloFEBJet" + + self.T2JetTools = [t2calojetgridfromfebs, + t2calojetconetool, + t2calojetcalibtool] + + + + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetMonitoring.py b/Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetMonitoring.py new file mode 100755 index 00000000000..1253f57a92e --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/python/TrigT2CaloJetMonitoring.py @@ -0,0 +1,630 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +#Definitions of the monitoring classes + + + +from TrigMonitorBase.TrigGenericMonitoringToolConfig import defineHistogram, TrigGenericMonitoringToolConfig + + +class TrigT2CaloJetValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloJet_Validation"): + super(TrigT2CaloJetValidationMonitoring, self).__init__(name) + + self.defineTarget("Validation") +# this target contains all the histograms necessary for validation + + self.Histograms = [ defineHistogram('dR', type='TH1F', title="L2CaloJet FEX dR between roi and jet ;dR; nevents", xbins=100, xmin=-10., xmax=10.) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="L2CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="L2CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eem', type='TH1F', title="L2CaloJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Ehad', type='TH1F', title="L2CaloJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="L2CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="L2CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="L2CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="L2CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="L2CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + + self.Histograms += [ defineHistogram('Eta,Eem', type='TH2F', title="L2CaloJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Ehad', type='TH2F', title="L2CaloJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + + self.Histograms += [ defineHistogram('Eta,Etem', type='TH2F', title="L2CaloJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Ethad', type='TH2F', title="L2CaloJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Etem', type='TH2F', title="L2CaloJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Ethad', type='TH2F', title="L2CaloJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="L2CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="L2CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram ('ConversionErrors' ,type='TH1F',title='Conversion Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram ('Eta, ConversionErrors' ,type='TH2F',title='ConversionErrors vs Eta;#eta; Conversion Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + self.Histograms += [ defineHistogram ('Phi, ConversionErrors' ,type='TH2F',title='ConversionErrors vs Phi;#phi; Conversion Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2CaloJetOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloJet_Online"): + """ defines hisograms for online """ + super(TrigT2CaloJetOnlineMonitoring, self).__init__(name) + + self.defineTarget("Online") +# right now this target has the same list of histograms as "Validation" + + self.Histograms = [ defineHistogram('dR', type='TH1F', title="L2CaloJet FEX dR between roi and jet ;dR; nevents", xbins=100, xmin=-10., xmax=10.) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="L2CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="L2CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eem', type='TH1F', title="L2CaloJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Ehad', type='TH1F', title="L2CaloJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="L2CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="L2CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="L2CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="L2CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="L2CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Eem', type='TH2F', title="L2CaloJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Ehad', type='TH2F', title="L2CaloJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Etem', type='TH2F', title="L2CaloJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Ethad', type='TH2F', title="L2CaloJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Etem', type='TH2F', title="L2CaloJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Ethad', type='TH2F', title="L2CaloJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="L2CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="L2CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram ('ConversionErrors' ,type='TH1F',title='Conversion Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram ('Eta, ConversionErrors' ,type='TH2F',title='ConversionErrors vs Eta;#eta; Conversion Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + self.Histograms += [ defineHistogram ('Phi, ConversionErrors' ,type='TH2F',title='ConversionErrors vs Phi;#phi; Conversion Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2CaloJetCosmicMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloJet_Cosmic"): + """ defines hisograms for online """ + super(TrigT2CaloJetCosmicMonitoring, self).__init__(name) + + self.defineTarget("Cosmic") +# this target contains the same list of histograms as for "Online", but the axis range for plots of Et and etc. are smaller + + self.Histograms = [ defineHistogram('dR', type='TH1F', title="L2CaloJet FEX dR between roi and jet ;dR; nevents", xbins=100, xmin=-10., xmax=10.) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="L2CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=300000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="L2CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=300000.) ] + self.Histograms += [ defineHistogram('Eem', type='TH1F', title="L2CaloJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=300000.) ] + self.Histograms += [ defineHistogram('Ehad', type='TH1F', title="L2CaloJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=300000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="L2CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="L2CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="L2CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="L2CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=300000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="L2CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=300000.) ] + self.Histograms += [ defineHistogram('Eta,Eem', type='TH2F', title="L2CaloJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=300000.) ] + self.Histograms += [ defineHistogram('Eta,Ehad', type='TH2F', title="L2CaloJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=300000.) ] + self.Histograms += [ defineHistogram('Eta,Etem', type='TH2F', title="L2CaloJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Ethad', type='TH2F', title="L2CaloJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Etem', type='TH2F', title="L2CaloJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Ethad', type='TH2F', title="L2CaloJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="L2CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="L2CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram ('ConversionErrors' ,type='TH1F',title='Conversion Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram ('Eta, ConversionErrors' ,type='TH2F',title='ConversionErrors vs Eta;#eta; Conversion Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + self.Histograms += [ defineHistogram ('Phi, ConversionErrors' ,type='TH2F',title='ConversionErrors vs Phi;#phi; Conversion Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2CaloJetTimeMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloJet_TimeUnpack"): + super(TrigT2CaloJetTimeMonitoring, self).__init__(name) + self.defineTarget("Time") + self.Histograms += [ defineHistogram('LArUnpck', type='TH1F', title="L2CaloJet Unpacking time (LAr)", xbins=100, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('TileUnpck', type='TH1F', title="L2CaloJet Unpacking time (Tile)", xbins=100, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('HECUnpck', type='TH1F', title="L2CaloJet Unpacking time (HEC)", xbins=100, xmin=0., xmax=50.) ] + +class TrigT2L1CaloJetValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2L1CaloJet_Validation"): + super(TrigT2L1CaloJetValidationMonitoring, self).__init__(name) + + self.defineTarget("Validation") + # this target contains all the histograms necessary for validation + self.Histograms = [ defineHistogram('nJets', type='TH1F', title="T2L1CaloJet FEX number of jets;N; nevents", xbins=21, xmin=-.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2L1CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2L1CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Eem', type='TH1F', title="T2L1CaloJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Ehad', type='TH1F', title="T2L1CaloJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('nLeadingTowers', type='TH1F', title="T2L1CaloJet FEX nLeadingTowers;nLeadingTowers; nevents", xbins=21, xmin=-0.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('Emf', type='TH1F', title="T2L1CaloJet FEX emf;EMF; nevents", xbins=100, xmin=-0.1, xmax=1.1) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2L1CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2L1CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('nTowers', type='TH1F', title="T2L1CaloJet number of L1 towers;number of L1 towers; nevents", xbins=101, xmin=-0.5, xmax=100.5) ] + self.Histograms += [ defineHistogram('UnpckTime', type='TH1F', title="T2L1CaloJet Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('L1_UnpckTime', type='TH1F', title="T2L1CaloJet L1 Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('FastJetTime', type='TH1F', title="T2L1CaloJet FastJet time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('JetFindingTime', type='TH1F', title="T2L1CaloJet Jet finding time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('OverallTime', type='TH1F', title="T2L1CaloJet Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2L1CaloJet RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2L1CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2L1CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2L1CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Eem', type='TH2F', title="T2L1CaloJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Ehad', type='TH2F', title="T2L1CaloJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Etem', type='TH2F', title="T2L1CaloJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Ethad', type='TH2F', title="T2L1CaloJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Etem', type='TH2F', title="T2L1CaloJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Ethad', type='TH2F', title="T2L1CaloJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2L1CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2L1CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nTowers,UnpckTime', type='TH2F', title="T2L1CaloJet Unpack time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,L1_UnpckTime', type='TH2F', title="T2L1CaloJet L1 Unpack time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,FastJetTime', type='TH2F', title="T2L1CaloJet Jet finding time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,JetFindingTime', type='TH2F', title="T2L1CaloJet Jet finding time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,OverallTime', type='TH2F', title="T2L1CaloJet Total time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,RoITime', type='TH2F', title="T2L1CaloJet RoI making time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2L1CaloJetOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2L1CaloJet_Online"): + """ defines hisograms for online """ + super(TrigT2L1CaloJetOnlineMonitoring, self).__init__(name) + + self.defineTarget("Online") + # right now this target has the same list of histograms as "Validation" + self.Histograms = [ defineHistogram('nJets', type='TH1F', title="T2L1CaloJet FEX number of jets;N; nevents", xbins=21, xmin=-.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2L1CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2L1CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Eem', type='TH1F', title="T2L1CaloJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Ehad', type='TH1F', title="T2L1CaloJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('nLeadingTowers', type='TH1F', title="T2L1CaloJet FEX nLeadingTowers;nLeadingTowers; nevents", xbins=21, xmin=-0.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('Emf', type='TH1F', title="T2L1CaloJet FEX emf;EMF; nevents", xbins=100, xmin=-0.1, xmax=1.1) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2L1CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2L1CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('nTowers', type='TH1F', title="T2L1CaloJet number of L1 towers;number of L1 towers; nevents", xbins=101, xmin=-0.5, xmax=100.5) ] + self.Histograms += [ defineHistogram('UnpckTime', type='TH1F', title="T2L1CaloJet Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('L1_UnpckTime', type='TH1F', title="T2L1CaloJet L1 Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('FastJetTime', type='TH1F', title="T2L1CaloJet FastJet time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('JetFindingTime', type='TH1F', title="T2L1CaloJet Jet finding time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('OverallTime', type='TH1F', title="T2L1CaloJet Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2L1CaloJet RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2L1CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2L1CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2L1CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Eem', type='TH2F', title="T2L1CaloJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Ehad', type='TH2F', title="T2L1CaloJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Etem', type='TH2F', title="T2L1CaloJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Ethad', type='TH2F', title="T2L1CaloJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Etem', type='TH2F', title="T2L1CaloJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Ethad', type='TH2F', title="T2L1CaloJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2L1CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2L1CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nTowers,UnpckTime', type='TH2F', title="T2L1CaloJet Unpack time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,L1_UnpckTime', type='TH2F', title="T2L1CaloJet L1 Unpack time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,FastJetTime', type='TH2F', title="T2L1CaloJet Jet finding time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,JetFindingTime', type='TH2F', title="T2L1CaloJet Jet finding time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,OverallTime', type='TH2F', title="T2L1CaloJet Total time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,RoITime', type='TH2F', title="T2L1CaloJet RoI making time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + +class TrigT2L1CaloJetCosmicMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2L1CaloJet_Cosmic"): + """ defines hisograms for online """ + super(TrigT2L1CaloJetCosmicMonitoring, self).__init__(name) + + self.defineTarget("Cosmic") + # this target contains the same list of histograms as for "Online", but the axis range for plots of Et and etc. are smaller + self.Histograms = [ defineHistogram('nJets', type='TH1F', title="T2L1CaloJet FEX number of jets;N; nevents", xbins=21, xmin=-.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2L1CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2L1CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Eem', type='TH1F', title="T2L1CaloJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Ehad', type='TH1F', title="T2L1CaloJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('nLeadingTowers', type='TH1F', title="T2L1CaloJet FEX nLeadingTowers;nLeadingTowers; nevents", xbins=21, xmin=-0.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('Emf', type='TH1F', title="T2L1CaloJet FEX emf;EMF; nevents", xbins=100, xmin=-0.1, xmax=1.1) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2L1CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2L1CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('nTowers', type='TH1F', title="T2L1CaloJet number of L1 towers;number of L1 towers; nevents", xbins=101, xmin=-0.5, xmax=100.5) ] + self.Histograms += [ defineHistogram('UnpckTime', type='TH1F', title="T2L1CaloJet Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('L1_UnpckTime', type='TH1F', title="T2L1CaloJet L1 Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('FastJetTime', type='TH1F', title="T2L1CaloJet FastJet time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('JetFindingTime', type='TH1F', title="T2L1CaloJet Jet finding time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('OverallTime', type='TH1F', title="T2L1CaloJet Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2L1CaloJet RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=200.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2L1CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2L1CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2L1CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Eem', type='TH2F', title="T2L1CaloJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Ehad', type='TH2F', title="T2L1CaloJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Etem', type='TH2F', title="T2L1CaloJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Ethad', type='TH2F', title="T2L1CaloJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Etem', type='TH2F', title="T2L1CaloJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Ethad', type='TH2F', title="T2L1CaloJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2L1CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2L1CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nTowers,UnpckTime', type='TH2F', title="T2L1CaloJet Unpack time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,L1_UnpckTime', type='TH2F', title="T2L1CaloJet L1 Unpack time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,FastJetTime', type='TH2F', title="T2L1CaloJet Jet finding time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,JetFindingTime', type='TH2F', title="T2L1CaloJet Jet finding time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,OverallTime', type='TH2F', title="T2L1CaloJet Total time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + self.Histograms += [ defineHistogram('nTowers,RoITime', type='TH2F', title="T2L1CaloJet RoI making time vs. nTowers;nTowers;time [ms]", xbins=101, xmin=0., xmax=500., ybins=100, ymin=0., ymax=200.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + +class TrigT2L1UnpackingValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2L1Unpacking_Validation"): + super(TrigT2L1UnpackingValidationMonitoring, self).__init__(name) + + self.defineTarget("Validation") + # this target contains all the histograms necessary for validation + self.Histograms += [ defineHistogram('nTowers', type='TH1F', title="T2L1Unpacking number of L1 towers;number of L1 towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nEMTowers', type='TH1F', title="T2L1Unpacking number of L1 EM towers;number of L1 EM towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nHADTowers', type='TH1F', title="T2L1Unpacking number of L1 HAD towers;number of L1 HAD towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nTowers_zoom', type='TH1F', title="T2L1Unpacking number of L1 towers;number of L1 towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('nEMTowers_zoom', type='TH1F', title="T2L1Unpacking number of L1 EM towers;number of L1 EM towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('nHADTowers_zoom',type='TH1F', title="T2L1Unpacking number of L1 HAD towers;number of L1 HAD towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2L1Unpacking FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtEM', type='TH1F', title="T2L1Unpacking FEX Etem;EM Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtHAD', type='TH1F', title="T2L1Unpacking FEX Ethad;Had Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2L1Unpacking FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('EtaEM', type='TH1F', title="T2L1Unpacking FEX EM Eta;EM Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('EtaHAD', type='TH1F', title="T2L1Unpacking FEX HAD Eta;HAD Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2L1Unpacking FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('PhiEM', type='TH1F', title="T2L1Unpacking FEX EM Phi;EM Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('PhiHAD', type='TH1F', title="T2L1Unpacking FEX HAD Phi;HAD Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('L1UnpckTime', type='TH1F', title="T2L1Unpacking L1 unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('UnpckTime', type='TH1F', title="T2L1Unpacking All unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CalibrationTime',type='TH1F', title="T2L1Unpacking Calibration time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2L1Unpacking RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('TotalTime', type='TH1F', title="T2L1Unpacking Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2L1Unpacking phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('EtaEM,PhiEM', type='TH2F', title="T2L1Unpacking EM phi vs. eta;EM #eta;EM #phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('EtaHAD,PhiHAD', type='TH2F', title="T2L1Unpacking HAD phi vs. eta;HAD #eta;HAD #phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2L1Unpacking Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('EtaEM,EtEM', type='TH2F', title="T2L1Unpacking EM E_{T} vs. #eta;EM #eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('EtaHAD,EtHAD', type='TH2F', title="T2L1Unpacking HAD E_{T} vs. #eta;HAD #eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2L1Unpacking Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('PhiEM,EtEM', type='TH2F', title="T2L1Unpacking EM E_{T} vs. #phi;EM #phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416,ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('PhiHAD,EtHAD', type='TH2F', title="T2L1Unpacking HAD E_{T} vs. #phi;HAD #phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416,ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nTowers,L1UnpckTime', type='TH2F', title="T2L1Unpacking L1 unpack time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,UnpckTime', type='TH2F', title="T2L1Unpacking All unpack time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,CalibrationTime', type='TH2F', title="T2L1Unpacking Tower calibration time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,RoITime', type='TH2F', title="T2L1Unpacking RoI making time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,TotalTime', type='TH2F', title="T2L1Unpacking Total time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + + +class TrigT2L1UnpackingOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2L1Unpacking_Online"): + """ defines hisograms for online """ + super(TrigT2L1UnpackingOnlineMonitoring, self).__init__(name) + + self.defineTarget("Online") + # right now this target has the same list of histograms as "Validation" + self.Histograms += [ defineHistogram('nTowers', type='TH1F', title="T2L1Unpacking number of L1 towers;number of L1 towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nEMTowers', type='TH1F', title="T2L1Unpacking number of L1 EM towers;number of L1 EM towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nHADTowers', type='TH1F', title="T2L1Unpacking number of L1 HAD towers;number of L1 HAD towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nTowers_zoom', type='TH1F', title="T2L1Unpacking number of L1 towers;number of L1 towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('nEMTowers_zoom', type='TH1F', title="T2L1Unpacking number of L1 EM towers;number of L1 EM towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('nHADTowers_zoom',type='TH1F', title="T2L1Unpacking number of L1 HAD towers;number of L1 HAD towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2L1Unpacking FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtEM', type='TH1F', title="T2L1Unpacking FEX Etem;EM Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtHAD', type='TH1F', title="T2L1Unpacking FEX Ethad;Had Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2L1Unpacking FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('EtaEM', type='TH1F', title="T2L1Unpacking FEX EM Eta;EM Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('EtaHAD', type='TH1F', title="T2L1Unpacking FEX HAD Eta;HAD Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2L1Unpacking FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('PhiEM', type='TH1F', title="T2L1Unpacking FEX EM Phi;EM Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('PhiHAD', type='TH1F', title="T2L1Unpacking FEX HAD Phi;HAD Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('L1UnpckTime', type='TH1F', title="T2L1Unpacking L1 unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('UnpckTime', type='TH1F', title="T2L1Unpacking All unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CalibrationTime',type='TH1F', title="T2L1Unpacking Calibration time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2L1Unpacking RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('TotalTime', type='TH1F', title="T2L1Unpacking Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2L1Unpacking phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('EtaEM,PhiEM', type='TH2F', title="T2L1Unpacking EM phi vs. eta;EM #eta;EM #phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('EtaHAD,PhiHAD', type='TH2F', title="T2L1Unpacking HAD phi vs. eta;HAD #eta;HAD #phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2L1Unpacking Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('EtaEM,EtEM', type='TH2F', title="T2L1Unpacking EM E_{T} vs. #eta;EM #eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('EtaHAD,EtHAD', type='TH2F', title="T2L1Unpacking HAD E_{T} vs. #eta;HAD #eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2L1Unpacking Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('PhiEM,EtEM', type='TH2F', title="T2L1Unpacking EM E_{T} vs. #phi;EM #phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416,ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('PhiHAD,EtHAD', type='TH2F', title="T2L1Unpacking HAD E_{T} vs. #phi;HAD #phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416,ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nTowers,L1UnpckTime', type='TH2F', title="T2L1Unpacking L1 unpack time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,UnpckTime', type='TH2F', title="T2L1Unpacking All unpack time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,CalibrationTime', type='TH2F', title="T2L1Unpacking Tower calibration time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,RoITime', type='TH2F', title="T2L1Unpacking RoI making time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,TotalTime', type='TH2F', title="T2L1Unpacking Total time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + + +class TrigT2L1UnpackingCosmicMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2L1Unpacking_Cosmic"): + """ defines hisograms for online """ + super(TrigT2L1UnpackingCosmicMonitoring, self).__init__(name) + + self.defineTarget("Cosmic") + # this target contains the same list of histograms as for "Online", but the axis range for plots of Et and etc. are smaller + self.Histograms += [ defineHistogram('nEMTowers', type='TH1F', title="T2L1Unpacking number of L1 EM towers;number of L1 EM towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nHADTowers', type='TH1F', title="T2L1Unpacking number of L1 HAD towers;number of L1 HAD towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nTowers', type='TH1F', title="T2L1Unpacking number of L1 towers;number of L1 towers; nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('nTowers_zoom', type='TH1F', title="T2L1Unpacking number of L1 towers;number of L1 towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('nEMTowers_zoom', type='TH1F', title="T2L1Unpacking number of L1 EM towers;number of L1 EM towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('nHADTowers_zoom',type='TH1F', title="T2L1Unpacking number of L1 HAD towers;number of L1 HAD towers; nevents", xbins=50, xmin=0., xmax=50.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2L1Unpacking FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtEM', type='TH1F', title="T2L1Unpacking FEX Etem;EM Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtHAD', type='TH1F', title="T2L1Unpacking FEX Ethad;Had Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2L1Unpacking FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('EtaEM', type='TH1F', title="T2L1Unpacking FEX EM Eta;EM Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('EtaHAD', type='TH1F', title="T2L1Unpacking FEX HAD Eta;HAD Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2L1Unpacking FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('PhiEM', type='TH1F', title="T2L1Unpacking FEX EM Phi;EM Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('PhiHAD', type='TH1F', title="T2L1Unpacking FEX HAD Phi;HAD Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('L1UnpckTime', type='TH1F', title="T2L1Unpacking L1 unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('UnpckTime', type='TH1F', title="T2L1Unpacking All unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CalibrationTime',type='TH1F', title="T2L1Unpacking Calibration time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2L1Unpacking RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('TotalTime', type='TH1F', title="T2L1Unpacking Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2L1Unpacking phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('EtaEM,PhiEM', type='TH2F', title="T2L1Unpacking EM phi vs. eta;EM #eta;EM #phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('EtaHAD,PhiHAD', type='TH2F', title="T2L1Unpacking HAD phi vs. eta;HAD #eta;HAD #phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2L1Unpacking Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('EtaEM,EtEM', type='TH2F', title="T2L1Unpacking EM E_{T} vs. #eta;EM #eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('EtaHAD,EtHAD', type='TH2F', title="T2L1Unpacking HAD E_{T} vs. #eta;HAD #eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2L1Unpacking Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('PhiEM,EtEM', type='TH2F', title="T2L1Unpacking EM E_{T} vs. #phi;EM #phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416,ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('PhiHAD,EtHAD', type='TH2F', title="T2L1Unpacking HAD E_{T} vs. #phi;HAD #phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416,ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nTowers,L1UnpckTime', type='TH2F', title="T2L1Unpacking L1 unpack time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,UnpckTime', type='TH2F', title="T2L1Unpacking All unpack time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,CalibrationTime', type='TH2F', title="T2L1Unpacking Tower calibration time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,RoITime', type='TH2F', title="T2L1Unpacking RoI making time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nTowers,TotalTime', type='TH2F', title="T2L1Unpacking Total time vs. nTowers;nTowers;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + +class TrigT2CaloFastJetValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloFastJet_Validation"): + super(TrigT2CaloFastJetValidationMonitoring, self).__init__(name) + + self.defineTarget("Validation") + # this target contains all the histograms necessary for validation + self.Histograms = [ defineHistogram('nJets', type='TH1F', title="T2CaloFastJet FEX number of jets;N;nevents", xbins=21, xmin=-.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('nGrid', type='TH1F', title="T2CaloFastJet FEX number of inputs;N;nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2CaloFastJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtEM', type='TH1F', title="T2CaloFastJet FEX Et EM;Etem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtHAD', type='TH1F', title="T2CaloFastJet FEX Et HAD;Ethad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2CaloFastJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EEM', type='TH1F', title="T2CaloFastJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EHAD', type='TH1F', title="T2CaloFastJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('nLeadingTowers', type='TH1F', title="T2CaloFastJet FEX nLeadingTowers;nLeadingTowers; nevents", xbins=21, xmin=-0.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('Emf', type='TH1F', title="T2CaloFastJet FEX emf;EMF; nevents", xbins=100, xmin=-0.1, xmax=1.1) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2CaloFastJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2CaloFastJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('UnpackTime', type='TH1F', title="T2CaloFastJet Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('FastJetTime', type='TH1F', title="T2CaloFastJet FastJet time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('puSubTime', type='TH1F', title="T2CaloFastJet FastJet pu sub time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CleaningTime', type='TH1F', title="T2CaloFastJet Cleaning time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CalibrationTime', type='TH1F', title="T2CaloFastJet Calibration time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2CaloFastJet RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('TotalTime', type='TH1F', title="T2CaloFastJet Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2CaloFastJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2CaloFastJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EtEM', type='TH2F', title="T2CaloFastJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EtHAD', type='TH2F', title="T2CaloFastJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2CaloFastJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EEM', type='TH2F', title="T2CaloFastJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EHAD', type='TH2F', title="T2CaloFastJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2CaloFastJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2CaloFastJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,EtEM', type='TH2F', title="T2CaloFastJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,EtHAD', type='TH2F', title="T2CaloFastJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nGrid,UnpackTime', type='TH2F', title="T2CaloFastJet Unpack time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,FastJetTime', type='TH2F', title="T2CaloFastJet Jet finding time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,FastJetTime', type='TH2F', title="T2CaloFastJet Jet finding time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,puSubTime', type='TH2F', title="T2CaloFastJet pu subtraction time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,puSubTime', type='TH2F', title="T2CaloFastJet pu subtraction time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,CleaningTime', type='TH2F', title="T2CaloFastJet Jet cleaning time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,CleaningTime', type='TH2F', title="T2CaloFastJet Jet cleaning time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,CalibrationTime', type='TH2F', title="T2CaloFastJet Jet calibration time vs. nJets;nJets;time [ms]",xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,RoITime', type='TH2F', title="T2CaloFastJet RoI making time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,TotalTime', type='TH2F', title="T2CaloFastJet Total time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,TotalTime', type='TH2F', title="T2CaloFastJet Total time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + +class TrigT2CaloFastJetOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloFastJet_Online"): + super(TrigT2CaloFastJetOnlineMonitoring, self).__init__(name) + + self.defineTarget("Online") + # this target contains all the histograms necessary for Online + self.Histograms = [ defineHistogram('nJets', type='TH1F', title="T2CaloFastJet FEX number of jets;N;nevents", xbins=21, xmin=-.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('nGrid', type='TH1F', title="T2CaloFastJet FEX number of inputs;N;nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2CaloFastJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtEM', type='TH1F', title="T2CaloFastJet FEX Et EM;Etem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtHAD', type='TH1F', title="T2CaloFastJet FEX Et HAD;Ethad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2CaloFastJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EEM', type='TH1F', title="T2CaloFastJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EHAD', type='TH1F', title="T2CaloFastJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('nLeadingTowers', type='TH1F', title="T2CaloFastJet FEX nLeadingTowers;nLeadingTowers; nevents", xbins=21, xmin=-0.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('Emf', type='TH1F', title="T2CaloFastJet FEX emf;EMF; nevents", xbins=100, xmin=-0.1, xmax=1.1) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2CaloFastJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2CaloFastJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('UnpackTime', type='TH1F', title="T2CaloFastJet Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('FastJetTime', type='TH1F', title="T2CaloFastJet FastJet time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('puSubTime', type='TH1F', title="T2CaloFastJet FastJet pu sub time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CleaningTime', type='TH1F', title="T2CaloFastJet Cleaning time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CalibrationTime', type='TH1F', title="T2CaloFastJet Calibration time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2CaloFastJet RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('TotalTime', type='TH1F', title="T2CaloFastJet Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2CaloFastJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2CaloFastJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EtEM', type='TH2F', title="T2CaloFastJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EtHAD', type='TH2F', title="T2CaloFastJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2CaloFastJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EEM', type='TH2F', title="T2CaloFastJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EHAD', type='TH2F', title="T2CaloFastJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2CaloFastJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2CaloFastJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,EtEM', type='TH2F', title="T2CaloFastJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,EtHAD', type='TH2F', title="T2CaloFastJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nGrid,UnpackTime', type='TH2F', title="T2CaloFastJet Unpack time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,FastJetTime', type='TH2F', title="T2CaloFastJet Jet finding time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,FastJetTime', type='TH2F', title="T2CaloFastJet Jet finding time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,puSubTime', type='TH2F', title="T2CaloFastJet pu subtraction time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,puSubTime', type='TH2F', title="T2CaloFastJet pu subtraction time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,CleaningTime', type='TH2F', title="T2CaloFastJet Jet cleaning time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,CleaningTime', type='TH2F', title="T2CaloFastJet Jet cleaning time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,CalibrationTime', type='TH2F', title="T2CaloFastJet Jet calibration time vs. nJets;nJets;time [ms]",xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,RoITime', type='TH2F', title="T2CaloFastJet RoI making time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,TotalTime', type='TH2F', title="T2CaloFastJet Total time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,TotalTime', type='TH2F', title="T2CaloFastJet Total time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2CaloFastJetCosmicMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloFastJet_Cosmic"): + super(TrigT2CaloFastJetCosmicMonitoring, self).__init__(name) + + self.defineTarget("Cosmic") + # this target contains all the histograms necessary for Cosmic + self.Histograms = [ defineHistogram('nJets', type='TH1F', title="T2CaloFastJet FEX number of jets;N;nevents", xbins=21, xmin=-.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('nGrid', type='TH1F', title="T2CaloFastJet FEX number of inputs;N;nevents", xbins=100, xmin=0., xmax=1000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2CaloFastJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtEM', type='TH1F', title="T2CaloFastJet FEX Et EM;Etem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EtHAD', type='TH1F', title="T2CaloFastJet FEX Et HAD;Ethad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2CaloFastJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EEM', type='TH1F', title="T2CaloFastJet FEX Eem;Eem [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('EHAD', type='TH1F', title="T2CaloFastJet FEX Ehad;Ehad [MeV]; nevents", xbins=100, xmin=0., xmax=100000.) ] + self.Histograms += [ defineHistogram('nLeadingTowers', type='TH1F', title="T2CaloFastJet FEX nLeadingTowers;nLeadingTowers; nevents", xbins=21, xmin=-0.5, xmax=20.5) ] + self.Histograms += [ defineHistogram('Emf', type='TH1F', title="T2CaloFastJet FEX emf;EMF; nevents", xbins=100, xmin=-0.1, xmax=1.1) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2CaloFastJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2CaloFastJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('UnpackTime', type='TH1F', title="T2CaloFastJet Unpacking time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('FastJetTime', type='TH1F', title="T2CaloFastJet FastJet time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('puSubTime', type='TH1F', title="T2CaloFastJet FastJet pu sub time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CleaningTime', type='TH1F', title="T2CaloFastJet Cleaning time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('CalibrationTime', type='TH1F', title="T2CaloFastJet Calibration time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('RoITime', type='TH1F', title="T2CaloFastJet RoI making time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('TotalTime', type='TH1F', title="T2CaloFastJet Total time; time [ms]; nevents", xbins=200, xmin=0., xmax=100.) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2CaloFastJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2CaloFastJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EtEM', type='TH2F', title="T2CaloFastJet EM E_{T} vs. #eta;#eta;E_{T}^{em} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EtHAD', type='TH2F', title="T2CaloFastJet HAD E_{T} vs. #eta;#eta;E_{T}^{had} [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2CaloFastJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EEM', type='TH2F', title="T2CaloFastJet EM ene vs. eta;#eta;Eem [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Eta,EHAD', type='TH2F', title="T2CaloFastJet Had ene vs. eta;#eta;Ehad [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2CaloFastJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2CaloFastJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,EtEM', type='TH2F', title="T2CaloFastJet EM E_{T} vs. #phi;#phi;E_{T}^{em} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('Phi,EtHAD', type='TH2F', title="T2CaloFastJet HAD E_{T} vs. #phi;#phi;E_{T}^{had} [MeV]", xbins=100, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=100000.) ] + self.Histograms += [ defineHistogram('nGrid,UnpackTime', type='TH2F', title="T2CaloFastJet Unpack time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,FastJetTime', type='TH2F', title="T2CaloFastJet Jet finding time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,FastJetTime', type='TH2F', title="T2CaloFastJet Jet finding time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,puSubTime', type='TH2F', title="T2CaloFastJet pu subtraction time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,puSubTime', type='TH2F', title="T2CaloFastJet pu subtraction time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,CleaningTime', type='TH2F', title="T2CaloFastJet Jet cleaning time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,CleaningTime', type='TH2F', title="T2CaloFastJet Jet cleaning time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,CalibrationTime', type='TH2F', title="T2CaloFastJet Jet calibration time vs. nJets;nJets;time [ms]",xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,RoITime', type='TH2F', title="T2CaloFastJet RoI making time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nGrid,TotalTime', type='TH2F', title="T2CaloFastJet Total time vs. nGrid;nGrid;time [ms]", xbins=100, xmin=0., xmax=1000., ybins=100, ymin=0., ymax=100.) ] + self.Histograms += [ defineHistogram('nJets,TotalTime', type='TH2F', title="T2CaloFastJet Total time vs. nJets;nJets;time [ms]", xbins=21, xmin=-.5, xmax=20.5, ybins=100, ymin=0., ymax=100.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + +class TrigT2VirtualL1CaloJetValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2VirtualL1CaloJet_Validation"): + super(TrigT2VirtualL1CaloJetValidationMonitoring, self).__init__(name) + + self.defineTarget("Validation") +# this target contains all the histograms necessary for validation + + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2VirtualL1CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2VirtualL1CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2VirtualL1CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2VirtualL1CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2VirtualL1CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2VirtualL1CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2VirtualL1CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2VirtualL1CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2VirtualL1CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2VirtualL1CaloJetOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2VirtualL1CaloJet_Online"): + """ defines hisograms for online """ + super(TrigT2VirtualL1CaloJetOnlineMonitoring, self).__init__(name) + + self.defineTarget("Online") +# right now this target has the same list of histograms as "Validation" + + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2VirtualL1CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2VirtualL1CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2VirtualL1CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2VirtualL1CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2VirtualL1CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2VirtualL1CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2VirtualL1CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2VirtualL1CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2VirtualL1CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + + +class TrigT2VirtualL1CaloJetCosmicMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2VirtualL1CaloJet_Cosmic"): + """ defines hisograms for online """ + super(TrigT2VirtualL1CaloJetCosmicMonitoring, self).__init__(name) + + self.defineTarget("Cosmic") +# this target contains the same list of histograms as for "Online", but the axis range for plots of Et and etc. are smaller + + self.Histograms += [ defineHistogram('E', type='TH1F', title="T2VirtualL1CaloJet FEX E;E [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Et', type='TH1F', title="T2VirtualL1CaloJet FEX Et;Et [MeV]; nevents", xbins=100, xmin=0., xmax=1000000.) ] + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2VirtualL1CaloJet FEX Eta;Eta; nevents", xbins=100, xmin=-5., xmax=5.) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2VirtualL1CaloJet FEX Phi;Phi; nevents", xbins=64, xmin=-3.1416, xmax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,Phi', type='TH2F', title="T2VirtualL1CaloJet phi vs. eta;#eta;#phi", xbins=100, xmin=-5., xmax=5., ybins=64, ymin=-3.1416, ymax=3.1416) ] + self.Histograms += [ defineHistogram('Eta,E', type='TH2F', title="T2VirtualL1CaloJet ene vs. eta;#eta;ene [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,E', type='TH2F', title="T2VirtualL1CaloJet ene vs. phi;#phi;ene [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Eta,Et', type='TH2F', title="T2VirtualL1CaloJet Et vs. eta;#eta;Et [MeV]", xbins=100, xmin=-5., xmax=5., ybins=100 , ymin=0., ymax=1000000.) ] + self.Histograms += [ defineHistogram('Phi,Et', type='TH2F', title="T2VirtualL1CaloJet Et vs. phi;#phi;Et [MeV]", xbins=64, xmin=-3.1416, xmax=3.1416, ybins=100 , ymin=0., ymax=1000000.) ] + #self.Histograms += [ defineHistogram ('AlgorithmErrors', type='TH1F',title='Algorithm Errors bit mask' ,xbins=10,xmin=0,xmax=10)] + #self.Histograms += [ defineHistogram ('Eta, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Eta;#eta; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=100,xmin=-5.,xmax=5.)] + #self.Histograms += [ defineHistogram ('Phi, AlgorithmErrors' ,type='TH2F',title='AlgorithmErrors vs Phi;#phi; AlgorithmErrors Errors' ,ybins=6,ymin=0,ymax=6,xbins=64,xmin=-3.1416,xmax=3.1416)] + +# T2AllRoiUnpacking histograms [begin] +fexName = "T2AllRoiUnpacking" +hUnpckTime = defineHistogram(varname='UnpckTime', type='TH1F', + title='%s tot unpacking time; time [ms]'%fexName, + xbins=40, xmin=0., xmax=40) +hCellUnpckTime = defineHistogram(varname='CellUnpckTime', type='TH1F', + title='%s unpacking time (addCell only); time [ms]'%fexName, + xbins=50, xmin=0., xmax=10) +hRoITime = defineHistogram(varname='RoITime', type='TH1F', + title='%s time to setup output TE; time [ms]'%fexName, + xbins=50, xmin=0., xmax=10) +hMergeTime = defineHistogram(varname='MergeTime', type='TH1F', + title='%s time to merge the EM cells; time [ms]'%fexName, + xbins=50, xmin=0., xmax=10) +hTotalTime = defineHistogram('TotalTime', type='TH1F', + title='%s Total time; time [ms]; nevents'%fexName, + xbins=100, xmin=0., xmax=100.) +# T2AllRoiUnpacking histograms [end] + +class T2AllRoiUnpackingTimeOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name = "T2AllRoiUnpackingTimeOnlineMonitoring"): + super(T2AllRoiUnpackingTimeOnlineMonitoring, self).__init__(name) + self.defineTarget("Online") + self.Histograms = [hUnpckTime, hCellUnpckTime, hRoITime, hMergeTime, hTotalTime,] + +class T2AllRoiUnpackingTimeValidationMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name = "T2AllRoiUnpackingTimeValidationMonitoring"): + super(T2AllRoiUnpackingTimeValidationMonitoring, self).__init__(name) + self.defineTarget("Validation") + # validation can have additional histograms (online should be the minimal subset) + self.Histograms = [hUnpckTime, hCellUnpckTime, hRoITime, hMergeTime, hTotalTime,] diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet.py b/Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet.py new file mode 100755 index 00000000000..85acbcdbc08 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet.py @@ -0,0 +1,139 @@ +#---------------------------------------------------- +# T2CaloJet options +#---------------------------------------------------- +theApp.Dlls += [ "TrigT2CaloJet" ] + +include( "TrigT2CaloCommon/jobOfragment_TrigT2CaloCommon.py" ) + +#T2CaloJet_g4_L2 = Algorithm( "T2CaloJet_g4_L2" ) +#T2CaloJet_g4_L2.T2JetTools=["T2CaloJetGridFromCells","T2CaloJetConeTool","T2CaloJetCalibTool"] +#T2CaloJet_g4_L2.OutputLevel = INFO +#T2CaloJet_g4_L2.clearJetGrid = False + +# Set up default options (according to Osamu's talk at Trigger&Physics week, March) +# ROI half width in eta x phi: 0.7x0.7 +# Number of iterations = 3 +# Cone radius: R = 0.4 +#T2CaloJet_g4_L2.EtaWidth = 0.7 # Eta half width +#T2CaloJet_g4_L2.PhiWidth = 0.7 # Phi half width + +#T2CaloJet_g4_L2.T2CaloJetConeTool.coneRadius = 0.4; +#T2CaloJet_g4_L2.T2CaloJetConeTool.numberOfIterations = 3; + + +# Monitoring +#include( "TrigJetMonitoring/jobOfragment_TrigT2CaloJetMoni.py" ) + + +# Using CSC calibration. +# Performance described in: +# http://indico.cern.ch/materialDisplay.py?contribId=16&materialId=slides&confId=6198 + +include("TrigT2CaloCalibration/T2SampCalibration_jobOptions.py") + +#T2CaloJet_g4_L2.T2CaloJetCalibTool.CalibToolName = "T2SampCalibTool" + +#T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.nEtaBin = 44 +#T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.EtRegionLimit = 5000 + +#T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.EtaReg=[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.1,4.2,4.3,4.4] + +#T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.VECut=[20, 20.1001, 20.4013, 20.9068, 21.6214, 22.5525, 23.7093, 25.1034, 26.7487, 28.6617, 30.8616, 33.3704, 36.2131, 39.4183, 43.018, 47.0482, 51.5493, 56.5663, 62.1495, 68.3546, 75.2439, 82.8863, 91.3582, 100.744, 111.139, 122.646, 135.38, 149.469, 165.055, 182.292, 201.353, 222.43, 245.733, 271.495, 299.975, 331.456, 366.256, 404.72, 447.236, 494.227, 546.165, 603.569, 667.013, 737.134] + +#Schema of weights specification through jobO +########################################################### +# i -> this is the number of eta bin # +#m_wt[i][0][0],m_wt[i][0][1],m_wt[i][0][2],m_wt[i][0][3], # +#m_wt[i][1][0],m_wt[i][1][1],m_wt[i][0][2],m_wt[i][1][3], # +########################################################### + +#T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.Weights=[ +#1.51389, -0.0895586, 1., 0., +#1.72829, -0.0340167, 1., 0., +#1.49137, -0.0868803, 1., 0., +#1.70548, -0.0337713, 1., 0., +#1.4857, -0.0863495, 1., 0., +#1.72645, -0.0432542, 1., 0., +#1.47319, -0.0812488, 1., 0., +#1.74611, -0.0531648, 1., 0., +#1.48531, -0.0863878, 1., 0., +#1.72056, -0.0471587, 1., 0., +#1.48752, -0.084979, 1., 0., +#1.71981, -0.0444118, 1., 0., +#1.51808, -0.0926553, 1., 0., +#1.74622, -0.0519999, 1., 0., +#1.55659, -0.101366, 1., 0., +#1.71495, -0.01945, 1., 0., +#1.58541, -0.105946, 1., 0., +#1.8069, -0.0353912, 1., 0., +#1.58109, -0.104969, 1., 0., +#1.86016, -0.0246607, 1., 0., +#1.59103, -0.108539, 1., 0., +#1.61592, -0.0223561, 1., 0., +#1.56324, -0.102244, 1., 0., +#1.54431, -0.030708, 1., 0., +#1.56805, -0.110581, 1., 0., +#1.68662, -0.0425636, 1., 0., +#1.5175, -0.0904923, 1., 0., +#1.9283, -0.0795127, 1., 0., +#1.57129, -0.102665, 1., 0., +#1.75441, -0.0341709, 1., 0., +#1.45089, -0.108513, 1., 0., +#1.71627, -0.0184717, 1., 0., +#1.38183, -0.0832477, 1., 0., +#1.68205, -0.0600046, 1., 0., +#1.3759, -0.0820196, 1., 0., +#1.52486, -0.0399448, 1., 0., +#1.3698, -0.0820021, 1., 0., +#1.50279, -0.0339901, 1., 0., +#1.36276, -0.0791147, 1., 0., +#1.47426, -0.0298548, 1., 0., +#1.34213, -0.0787685, 1., 0., +#1.49542, -0.0335057, 1., 0., +#1.34028, -0.0808486, 1., 0., +#1.47619, -0.020763, 1., 0., +#1.29883, -0.0668448, 1., 0., +#1.4767, -0.0266885, 1., 0., +#1.3058, -0.0647559, 1., 0., +#1.56106, -0.055258, 1., 0., +#1.30474, -0.0660207, 1., 0., +#1.53641, -0.0402638, 1., 0., +#1.32559, -0.070272, 1., 0., +#1.52766, -0.0386046, 1., 0., +#1.27423, -0.0582557, 1., 0., +#1.57456, -0.0636291, 1., 0., +#1.27919, -0.0590284, 1., 0., +#1.61072, -0.0685855, 1., 0., +#1.32345, -0.0834648, 1., 0., +#1.62766, -0.0522781, 1., 0., +#1.33869, -0.0813973, 1., 0., +#1.84186, -0.0996512, 1., 0., +#1.43289, -0.116186, 1., 0., +#1.98947, -0.0398448, 1., 0., +#1.35306, -0.0829135, 1., 0., +#2.58078, -0.266127, 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#1., 0., 1., 0., +#] diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet_RomeCalib.py b/Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet_RomeCalib.py new file mode 100755 index 00000000000..a34a7951f0f --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/share/jobOfragment_TrigT2CaloJet_RomeCalib.py @@ -0,0 +1,181 @@ +#---------------------------------------------------- +# T2CaloJet options +#---------------------------------------------------- +theApp.Dlls += [ "TrigT2CaloJet" ] + +include( "TrigT2CaloCommon/jobOfragment_TrigT2CaloCommon.py" ) + +T2CaloJet_g4_L2 = Algorithm( "T2CaloJet_g4_L2" ) +T2CaloJet_g4_L2.T2JetTools=["T2CaloJetGridFromCells","T2CaloJetConeTool","T2CaloJetCalibTool"] +T2CaloJet_g4_L2.OutputLevel = INFO +T2CaloJet_g4_L2.clearJetGrid = False + +# Set up default options (according to Osamu's talk at Trigger&Physics week, March) +# ROI size in eta x phi: 0.7x0.7 +# Number of iterations = 3 +# Cone radius: R = 0.4 +T2CaloJet_g4_L2.EtaWidth = 0.35 # Eta half width +T2CaloJet_g4_L2.PhiWidth = 0.35 # Phi half width + +T2CaloJet_g4_L2.T2CaloJetConeTool.coneRadius = 0.4; +T2CaloJet_g4_L2.T2CaloJetConeTool.numberOfIterations = 3; + +# Adding calibration. +# Performance described in: +# http://indico.cern.ch/getFile.py/access?contribId=25&sessionId=4&resId=0&materialId=slides&confId=5141 + +include("TrigT2CaloCalibration/T2SampCalibration_jobOptions.py") + +T2CaloJet_g4_L2.T2CaloJetCalibTool.CalibToolName = "T2SampCalibTool" +T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.nEtaBin = 44 +T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.EtRegionLimit = 5000 + +T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.EtaReg=[0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3.,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.1,4.2,4.3,4.4] + +T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.VECut=[20, 20.1001, 20.4013, 20.9068, 21.6214, 22.5525, 23.7093, 25.1034, 26.7487, 28.6617, 30.8616, 33.3704, 36.2131, 39.4183, 43.018, 47.0482, 51.5493, 56.5663, 62.1495, 68.3546, 75.2439, 82.8863, 91.3582, 100.744, 111.139, 122.646, 135.38, 149.469, 165.055, 182.292, 201.353, 222.43, 245.733, 271.495, 299.975, 331.456, 366.256, 404.72, 447.236, 494.227, 546.165, 603.569, 667.013, 737.134] + +#Schema of weights specification through jobO +########################################################### +# i -> this is the number of eta bin # +#m_wt[i][0][0],m_wt[i][0][1],m_wt[i][0][2],m_wt[i][0][3], # +#m_wt[i][1][0],m_wt[i][1][1],m_wt[i][0][2],m_wt[i][1][3], # +########################################################### + +T2CaloJet_g4_L2.T2CaloJetCalibTool.T2SampCalibTool.Weights=[ +1.48308, -0.0826528, 0.5, 0.5, +1.42289, -0.0171067, 0.5, 0.5, + +1.45557, -0.0781768, 0.5, 0.5, +1.44633, -0.027712, 0.5, 0.5, + +1.43856, -0.0751478, 0.5, 0.5, +1.45253, -0.0306214, 0.5, 0.5, + +1.43498, -0.0718259, 0.5, 0.5, +1.45168, -0.032742, 0.5, 0.5, + +1.43684, -0.0729862, 0.5, 0.5, +1.49863, -0.048398, 0.5, 0.5, + +1.45232, -0.0772673, 0.5, 0.5, +1.45768, -0.03347, 0.5, 0.5, + +1.47967, -0.0838591, 0.5, 0.5, +1.43648, -0.0286997, 0.5, 0.5, + +1.50318, -0.0855062, 0.5, 0.5, +1.50884, -0.0353893, 0.5, 0.5, + +1.52509, -0.0885095, 0.5, 0.5, +1.52056, -0.032717, 0.5, 0.5, + +1.5283, -0.0951263, 0.5, 0.5, +1.58505, -0.0175355, 0.5, 0.5, + + 1.53577, -0.0941264, 0.5, 0.5, + 1.44049, -0.0297817, 0.5, 0.5, + + 1.54731, -0.103539, 0.5, 0.5, + 1.26273, 0.009096, 0.5, 0.5, + + 1.50927, -0.0939212, 0.5, 0.5, + 1.53218, -0.0516523, 0.5, 0.5, + + 1.53583, -0.0924597, 0.5, 0.5, + 1.57429, -0.0390652, 0.5, 0.5, + + 1.56737, -0.0848132, 0.5, 0.5, + 1.6557, -0.0695771, 0.5, 0.5, + + 1.48189, -0.122748, 0.5, 0.5, + 1.63334, -0.00433293, 0.5, 0.5, + + 1.3956, -0.0938853, 0.5, 0.5, + 1.65188, -0.0527244, 0.5, 0.5, + + 1.39098, -0.0913043, 0.5, 0.5, + 1.50682, -0.0362353, 0.5, 0.5, + + 1.3567, -0.0810333, 0.5, 0.5, + 1.47922, -0.0375228, 0.5, 0.5, + + 1.33288, -0.0776533, 0.5, 0.5, + 1.47069, -0.0322596, 0.5, 0.5, + + 1.29355, -0.067195, 0.5, 0.5, + 1.50526, -0.0458961, 0.5, 0.5, + + 1.27226, -0.0561386, 0.5, 0.5, + 1.51188, -0.0578599, 0.5, 0.5, + + 1.29132, -0.071984, 0.5, 0.5, + 1.41631, -0.0172732, 0.5, 0.5, + + 1.29759, -0.0714317, 0.5, 0.5, + 1.50393, -0.0499248, 0.5, 0.5, + + 1.27971, -0.0677093, 0.5, 0.5, + 1.47009, -0.036954, 0.5, 0.5, + + 1.27665, -0.0625996, 0.5, 0.5, + 1.47138, -0.0381273, 0.5, 0.5, + + 1.28796, -0.0642188, 0.5, 0.5, + 1.45072, -0.0414209, 0.5, 0.5, + + 1.23851, -0.0422229, 0.5, 0.5, + 1.57495, -0.0825966, 0.5, 0.5, + + 1.29582, -0.0643765, 0.5, 0.5, + 1.57768, -0.0887841, 0.5, 0.5, + + 1.37418, -0.116019, 0.5, 0.5, + 1.69627, -0.0531049, 0.5, 0.5, + + 1.3154, -0.0621647, 0.5, 0.5, + 2.28643, -0.265052, 0.5, 0.5, + + 1.28765, -0.0955826, 0.5, 0.5, + 2.76714, -0.109484, 0.5, 0.5, + + # Weights were not extracted for the forward calorimeters. + # don't apply any correction there: + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, + + 1., 0. , 0.5, 0.5, + 1., 0. , 0.5, 0.5, +] + + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/EtaPhiSampleHash.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/EtaPhiSampleHash.cxx new file mode 100644 index 00000000000..f13eeb5f7fa --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/EtaPhiSampleHash.cxx @@ -0,0 +1,84 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigT2CaloJet/EtaPhiSampleHash.h" + +#include "TrigT2CaloJet/HashedTrig3Momentum.h" + +#include "TVector2.h" // Phi_mpi_pi + +#include <iostream> +#include <cmath> // M_PI, fabs + + + +const double EtaPhiSampleHash::kMinEta = -5.0; +const double EtaPhiSampleHash::kMaxEta = +5.0; +const double EtaPhiSampleHash::kMinPhi = -M_PI; +const double EtaPhiSampleHash::kMaxPhi = +M_PI; + +//------------------------------------------------ +EtaPhiSampleHash::EtaPhiSampleHash(const u_short &nEtaBins, const u_short &nPhiBins, + double minEta, double maxEta, + double minPhi, double maxPhi): + + m_minEta(minEta), + m_maxEta(maxEta), + m_minPhi(minPhi), + m_maxPhi(maxPhi), + m_nEtaBins(nEtaBins), + m_nPhiBins(nPhiBins) +{ + checkValues(); + m_dEta = (m_maxEta-m_minEta)/ static_cast<double>(m_nEtaBins); + m_dPhi = (m_maxPhi-m_minPhi)/ static_cast<double>(m_nPhiBins); + m_invDeta = 1.0/m_dEta; + m_invDphi = 1.0/m_dPhi; +} + +//------------------------------------------------ +void EtaPhiSampleHash::checkValues() +{ + using namespace std; + if(m_nEtaBins >= kMaxNetaBins) + cerr<<"EtaPhiSampleHash: number of eta bins too large" + <<" ("<<m_nEtaBins<<" >= "<<kMaxNetaBins<<")"<<endl; + if(m_nPhiBins >= kMaxNphiBins) + cerr<<"EtaPhiSampleHash: number of phi bins too large" + <<" ("<<m_nPhiBins<<" >= "<<kMaxNphiBins<<")"<<endl; +} +//------------------------------------------------ +u_int EtaPhiSampleHash::hash(const double &eta, const double &phi, + const CaloSampling::CaloSample &sample) const +{ + double rPhi = TVector2::Phi_mpi_pi(phi); + if(eta<m_minEta || eta>m_maxEta || rPhi<m_minPhi || rPhi>m_maxPhi){ + std::cerr<<"EtaPhiSampleHash::hash("<<eta<<", phi, "<<sample<<")"<<std::endl + <<"out of bounds: returning 0"<<std::endl; + return 0; + } + return (sample & kSixBits) + + ((int((eta-m_minEta)*m_invDeta) & kTenBits) << 6) + + ((int((phi-m_minPhi)*m_invDphi) & kTenBits) << 16); +} +//------------------------------------------------ +u_int EtaPhiSampleHash::hash(const Trig3Momentum &t3m) const +{ + return hash(t3m.eta(), t3m.phi(), t3m.caloSample()); +} +//------------------------------------------------ +u_int EtaPhiSampleHash::hash(const HashedTrig3Momentum &htm) const +{ + return hash(htm.eta(), htm.phi(), htm.caloSample()); +} + +//------------------------------------------------ +bool EtaPhiSampleHash::etaPhiSample(const u_int &hash, double &eta, double &phi, + CaloSampling::CaloSample &sample) const +{ + sample = static_cast< CaloSampling::CaloSample >(hash & kSixBits); + eta = m_minEta + m_dEta * ((hash >> 6) & kTenBits); + phi = m_minPhi + m_dPhi * ((hash >> 16) & kTenBits); + return true; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/GridsHandler.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/GridsHandler.cxx new file mode 100644 index 00000000000..d0b6b70a2d1 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/GridsHandler.cxx @@ -0,0 +1,72 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigT2CaloJet/GridsHandler.h" + +#include "TrigT2CaloJet/HashedTrig3Momentum.h" + +#include <iostream> + + +GridsHandler::GridsHandler() +{ + using namespace std; + vector< CaloSampling::CaloSample > samples; + vector< size_t > defaultSizes; + // need to ajust the default sizes? (granularity ~0.1) + samples.push_back(CaloSampling::PreSamplerB); defaultSizes.push_back(128); + samples.push_back(CaloSampling::EMB1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::EMB2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::EMB3 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::PreSamplerE); defaultSizes.push_back(128); + samples.push_back(CaloSampling::EME1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::EME2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::EME3 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::HEC0 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::HEC1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::HEC2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::HEC3 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileBar0 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileBar1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileBar2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileGap1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileGap2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileGap3 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileExt0 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileExt1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::TileExt2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::FCAL0 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::FCAL1 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::FCAL2 ); defaultSizes.push_back(128); + samples.push_back(CaloSampling::Unknown ); defaultSizes.push_back(128); + + for(unsigned int iS=0; iS<samples.size(); iS++){ + CaloSampling::CaloSample &sample = samples[iS]; + m_grids[sample] = vector< HashedTrig3Momentum >(0); + m_grids[sample].reserve(defaultSizes[iS]); + } // end for(iS) + + copy(samples.begin(), samples.end(), + back_inserter< vector< CaloSampling::CaloSample> >(m_allSamples)); +} + +//------------------------------------------------ +void clearGrid(CsVmcPair &map){ map.second.clear(); } +//------------------------------------------------ +void GridsHandler::clearAllGrids() +{ + std::for_each(m_grids.begin(), m_grids.end(), clearGrid); +} + +//------------------------------------------------ +Vmc& GridsHandler::grid(const CaloSampling::CaloSample &sample) +{ + return m_grids[sample]; +} +//------------------------------------------------ +void GridsHandler::appendAllGrids(Vt3m &output) const +{ + for(CsVmcMap::const_iterator it=m_grids.begin(); it != m_grids.end(); ++it) + output.insert(output.end(), it->second.begin(), it->second.end()); +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/HashedTrig3Momentum.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/HashedTrig3Momentum.cxx new file mode 100644 index 00000000000..c657566a7f5 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/HashedTrig3Momentum.cxx @@ -0,0 +1,55 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigT2CaloJet/HashedTrig3Momentum.h" + +#include <cmath> // fabs + +HashedTrig3Momentum::HashedTrig3Momentum() : Trig3Momentum(), m_hash(0) {} +//------------------------------------------------ +HashedTrig3Momentum::HashedTrig3Momentum(const Trig3Momentum &t3m, const u_int &hash) : + Trig3Momentum(t3m), m_hash(hash) +{ +} +//------------------------------------------------ +void HashedTrig3Momentum::addE(const double &eta, const double &phi, + const double &energy) +{ + //-dbg-using namespace std; + //-dbg-cout<<"adding ("<<eta<<", "<<phi<<", "<<energy<<") to " + //-dbg- <<" ("<<eta_<<", "<<phi_<<", "<<ene_<<")"<<endl; + updateWeightedCoord(eta, phi, energy); + setE(e() + energy); + //-dbg-cout<<"now ("<<eta_<<", "<<phi_<<", "<<ene_<<")"<<endl; +} +//------------------------------------------------ +void HashedTrig3Momentum::reset() +{ + m_hash = 0; + setE(0.); + setEta(0.); + setPhi(0.); +} +//------------------------------------------------ +void HashedTrig3Momentum::addE(const Trig3Momentum &t3m) +{ + HashedTrig3Momentum::addE(t3m.eta(), t3m.phi(), t3m.e()); +} +//------------------------------------------------ +void HashedTrig3Momentum::updateWeightedCoord(const double &etaVal, + const double &phiVal, + const double &energyVal) +{ + double weightOld(fabs(e())), weightNew(fabs(energyVal)); + double weightTot(weightOld+weightNew); + if(weightTot==0.0){ + setEta(0.5*(eta() + etaVal)); + setPhi(0.5*(phi() + phiVal)); + } else { + double invWeightTot = 1.0 / weightTot; + setEta((eta()*weightOld + etaVal*weightNew) * invWeightTot); + setPhi((phi()*weightOld + phiVal*weightNew) * invWeightTot); + } +} +//------------------------------------------------ diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2AllRoiUnpacking.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2AllRoiUnpacking.cxx new file mode 100644 index 00000000000..6b9f64dc7ae --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2AllRoiUnpacking.cxx @@ -0,0 +1,496 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2AllRoiUnpacking.cxx +// PACKAGE: Trigger/TrigAlgorithms/T2AllRoiUnpacking +// +// AUTHOR: Davide Gerbaudo, gerbaudo@cern.ch +// +// Description: Unpack several L2 calorimeter ROIs and store them in a single output grid. +// Used T2L1Unpacking (by Matthew Tamsett) as a template for this AllTEAlgo. +// ******************************************************************** + +#include "TrigT2CaloJet/T2AllRoiUnpacking.h" +#include "TrigCaloEvent/Trig3Momentum.h" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + +#include <boost/assign/std/vector.hpp> // for 'operator+=()' +#include <boost/foreach.hpp> + +#include <cmath> +#include <algorithm> +#include <iostream> +#include <fstream> + +//-------------------------------------------------------------- +T2AllRoiUnpacking::T2AllRoiUnpacking(const std::string & name, ISvcLocator* pSvcLocator) + : HLT::AllTEAlgo(name, pSvcLocator), + kAllocatedGridCells_(8192), + m_jetOutputKey(""), + m_roiEtaHalfWidth(0.), + m_roiPhiHalfWidth(0.), + m_mergeEmCells(true), + m_tmpGrid(0), + m_ttEmSamplings(0), + m_ttHecSamplings(0), + m_tileSampling(0), + m_prepare(true), + m_tmm(), + m_caloGridFromCellsTool("T2CaloJetGridFromCells",0), + m_retrievedGridTool(false), + m_grid(0), + m_processedRegions(0), + m_overlapRegions(0), + m_log(0), + m_cell_unpacking_timer(0), + m_unpacking_timer(0), + m_RoI_timer(0), + m_merge_timer(0), + m_jet(0), + m_UnpckTime(0.), + m_cellUnpckTime(0.), + m_RoITime(0.), + m_mergeTime(0.) +{ + // unpacking tool + // configurables + declareProperty("GridFromCellsTool", m_caloGridFromCellsTool, "tool used to unpack the grid"); + declareProperty("L2RoiEtaHalfWidth", m_roiEtaHalfWidth = 1.0, "half width in eta of the L2 ROI"); + declareProperty("L2RoiPhiHalfWidth", m_roiPhiHalfWidth = 1.0, "half width in phi of the L2 ROI"); + declareProperty("jetOutputKey", m_jetOutputKey = "T2L1Towers"); + declareProperty("MergeEmCells", m_mergeEmCells = true, "whether EM cells shoud be merged"); + // monitoring + declareMonitoredVariable("UnpckTime", m_UnpckTime); + declareMonitoredVariable("CellUnpckTime", m_cellUnpckTime); + declareMonitoredVariable("RoITime", m_RoITime); + declareMonitoredVariable("MergeTime", m_mergeTime); + +} +//-------------------------------------------------------------- +HLT::ErrorCode T2AllRoiUnpacking::hltInitialize() { + m_log = new MsgStream(msgSvc(), name()); + MsgStream &logStream = *m_log; + + if(logStream.level() <= MSG::INFO) + logStream << MSG::INFO << " Initalizing FEX algorithm: " << name() << endmsg; + + initializeTimers(); + initializeHelperTools(); + + return HLT::OK; +} +//-------------------------------------------------------------- +T2AllRoiUnpacking::~T2AllRoiUnpacking(){ +} + +/* +// Just a functor that allows to use +// T2AllRoiUnpacking::processTriggerElement within for_each +// Right now I cannot use it because processTriggerElement is private. +// Later on I will check whether it's safe to make it public... +// DG Jan2012 +typedef std::vector<Trig3Momentum> Trig3MomentumVec; +struct SingleTeProcessor : + public std::binary_function< T2AllRoiUnpacking, Trig3MomentumVec, HLT::ErrorCode> { + Trig3MomentumVec *grid_; + SingleTeProcessor(Trig3MomentumVec *grid):grid_(grid) {} ; + bool operator() (const T2AllRoiUnpacking &tu, const HLT::TriggerElement *te) { + return tu.processTriggerElement(te, grid_); + } +}; +*/ +//-------------------------------------------------------------- +HLT::ErrorCode T2AllRoiUnpacking::hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& tes_in, + unsigned int type_out) +{ + MsgStream &logStream = *m_log; + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + beforeExecMonitors().ignore(); + // setup what we need (variables and tools) + resetTimers(); + if(!inputIsValid(tes_in)) return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + + // if the input is valid, take _the_ TEVec and process it + const HLT::TEVec &tev = tes_in[0]; + HLT::TriggerElement* outputTE(setupOutputTe(type_out)); + if(m_unpacking_timer) m_unpacking_timer->start(); + // N.B. the ownership of m_grid is passed on to m_jet, and then to outputTE (i.e. no need to delete) + m_grid = new std::vector<Trig3Momentum>(); + m_grid->reserve(kAllocatedGridCells_); + m_processedRegions.clear(); + for(unsigned int iTe=0; iTe<tev.size(); iTe++){ + const HLT::TriggerElement* inputTe = tev[iTe]; + processTriggerElement(inputTe, m_grid); + } // end for(iTe) + if(m_unpacking_timer) m_unpacking_timer->stop(); + logStream<<MSG::DEBUG + <<"Processed "<<tev.size()<<" TriggerElements" + <<" and filled the grid with "<<m_grid->size()<<" cells." + <<endmsg; + // finalize the output and the monitoring variables + { + HLT::ErrorCode stat(finalizeOutput(outputTE)); + if(stat!= HLT::OK) return stat; + } + finalizeAccessories(); + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + afterExecMonitors().ignore(); + return HLT::OK; +} +//-------------------------------------------------------------- +HLT::ErrorCode T2AllRoiUnpacking::hltFinalize() +{ + MsgStream &logStream = *m_log; + if ( logStream.level() <= MSG::DEBUG ) + logStream << MSG::DEBUG << "Finalizing T2AllRoiUnpacking FEX " << name() << endmsg; + + delete m_log; + + return HLT::OK; +} +//-------------------------------------------------------------- +HLT::ErrorCode T2AllRoiUnpacking::processTriggerElement(const HLT::TriggerElement *te, + std::vector<Trig3Momentum>* grid) { + MsgStream &logStream = *m_log; + // sanity check on inputs + if(!te || !grid){ + logStream<<MSG::ERROR + <<"Invalid TriggerElement ("<<te<<") or grid ("<<grid<<") pointers" + <<endmsg; + return HLT::ERROR; + } // end if(!te || !grid) + + // get the (eta,phi) rectangles and overlaps + const TrigRoiDescriptor* roiDescriptor = 0; + HLT::ErrorCode hltStatus = getFeature(te, roiDescriptor); + if(HLT::OK != hltStatus){ + logStream<<MSG::ERROR + <<" Failed to find RoiDescriptor "<<endmsg; + return hltStatus; + } // end if(not OK) + L2CaloRoiBoundsCalculator bcalc(roiDescriptor, m_roiEtaHalfWidth, m_roiPhiHalfWidth); + EtaPhiRectangle l2Roi(bcalc.etaMin(), bcalc.etaMax(), + bcalc.phiMin(), bcalc.phiMax()); + + // determine overlaps and avoid these regions for this TE + m_overlapRegions.clear(); + determineOverlaps(l2Roi); + m_caloGridFromCellsTool->setForbiddenRegions(m_overlapRegions); + + // unpack (see T2CaloJetGridFromCells::addAllCells for the various bits) + if(m_cell_unpacking_timer) m_cell_unpacking_timer->start(); + double etaMin(l2Roi.etaMin()), etaMax(l2Roi.etaMax()); + double phiMin(l2Roi.phiMin()), phiMax(l2Roi.phiMax()); + + StatusCode sc = StatusCode::SUCCESS; + if(!m_mergeEmCells){ + if(m_caloGridFromCellsTool->addAllCells(etaMin, etaMax, + phiMin, phiMax, + grid).isFailure()) + sc = StatusCode::FAILURE; + + } // end if not merge EM + else { + // merge EM + if(m_merge_timer) m_merge_timer->start(); + m_tmpGrid.clear(); + BOOST_FOREACH(int sampling, m_ttEmSamplings){ + if(m_caloGridFromCellsTool->addLArCells(etaMin, etaMax, phiMin, phiMax, + &m_tmpGrid, + TTEM, + sampling, m_prepare).isFailure()) + sc = StatusCode::FAILURE; + } + m_tmm.mergeCells(m_tmpGrid, *grid); + if(m_merge_timer) m_merge_timer->stop(); + + // then just add HEC and Tile + BOOST_FOREACH(int sampling, m_ttHecSamplings){ + if(m_caloGridFromCellsTool->addLArCells(etaMin, etaMax, phiMin, phiMax, + grid, + TTHEC, + sampling, m_prepare).isFailure()) + sc = StatusCode::FAILURE; + } + if(m_caloGridFromCellsTool->addTileCells(etaMin, etaMax, phiMin, phiMax, + grid, + TILE, + m_tileSampling, m_prepare).isFailure()) + sc = StatusCode::FAILURE; + } // end if(m_mergeEmCells) + + if(m_cell_unpacking_timer) m_cell_unpacking_timer->stop(); + if(sc.isFailure()){ + if(logStream.level() <= MSG::DEBUG) + logStream<<MSG::DEBUG + <<" Failure of addCells. Empty grid, or some missing cells! "<<endmsg; + return HLT::ERROR; + } // end if(isFailure) + m_processedRegions.push_back(l2Roi); + return HLT::OK; +} +//---------------------------------------------------------- +bool T2AllRoiUnpacking::initializeTimers(){ + MsgStream &logStream = *m_log; + ITrigTimerSvc *pTimerService=0; + if( service( "TrigTimerSvc", pTimerService).isFailure() + || !pTimerService){ + logStream<<MSG::ERROR + <<name()<<": Unable to locate TrigTimer Service" + <<endmsg; + return false; + } + logStream << MSG::DEBUG << " Adding timers" << endmsg; + //Add timers + m_cell_unpacking_timer = addTimer("cell_unpacking_time"); + m_unpacking_timer = addTimer("unpacking_time"); + m_RoI_timer = addTimer("RoI_time"); + m_merge_timer = addTimer("merge_time"); + return true; +} +//-------------------------------------------------------------- +bool T2AllRoiUnpacking::initializeHelperTools(){ + using namespace boost::assign; + MsgStream &logStream = *m_log; + if ( m_caloGridFromCellsTool.retrieve().isFailure() ) { + logStream << MSG::ERROR << "Failed to retreive CaloGridFromCells tool: " << m_caloGridFromCellsTool << endmsg; + m_retrievedGridTool = false; + return false; + } + m_retrievedGridTool = true; + logStream << MSG::DEBUG << "Retrieved " << m_caloGridFromCellsTool << endmsg; + + // not strictly 'helpers' but have to be initialized too + m_ttEmSamplings += 0,1,2,3; + m_ttHecSamplings += 0,1,2; + m_tmpGrid.reserve(kAllocatedGridCells_); + + return true; +} +//-------------------------------------------------------------- +void T2AllRoiUnpacking::resetTimers(){ + if(m_cell_unpacking_timer) m_cell_unpacking_timer->reset(); + if(m_unpacking_timer) m_unpacking_timer->reset(); + if(m_RoI_timer) m_RoI_timer->reset(); + if(m_merge_timer) m_merge_timer->reset(); +} +//-------------------------------------------------------------- +bool T2AllRoiUnpacking::inputIsValid(const std::vector<std::vector<HLT::TriggerElement*> >& input) const { + MsgStream &logStream = *m_log; + if(logStream.level() <= MSG::DEBUG) + logStream<< MSG::DEBUG << "T2AllRoiUnpacking "<<name()<<"\n" + <<input.size()<<" input trigger elements for T2AllRoiUnpacking" + <<endmsg; + // sanity check on the input + if(1!=input.size()){ + logStream<<MSG::ERROR<<"T2AllRoiUnpacking "<<name()<<"\n" + <<"Error! expected only one vector<TriggerElement> as input,\n" + <<" that should contain the L1 jets." + <<" (got "<<input.size()<<" vectors instead)\n" + <<"Exiting hltExecute." + <<endmsg; + return false; + } // end if(1!=input.size()) + return true; +} +//-------------------------------------------------------------- +HLT::TriggerElement* T2AllRoiUnpacking::setupOutputTe(unsigned int type_out) { + if(m_RoI_timer) m_RoI_timer->start(); + HLT::TriggerElement* outputTE = addRoI(type_out, new TrigRoiDescriptor( true ) ); + outputTE->setActiveState(true); + if(m_RoI_timer) m_RoI_timer->stop(); + return outputTE; +} +//-------------------------------------------------------------- +void T2AllRoiUnpacking::storeTimers(){ + if(m_cell_unpacking_timer) m_cellUnpckTime = m_cell_unpacking_timer->elapsed(); + if(m_unpacking_timer) m_UnpckTime = m_unpacking_timer->elapsed(); + if(m_RoI_timer) m_RoITime = m_RoI_timer->elapsed(); + if(m_merge_timer) m_mergeTime = m_merge_timer->elapsed(); +} +//-------------------------------------------------------------- +HLT::ErrorCode T2AllRoiUnpacking::finalizeOutput(HLT::TriggerElement* outputTE){ + MsgStream &logStream = *m_log; + if(m_RoI_timer) m_RoI_timer->start(); + // N.B. the ownership of m_jet is passed on to outputTE (i.e. no need to delete) + m_jet = new TrigT2Jet(); + m_jet->setGrid(m_grid); + //HLT::ErrorCode stat = attachFeature(outputTE, outJets, m_jetOutputKey); + std::string key = ""; + HLT::ErrorCode stat = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (stat != HLT::OK){ + logStream<<MSG::ERROR + <<" recording of TrigT2Jets into StoreGate failed" + <<endmsg; + return stat; + } + if(m_RoI_timer) m_RoI_timer->stop(); + if(logStream.level() <= MSG::DEBUG) + logStream<<MSG::DEBUG + <<" Unpacking done. "<<name() + <<endmsg; + return stat; +} +//-------------------------------------------------------------- +void T2AllRoiUnpacking::finalizeAccessories(){ + storeTimers(); +} +//-------------------------------------------------------------- + +void T2AllRoiUnpacking::determineOverlaps(const EtaPhiRectangle &l2Roi) +{ + for(unsigned int iR=0; + iR < m_processedRegions.size(); + iR++){ + const EtaPhiRectangle &previous = m_processedRegions[iR]; + EtaPhiRectangle overlap(EtaPhiRectangle::overlappingRectangle(l2Roi,previous)); + if (overlap.area()>0.) m_overlapRegions.push_back(overlap); + } // end for(iR) +} +//-------------------------------------------------------------- + +// M_PI is defined in cmath. + +EtaPhiRectangle::EtaPhiRectangle(const double &etaMin, const double &etaMax, + const double &phiMin, const double &phiMax){ + m_etaMin = etaMin; + m_etaMax = etaMax; + m_phiMin = phiMin; + m_phiMax = phiMax; + m_wrapsAroundPi = std::abs(m_phiMax-m_phiMin) > M_PI; + computeCenterCoord(); +} +//-------------------------------------------------------------- +bool EtaPhiRectangle::contains(const EtaPhiPoint &point) const { + return ((fabs(point.first - m_etaCen) < m_etaHw) + && fabs(phi_mpi_pi(point.second - m_phiCen)) < m_phiHw); +} +//-------------------------------------------------------------- +void EtaPhiRectangle::computeCenterCoord(){ + m_etaCen = 0.5*(m_etaMin + m_etaMax); + // this takes care of the 2pi wrap + m_phiCen = atan2(sin(m_phiMin) + sin(m_phiMax), + cos(m_phiMin) + cos(m_phiMax)); + m_etaHw = 0.5*fabs(m_etaMax - m_etaMin); + m_phiHw = 0.5*fabs(phi_mpi_pi(m_phiMax - m_phiMin)); +} +//-------------------------------------------------------------- +double EtaPhiRectangle::phi_mpi_pi(const double &val) { + double value(val); + while(value <= -M_PI) value += 2.*M_PI; + while(value > +M_PI) value -= 2.*M_PI; + return value; +} +//-------------------------------------------------------------- +double EtaPhiRectangle::phi_zero_2pi(const double &val) { + double value(val); + while(value <= 0. ) value += 2.*M_PI; + while(value > 2.*M_PI) value -= 2.*M_PI; + return value; +} +//-------------------------------------------------------------- +double EtaPhiRectangle::overlappingArea(const EtaPhiRectangle &lhs, + const EtaPhiRectangle &rhs) { + // this is duplicated...we should just use EtaPhiRectangle::overlappingRectangle().area() + double etaOverlap(0.), phiOverlap(0.); + double deltaEta12(fabs(lhs.eta() - rhs.eta())); + double totHalfEtaWidth(lhs.etaHalfWidth() + rhs.etaHalfWidth()); + double deltaPhi12(fabs(phi_mpi_pi(lhs.phi() - rhs.phi()))); + double totHalfPhiWidth(lhs.phiHalfWidth() + rhs.phiHalfWidth()); + if (deltaEta12 < totHalfEtaWidth) + etaOverlap = totHalfEtaWidth - deltaEta12; + if (deltaPhi12 < totHalfPhiWidth) + phiOverlap = totHalfPhiWidth - deltaPhi12; + return etaOverlap * phiOverlap; +} +//-------------------------------------------------------------- +EtaPhiRectangle EtaPhiRectangle::overlappingRectangle(const EtaPhiRectangle &lhs, + const EtaPhiRectangle &rhs) { + double etaOverlap(0.), phiOverlap(0.); + double deltaEta12(fabs(lhs.eta() - rhs.eta())); + double totHalfEtaWidth(lhs.etaHalfWidth() + rhs.etaHalfWidth()); + double deltaPhi12(fabs(phi_mpi_pi(lhs.phi() - rhs.phi()))); + double totHalfPhiWidth(lhs.phiHalfWidth() + rhs.phiHalfWidth()); + if (deltaEta12 < totHalfEtaWidth) + etaOverlap = totHalfEtaWidth - deltaEta12; + if (deltaPhi12 < totHalfPhiWidth) + phiOverlap = totHalfPhiWidth - deltaPhi12; + double etaAvg(0.5*(lhs.eta() + rhs.eta())); + double phiAvg(atan2(sin(lhs.phi()) + sin(rhs.phi()), + cos(lhs.phi()) + cos(rhs.phi()))); + + EtaPhiRectangle res(etaAvg-0.5*etaOverlap, etaAvg+0.5*etaOverlap, + phiAvg-0.5*phiOverlap, phiAvg+0.5*phiOverlap); + /* + using std::ofstream; + using std::endl; + ofstream outFile; + std::string fileName("overlap_check.txt"); + string marker(""); + if(res.area()>0.) marker = " <<<<<<<<<<<<< "; + outFile.open(fileName.c_str(), std::ios::app); + outFile<<"Checking the overlap between "<<endl + <<lhs<<endl<<rhs + <<" result: "<<res<<" (area "<<res.area() + <<" = " + <<2.0*res.etaHalfWidth()<<" x " + <<2.0*res.phiHalfWidth()<<")" + <<marker<<endl; + outFile.close(); + */ + return res; +} + +//-------------------------------------------------------------- +void EtaPhiRectangle::print(std::ostream& stream) const { + stream<<"eta ["<<m_etaMin<<", "<<m_etaMax<<"], phi ["<<m_phiMin<<", "<<m_phiMax<<"]"; +} +//-------------------------------------------------------------- +std::ostream& operator<< (std::ostream& stream, const EtaPhiRectangle &epr) { + epr.print(stream); + return stream; +} +//-------------------------------------------------------------- +L2CaloRoiBoundsCalculator::L2CaloRoiBoundsCalculator(const TrigRoiDescriptor* trd, + const double &etaHalfWidth, + const double &phiHalfWidth): + m_etaMin(0.), + m_etaMax(0.), + m_phiMin(0.), + m_phiMax(0.), + m_roiEtaLimit(4.8), + m_fcalEtaMin(3.0), + m_fcalEtaMax(5.0), + m_minFcalEtaCenter(3.2) { + computeBounds(trd, etaHalfWidth, phiHalfWidth); +} +//-------------------------------------------------------------- +void L2CaloRoiBoundsCalculator::computeBounds(const TrigRoiDescriptor* trd, + const double &etaHalfWidth, + const double &phiHalfWidth) { + if(!trd){ + std::cerr<<"L2CaloRoiBoundsCalculator::computeBounds: invalid TrigRoiDescriptor ptr"<<std::endl; + return; + } + // DG Jan2012: I don't know why here they used (0, 2pi]...keeping it just for consistency + m_etaMin = std::max(-1.0 * m_roiEtaLimit, trd->eta() - etaHalfWidth); + m_etaMax = std::min( 1.0 * m_roiEtaLimit, trd->eta() + etaHalfWidth); + m_phiMin = EtaPhiRectangle::phi_zero_2pi(trd->phi() - phiHalfWidth); + m_phiMax = EtaPhiRectangle::phi_zero_2pi(trd->phi() + phiHalfWidth); + //Look at RoIs in FCal + if(fabs(trd->eta()) > m_minFcalEtaCenter){ + if(trd->eta() < -m_minFcalEtaCenter){ + m_etaMin = -m_fcalEtaMax; + m_etaMax = -m_fcalEtaMin; + } + if(trd->eta() > +m_minFcalEtaCenter){ + m_etaMin = m_fcalEtaMin; + m_etaMax = m_fcalEtaMax; + } + } +} +//-------------------------------------------------------------- diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloFastJet.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloFastJet.cxx new file mode 100644 index 00000000000..a85e73691fb --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloFastJet.cxx @@ -0,0 +1,824 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloFastJet.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett, tamsett@cern.ch +// +// Description: Level 2 FastJet FEX algorithm. +// ******************************************************************** +#include "TrigT2CaloJet/T2CaloFastJet.h" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigCaloEvent/TrigT2JetContainer.h" +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + +#include <algorithm> +#include <iterator> + +T2CaloFastJet::T2CaloFastJet(const std::string & name, ISvcLocator* pSvcLocator) + : HLT::AllTEAlgo(name, pSvcLocator), + m_cellMinEnergy(0.), + m_tools(this), + m_pTimerService(0), + //m_total_timer(0), + m_unpack_timer(0), + m_fastjet_timer(0), + m_pu_subtraction_timer(0), + m_cleaning_timer(0), + m_calibration_timer(0), + m_RoI_timer(0), + m_jet_def(0), + m_cluster_sequence(0), + m_pu_cluster_sequence(0), + m_pu_area_cluster_sequence(0), + m_jet(0) +{ + // configurables + declareProperty("jetInputKey", m_jetInputKey = "T2L1Towers"); + declareProperty("jetOutputKey", m_jetOutputKey = "TrigT2CaloJet"); + declareProperty("distanceParameter", m_distanceParameter = 0.4); + declareProperty("pTmin", m_pTmin = 10000.); + declareProperty("inputType", m_inputType = 1); + declareProperty("outputType", m_outputType = 1); + declareProperty("T2JetTools", m_tools, "list of Jet tools"); + declareProperty("cellMinEnergy", m_cellMinEnergy=0.0); + // cleaning: + declareProperty("doCleaning", m_doCleaning = false); + declareProperty("doT2L1Cleaning", m_doT2L1Cleaning = true); + declareProperty("cellQualityThresholdLAr", m_cellQualityThresholdLAr = 4000); + declareProperty("leadingCellFraction", m_leadingCellFraction = 0.9); // for jet cleaning, e.g.: n90 -> leadingCellFraction = 0.9 + // navigation + declareProperty("writeMultipleOutputTEs", m_writeMultipleOutputTEs = false); + declareProperty("secondOutputType", m_secondOutputType = 0); + + // pileup subtraction + declareProperty("doPileupSubtraction", m_doPileupSubtraction = false); + + // monitoring + //declareMonitoredVariable("OverallTime", m_TotalTime); + declareMonitoredVariable("UnpackTime", m_UnpackTime); + declareMonitoredVariable("FastJetTime", m_FastJetTime); + declareMonitoredVariable("puSubTime", m_puSubTime); + declareMonitoredVariable("CleaningTime", m_CleaningTime); + declareMonitoredVariable("CalibrationTime",m_CalibrationTime); + declareMonitoredVariable("RoITime", m_RoITime); + declareMonitoredVariable("nJets", m_nJets); + declareMonitoredVariable("nGrid", m_nGrid); + declareMonitoredStdContainer("Et", m_et); + declareMonitoredStdContainer("EtEM", m_et_em); + declareMonitoredStdContainer("EtHAD", m_et_had); + declareMonitoredStdContainer("E", m_e); + declareMonitoredStdContainer("EEM", m_e_em); + declareMonitoredStdContainer("EHAD", m_e_had); + declareMonitoredStdContainer("Eta", m_eta); + declareMonitoredStdContainer("Phi", m_phi); + declareMonitoredStdContainer("Emf", m_em_frac); + declareMonitoredStdContainer("nLeadingTowers", m_nLeadingTowers); +} + +HLT::ErrorCode T2CaloFastJet::hltInitialize() +{ + m_log = new MsgStream(msgSvc(), name()); + + if((*m_log).level() <= MSG::INFO){ + (*m_log) << MSG::INFO << " Initalizing FEX algorithm: " << name() << endmsg; + (*m_log) << MSG::DEBUG << "Options: " << endmsg; + (*m_log) << MSG::DEBUG << " distanceParameter: " << m_distanceParameter << endmsg; + (*m_log) << MSG::DEBUG << " pTmin: " << m_pTmin << endmsg; + (*m_log) << MSG::DEBUG << " doCleaning: " << m_doCleaning << endmsg; + (*m_log) << MSG::DEBUG << " doT2L1Cleaning: " << m_doT2L1Cleaning << endmsg; + (*m_log) << MSG::DEBUG << " leadingCellFraction: " << m_leadingCellFraction << endmsg; + (*m_log) << MSG::DEBUG << " cellQualityThresholdLAr: " << m_cellQualityThresholdLAr << endmsg; + (*m_log) << MSG::DEBUG << " input type: " << m_inputType << endmsg; + (*m_log) << MSG::DEBUG << " output type: " << m_outputType << endmsg; + (*m_log) << MSG::DEBUG << " write multiple TEs: " << m_writeMultipleOutputTEs << endmsg; + (*m_log) << MSG::DEBUG << " secondary output type: " << m_secondOutputType << endmsg; + (*m_log) << MSG::DEBUG << " do pileup subtraction: " << m_doPileupSubtraction << endmsg; + + } + + // initalise T2L1 helper tools + m_t2l1_tools = T2L1Tools(); + + // Create helper tools + if ( m_tools.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_tools << endmsg; + } else { + (*m_log) << MSG::INFO << "Retrieved " << m_tools << endmsg; + } + + // Initialize timing service + if( service( "TrigTimerSvc", m_pTimerService).isFailure() ) { + (*m_log) << MSG::WARNING << name() << ": Unable to locate TrigTimer Service" << endmsg; + } + + if (m_pTimerService){ + (*m_log) << MSG::DEBUG << "Adding timers" << endmsg; + //Add timers + //m_total_timer = addTimer("total_time"); + m_unpack_timer = addTimer("unpack_time"); + m_fastjet_timer = addTimer("fastjet_time"); + m_pu_subtraction_timer = addTimer("pu_subtraction_time"); + m_cleaning_timer = addTimer("cleaing_time"); + m_calibration_timer = addTimer("calibration_time"); + m_RoI_timer = addTimer("roi_time"); + } + + // initialise fast jet + m_particles.reserve(100); + m_constituents.reserve(100); + m_jets.reserve(100); + + (*m_log) << MSG::INFO << "Setting up fastjet jet definition" << endmsg; + m_jet_def = new fastjet::JetDefinition(fastjet::antikt_algorithm, m_distanceParameter); // this should be made configurable in the future + // dummy call to fast jet so it's internal initalize methods are set (and we don't print the banner during execute) + (*m_log) << MSG::INFO << "Making dummy call to fast jet cluster sequence" << endmsg; + m_particles.clear(); + m_cluster_sequence = new fastjet::ClusterSequence(m_particles, *m_jet_def); + delete m_cluster_sequence; + // pileup subtraction + if (m_doPileupSubtraction) { + (*m_log) << MSG::INFO << "Setting up fastjet pileup subtraction" << endmsg; + // define the jet algorithm + double ktRadius(0.4); + m_pu_jet_def = new fastjet::JetDefinition(fastjet::kt_algorithm,ktRadius,fastjet::E_scheme,fastjet::Best); + // define jet area algorithm + m_pu_area_def = new fastjet::AreaDefinition(fastjet::VoronoiAreaSpec(0.9)); + } + + // cleaning + m_cellenergies.reserve(100); + + // monitored vectors + m_et.reserve(100); + m_et_em.reserve(100); + m_et_had.reserve(100); + m_e.reserve(100); + m_e_em.reserve(100); + m_e_had.reserve(100); + m_eta.reserve(100); + m_phi.reserve(100); + m_em_frac.reserve(100); + m_nLeadingTowers.reserve(100); + + return HLT::OK; +} + +T2CaloFastJet::~T2CaloFastJet(){ +} + + +HLT::ErrorCode T2CaloFastJet::hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& tes_in, + unsigned int type_out) +{ + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + beforeExecMonitors().ignore(); + + // ==== pre-execute setup + if(doTiming()) { + //m_total_timer->reset(); + m_unpack_timer->reset(); + m_fastjet_timer->reset(); + m_pu_subtraction_timer->reset(); + m_cleaning_timer->reset(); + m_calibration_timer->reset(); + m_RoI_timer->reset(); + //m_total_timer->start(); + } + m_particles.clear(); + m_constituents.clear(); + m_jets.clear(); + m_nJets = -99; + m_nGrid = -99; + //m_TotalTime = -99; + m_UnpackTime = -99; + m_FastJetTime = -99; + m_CleaningTime = -99; + m_CalibrationTime = -99; + m_RoITime = -99; + m_et.clear(); + m_et_em.clear(); + m_et_had.clear(); + m_e.clear(); + m_e_em.clear(); + m_e_had.clear(); + m_eta.clear(); + m_phi.clear(); + m_em_frac.clear(); + m_nLeadingTowers.clear(); + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "================= Executing T2CaloFastJet FEX " << name() << endmsg; + + } +#endif + + // === get the input particles + //HLT::TriggerElement* seednode(0); + const TrigT2Jet* inputGrid(0); + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << tes_in.size() << " input TEs found" << endmsg; + } +#endif + // error check, we should only have a single input TE + if ( tes_in.size() != 1 ) { + msg() << MSG::WARNING << "Got more than one input TE" << endmsg; + afterExecMonitors().ignore(); + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN, HLT::Reason::USERDEF_1); + } + + for ( unsigned type = 0; type < tes_in.size(); ++ type ) { + std::vector<HLT::TriggerElement*>& tes = tes_in.at(type); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " - TE[" << type << "]: " << tes.size() << " sub TEs found" << endmsg; + } +#endif + // error check, we should only have a single sub TE + if ( tes.size() != 1 ) { + msg() << MSG::WARNING << "Got more than one sub TE" << endmsg; + afterExecMonitors().ignore(); + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN, HLT::Reason::USERDEF_1); + } + + for ( unsigned teIdx = 0; teIdx < tes.size(); ++teIdx ) { + HLT::ErrorCode ec = getFeature(tes.at(teIdx), inputGrid, m_jetInputKey); + //seednode = tes.at(teIdx); + if(ec!=HLT::OK) { + (*m_log) << MSG::WARNING << "Failed to get the input particles" << endmsg; + return ec; + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " - A total of " << inputGrid->grid()->size() << " particles found in this TE" << endmsg; + } +#endif + } // end of loop on sub TEs + } // end of loop on TEs + + const std::vector<Trig3Momentum>* grid = inputGrid->grid(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "A total of " << grid->size() << " particles are to be clustered" << endmsg; + } +#endif + + // === Unpack the grid + if(doTiming()) m_unpack_timer->start(); + std::vector<Trig3Momentum>::const_iterator begin_grid, begin_grid_fixed, end_grid; + begin_grid = grid->begin(); + begin_grid_fixed = grid->begin(); + end_grid = grid->end(); + int jet_counter = 0; + for (; begin_grid != end_grid; ++begin_grid){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Trig3Momentum[" << jet_counter + << "]: Et: " << begin_grid->e()/cosh(begin_grid->eta()) + << " MeV, eta: " << begin_grid->eta() + << ", phi: " << begin_grid->phi() + << ", sampling: " << std::hex << begin_grid->caloSample() << std::dec << endmsg; + } +#endif + + // now fill fast jet particles + double energy(begin_grid->e()); + if(energy<m_cellMinEnergy) continue; + double eta(begin_grid->eta()); + double phi(begin_grid->phi()); + double transverse_energy = energy/cosh(eta); + double px = transverse_energy*cos(phi); + double py = transverse_energy*sin(phi); + double pz = transverse_energy*sinh(eta); + + fastjet::PseudoJet pseudo_jet( px, py, pz, energy); + pseudo_jet.set_user_index(std::distance(begin_grid_fixed, begin_grid)); + m_particles.push_back( pseudo_jet ); + + jet_counter++; + } + m_nGrid = grid->size(); + if(doTiming()) m_unpack_timer->stop(); + + // === Run fast jet + if(doTiming()) m_fastjet_timer->start(); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "=== Performing jet finding " << endmsg; + } +#endif + // run the clustering, extract the jets + m_cluster_sequence = 0; + m_pu_cluster_sequence = 0; + if (m_doPileupSubtraction){ + m_pu_cluster_sequence = new fastjet::ClusterSequenceArea(m_particles, *m_jet_def, *m_pu_area_def); + m_jets = fastjet::sorted_by_pt(m_pu_cluster_sequence->inclusive_jets(m_pTmin)); // sorted by decreasing pt + } else { + m_cluster_sequence = new fastjet::ClusterSequence(m_particles, *m_jet_def); + m_jets = fastjet::sorted_by_pt(m_cluster_sequence->inclusive_jets(m_pTmin)); // sorted by decreasing pt + } + + //std::reverse(m_jets.begin(),m_jets.end()); // sorted by increasing pt + m_nJets = m_jets.size(); + if(doTiming()) m_fastjet_timer->stop(); + + // pileup subtraction + if(doTiming()) m_pu_subtraction_timer->start(); + if (m_doPileupSubtraction){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "=== Performing pileup subtraction jet finding " << endmsg; + } +#endif + m_pu_area_cluster_sequence = 0; + m_pu_area_cluster_sequence = new fastjet::ClusterSequenceArea(m_particles, *m_pu_jet_def, *m_pu_area_def); + // get rho in central eta range + m_rho = 0.; + m_sigma = 0.; + m_area = 0.; + fastjet::RangeDefinition etaRange(-2.,2.); + m_pu_area_cluster_sequence->get_median_rho_and_sigma(etaRange,false,m_rho,m_sigma,m_area); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " completed pileup subtraction jet finding" << endmsg; + (*m_log) << MSG::DEBUG << " median rho: " << m_rho << endmsg; + (*m_log) << MSG::DEBUG << " median sigma: " << m_sigma << endmsg; + (*m_log) << MSG::DEBUG << " area: " << m_area << endmsg; + + } +#endif + } + if(doTiming()) m_pu_subtraction_timer->pause(); + + // === Store output + if(doTiming()) m_RoI_timer->start(); + std::string key = ""; + HLT::TriggerElement* outputTE = 0; + if (!m_writeMultipleOutputTEs){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Writing all jets to a single output TE" << endmsg; + } +#endif + outputTE = addRoI(type_out, new TrigRoiDescriptor(true)); // make a single output TE + outputTE->setActiveState(true); + } else { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Writing each jet to it's own output TE" << endmsg; + } +#endif + } + int recorded_jet_counter = 0; + + + + // inspect the output jets, compute some cleaning variables then store +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Found "<< m_jets.size() << " jets " << endmsg; + if (m_jets.size()) (*m_log) << MSG::DEBUG << "== Resultant jets " << endmsg; + } +#endif + for (unsigned i = 0; i < m_jets.size(); ++i) { + if (m_doPileupSubtraction){ + m_constituents = fastjet::sorted_by_pt(m_pu_cluster_sequence->constituents(m_jets[i])); + } else { + m_constituents = fastjet::sorted_by_pt(m_cluster_sequence->constituents(m_jets[i])); + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " fastjet jet [" << i + << "]: Et: " << m_jets[i].e()/cosh(m_jets[i].eta()) + << " MeV, eta: " << m_jets[i].eta() + << ", phi: " << m_jets[i].phi_std() + << ", rapidity: " << m_jets[i].rapidity() + << ", n consituents: " << m_constituents.size() << endmsg; + } +#endif + // === pileup subtraction + if(doTiming()) m_pu_subtraction_timer->resume(); + double et_offset = 0.; + double e_offset = 0.; + if (m_doPileupSubtraction){ + double jet_area = m_pu_cluster_sequence->area(m_jets[i]); + et_offset = jet_area * m_rho; + e_offset = et_offset * cosh(m_jets[i].eta()); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " - area: " << jet_area << ", offset (median m_rho * m_area): " << et_offset << endmsg; + (*m_log) << MSG::DEBUG << " - offset ET: " << (m_jets[i].e()/cosh(m_jets[i].eta())) - et_offset << ", e: " << m_jets[i].e()-e_offset << endmsg; + + } +#endif + } + if(doTiming()) m_pu_subtraction_timer->stop(); + // === cleaning + if(doTiming()) m_cleaning_timer->start(); + // taken from Tobias' L2 cleaning code in T2CaloJetConeTool + // initialize cleaning variables + int nLeadingCells = 0.; // number of leading cells + double em_energy = 0.; // EM energy + double had_energy = 0.; // hadronic energy + double emf = -9.; // fraction of jet energy in emc + double hecf = -9.; // fraction of jet energy in hec + float jetQuality = -9.; // quality of the jet + float jetTimeCells = -9.; // jet time calculated from cells + + // helper functions / variables for cleaning: + m_cellenergies.clear(); + float HECEnergy = 0.; + float EinBadCells = 0.; + bool isTile = false; + bool isLAr = false; + bool qualityTimeIsDefined = false; + float totaltime = 0.; + float norm = 0.; + float cellNorm = 0.; + float totCellE = 0.; // sum of energy in LAr cells with quality defined + double eTot=0, eta=0, phi=0, tmpE=0, eThresh=0, tmpPhi=0; + double tmpdPhi=0, dphi=0; + + if (m_doCleaning) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Computing cleaning variables "<< endmsg; + } +#endif + for (unsigned ii = 0; ii < m_constituents.size(); ++ii){ + int grid_id = m_constituents[ii].user_index(); + Trig3Momentum grid_element = grid->at(grid_id); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " - Constituent["<< ii + << "], grid id[" << grid_id + << "]: Et: " << grid_element.e()/cosh(grid_element.eta()) + << " MeV, eta: " << grid_element.eta() + << ", phi: " << grid_element.phi() + << ", sampling: " << std::hex << grid_element.caloSample() << std::dec << endmsg; + if (!m_doT2L1Cleaning){ + (*m_log) << MSG::DEBUG << " provenance: " << grid_element.provenance() + << ", quality: " << grid_element.quality() + << ", time: " << grid_element.time() << endmsg; + } + } +#endif + // reset flags: + isTile = false; + isLAr = false; + + tmpE = grid_element.e(); + eTot += tmpE; // maybe this should be Et weighted + + // Summ contribution to hadronic/EM energy: + const CaloSampling::CaloSample s = grid_element.caloSample(); + if( s == CaloSampling::PreSamplerB || s == CaloSampling::PreSamplerE || + s == CaloSampling::EMB1 || s == CaloSampling::EME1 || + s == CaloSampling::EMB2 || s == CaloSampling::EME2 || + s == CaloSampling::EMB3 || s == CaloSampling::EME3 || + s == CaloSampling::FCAL0){ + em_energy += tmpE; + isLAr = true; // for cleaning + } + if( s == CaloSampling::HEC0 || s == CaloSampling::HEC1|| + s == CaloSampling::HEC2 || s == CaloSampling::HEC3 || + s == CaloSampling::TileBar0 || s == CaloSampling::TileExt0 || + s == CaloSampling::TileBar1 || s == CaloSampling::TileExt1 || + s == CaloSampling::TileBar2 || s == CaloSampling::TileExt2 || + s == CaloSampling::TileGap1 || s == CaloSampling::TileGap2 || + s == CaloSampling::TileGap3 || s == CaloSampling::FCAL1 || + s == CaloSampling::FCAL2) + had_energy += tmpE; + + if (tmpE>0){ // threshold from job options? + eThresh += tmpE; + eta += tmpE*grid_element.eta(); + tmpPhi = grid_element.phi(); + + tmpdPhi = tmpPhi - m_jets[i].phi_std(); // w.r.t Jet + if (tmpdPhi > M_PI) tmpdPhi -= 2*M_PI; + if (tmpdPhi < -1*M_PI) tmpdPhi += 2*M_PI; + + dphi += tmpE*tmpdPhi; // this needs the wrap-around check + + } + + // cleaning: + m_cellenergies.push_back( tmpE ); + if( s == CaloSampling::HEC0 || s == CaloSampling::HEC1 || + s == CaloSampling::HEC2 || s == CaloSampling::HEC3 ) { + HECEnergy += tmpE; + isLAr = true; + } + if( s == CaloSampling::FCAL1 || s == CaloSampling::FCAL2 ){ + isLAr = true; + } + if( s == CaloSampling::TileBar0 || s == CaloSampling::TileBar1 || + s == CaloSampling::TileBar2 || s == CaloSampling::TileGap1 || + s == CaloSampling::TileGap2 || s == CaloSampling::TileGap3 || + s == CaloSampling::TileExt0 || s == CaloSampling::TileExt1 || + s == CaloSampling::TileExt2 ) { + isTile = true; + } + + if (!m_doT2L1Cleaning){ + uint16_t cellprovenance = grid_element.provenance(); + // grab cell quality and cell time. + uint16_t cellquality = grid_element.quality(); + float celltime = grid_element.time(); + qualityTimeIsDefined = false; + + // check for tile + if(isTile){ + // cells with bad quality are masked -> don't take tile into account + // for jet quality calculation. + // provenance not set for tile cells. but time is defined. + // timing: + cellNorm = tmpE * tmpE; + totaltime += cellNorm * celltime; + norm += cellNorm; + } + // check for LAr. only take cells into accout which have time and quality defined + if( (isLAr) && (cellprovenance & 0x2000) ){ + qualityTimeIsDefined = true; + totCellE += tmpE; + // timing: + cellNorm = tmpE * tmpE; + totaltime += cellNorm * celltime; + norm += cellNorm; + } + + if( (isLAr) && (qualityTimeIsDefined) && (cellquality > m_cellQualityThresholdLAr) ){ + EinBadCells += tmpE; + } + } // end of non L1.5 cleaning + } // end loop over constituents + + // calculate the jet cleaning variables: + // ------------------------------------- + if(eThresh != 0) { + eta /= eThresh; + phi = dphi/eThresh + m_jets[i].phi_std(); // recover absolute value + + // phi must be between -pi and pi : + if(phi > M_PI) phi -= 2.0* M_PI; + if(phi < -1.0*M_PI) phi += 2.0*M_PI; + } + // sort cell-energy vector. (most energetic cell at end of vector) + std::sort(m_cellenergies.begin(), m_cellenergies.end()); + float sumE = 0.; + for(int k = m_cellenergies.size()-1; k > -1; k--){ + sumE += m_cellenergies[k]; + nLeadingCells++; + if(sumE > m_leadingCellFraction*eTot){ + break; + } + } + + float DELTA = 0.001; // distance to compare floats + if(fabs(eTot)>DELTA){ + hecf = HECEnergy/eTot; + emf = em_energy/eTot; + } + if (!m_doT2L1Cleaning){ + if(fabs(totCellE)>DELTA){ + jetQuality = EinBadCells/totCellE; + } + if(fabs(norm)>DELTA){ + jetTimeCells = totaltime/norm; + } + } + + // === cleaning completed +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " - EM energy [MeV]: " << em_energy << ", (ET: " << em_energy/cosh(m_jets[i].eta()) << ")" << endmsg; + (*m_log) << MSG::DEBUG << " - HAD energy [MeV]: " << had_energy << ", (ET: " << had_energy/cosh(m_jets[i].eta()) << ")" << endmsg; + (*m_log) << MSG::DEBUG << " - n leading cells: " << nLeadingCells << endmsg; + (*m_log) << MSG::DEBUG << " - EM fraction: " << emf << endmsg; + (*m_log) << MSG::DEBUG << " - HEC fraction: " << hecf << endmsg; + (*m_log) << MSG::DEBUG << " - Jet quality: " << jetQuality << endmsg; + (*m_log) << MSG::DEBUG << " - Jet time: " << jetTimeCells << endmsg; + } +#endif + + } // end of cleaning + if(doTiming()) m_cleaning_timer->stop(); + // Set properties + m_jet = new TrigT2Jet(); + if (m_doPileupSubtraction){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) + (*m_log) << MSG::DEBUG << " Recording with offset energy" << endmsg; +#endif + m_jet->setE(m_jets[i].e() - e_offset); + } else { + m_jet->setE(m_jets[i].e()); + } + m_jet->setEta(m_jets[i].eta()); + m_jet->setPhi(m_jets[i].phi_std()); + m_jet->setEem0(em_energy); + m_jet->setEhad0(had_energy); + // cleaning: + m_jet->setNLeadingCells(nLeadingCells); + m_jet->setHecf(hecf); + m_jet->setJetQuality(jetQuality); + m_jet->setEmf(emf); + m_jet->setJetTimeCells(jetTimeCells); + // RoI word + m_jet->set_RoIword(m_t2l1_tools.BLANKWORD+m_t2l1_tools.SET_INPUT*m_inputType+m_t2l1_tools.SET_OUTPUT*m_outputType+i); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) + (*m_log) << MSG::DEBUG << " RoI word set to: " << m_jet->RoIword() << endmsg; +#endif + + // === calibration + if(doTiming()) m_calibration_timer->start(); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " " << m_tools.size() << " calibration tools to be run"<< endmsg; + + } +#endif + // do loop over tools + ToolHandleArray< T2CaloJetBaseTool >::iterator it = m_tools.begin(), + itToolEnd = m_tools.end(); + int current=1; + for (; it != itToolEnd; ++it) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Executing tool [" << current << "]"<< endmsg; + } +#endif + if ((*it)->execute(m_jet, TrigRoiDescriptor(true), caloDDENull ).isFailure()){ // the zeros are the unused eta phi coordinates used by many base tools to define the RoI region + msg() << MSG::WARNING << "T2CaloFastJet AlgToolJets returned Failure" << endmsg; + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + } + current++; + } + +#ifndef NDEBUG + if( (m_tools.size()>0) && ((*m_log).level() <= MSG::DEBUG) ){ + (*m_log) << MSG::DEBUG << " calibrated jet [" << i + << "]: Et: " << m_jet->et() + << " MeV, eta: " << m_jet->eta() + << ", phi: " << m_jet->phi() + << endmsg; + } +#endif + if(doTiming()) m_calibration_timer->stop(); + // === monitor + m_et.push_back( m_jet->et()); + m_et_em.push_back( (m_jet->eem0()/cosh(m_jet->eta()))); + m_et_had.push_back( (m_jet->ehad0()/cosh(m_jet->eta()))); + m_e.push_back( m_jet->e()); + m_e_em.push_back( m_jet->eem0()); + m_e_had.push_back( m_jet->ehad0()); + m_eta.push_back( m_jet->eta() ); + m_phi.push_back( m_jet->phi() ); + m_em_frac.push_back( m_jet->emf() ); + m_nLeadingTowers.push_back( m_jet->nLeadingCells() ); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " recording T2CaloJet["<<recorded_jet_counter<<"]"<<endmsg; + } +#endif + if (m_writeMultipleOutputTEs){ + unsigned int secondary_roi_word = m_jet->RoIword(); + if (m_secondOutputType != 0){ + secondary_roi_word = m_t2l1_tools.BLANKWORD+m_t2l1_tools.SET_INPUT*m_outputType+m_t2l1_tools.SET_OUTPUT*m_secondOutputType+i; + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " preparing an output TE, using RoI word: " << secondary_roi_word <<endmsg; + } +#endif + // addRoI implementation + //outputTE = addRoI(type_out, m_jet->eta(), m_jet->phi()); // make an output TE + // alternative implementation + //outputTE = config()->getNavigation()->addNode(seednode,type_out); + //outputTE->setActiveState(true); + HLT::TriggerElement* initialTE = config()->getNavigation()->getInitialNode(); + outputTE = config()->getNavigation()->addNode(initialTE,type_out); + outputTE->setActiveState(true); + + // setup a trig RoI descriptor + unsigned int dummy_l1id = -9; // NO NO!!! THE L1ID IS AN UNSIGNED INT!!!! + int dummy_id = -9; // NO NO!!! THE ID IS AN UNSIGNED INT!!!! + TrigRoiDescriptor* newRoiDescriptor = + new TrigRoiDescriptor(unsigned(secondary_roi_word), unsigned(dummy_l1id), unsigned(dummy_id), + m_jet->eta(), m_jet->eta(), m_jet->eta(), + m_jet->phi(), m_jet->phi(), m_jet->phi() + ); + /// HOW BIG IS THE ROI ??? + HLT::ErrorCode hltStatus = attachFeature(outputTE, newRoiDescriptor, m_jetOutputKey); + if ( hltStatus != HLT::OK ) { + (*m_log) << MSG::ERROR << "recording of RoiDescriptor into StoreGate failed" << endmsg; + return hltStatus; + } + + + hltStatus = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (hltStatus != HLT::OK){ + (*m_log) << MSG::ERROR << "recording of TrigT2Jet into StoreGate failed" << endmsg; + return hltStatus; + } + } else { + HLT::ErrorCode hltStatus = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (hltStatus != HLT::OK){ + (*m_log) << MSG::ERROR << "recording of TrigT2Jet into StoreGate failed" << endmsg; + return hltStatus; + } + } + + + recorded_jet_counter++; + } + + m_RoI_timer->stop(); + + + // === post-execute admin + if (m_doPileupSubtraction){ + delete m_pu_cluster_sequence; + delete m_pu_area_cluster_sequence; + } else { + delete m_cluster_sequence; + } + if(doTiming()) { + //m_total_timer->stop(); + m_UnpackTime = m_unpack_timer->elapsed(); + m_FastJetTime = m_fastjet_timer->elapsed(); + m_puSubTime = m_pu_subtraction_timer->elapsed(); + m_CleaningTime = m_cleaning_timer->elapsed(); + m_CalibrationTime = m_calibration_timer->elapsed(); + m_RoITime = m_RoI_timer->elapsed(); + //m_TotalTime = m_total_timer->elapsed(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Unpacking completed in " << m_unpack_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "FastJet completed in " << m_fastjet_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "PU subtraction completed in " << m_pu_subtraction_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "Cleaning completed in " << m_cleaning_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "Calibration completed in " << m_calibration_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "RoI making completed in " << m_RoI_timer->elapsed() << " ms " << endmsg; + //(*m_log) << MSG::DEBUG << "T2CaloFastJet completed in " << m_total_timer->elapsed() << " ms " << endmsg; + } +#endif + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) (*m_log) << MSG::DEBUG << "================= Finished T2CaloFastJet " << name() << endmsg; +#endif + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + afterExecMonitors().ignore(); + + return HLT::OK; +} + + +HLT::ErrorCode T2CaloFastJet::hltFinalize() +{ + if ( (*m_log).level() <= MSG::DEBUG ) + (*m_log) << MSG::DEBUG << "Finalizing T2CaloFastJet FEX " << name() << endmsg; + + delete m_log; + m_particles.clear(); + m_jets.clear(); + m_constituents.clear(); + m_et.clear(); + m_et_em.clear(); + m_et_had.clear(); + m_e.clear(); + m_e_em.clear(); + m_e_had.clear(); + m_eta.clear(); + m_phi.clear(); + m_em_frac.clear(); + m_nLeadingTowers.clear(); + + if ( bool(m_jet_def) ){ + delete m_jet_def; + } + + if (m_doPileupSubtraction){ + delete m_pu_jet_def; + delete m_pu_area_def; + } + + + return HLT::OK; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJet.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJet.cxx new file mode 100755 index 00000000000..7185627e56e --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJet.cxx @@ -0,0 +1,491 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloJet.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Kyle Cranmer +// ******************************************************************** + + +#include "GaudiKernel/IToolSvc.h" +//#include "GaudiKernel/StatusCode.h" + +//#include "TrigT1Interfaces/RecEmTauRoI.h" +#include "TrigT1Interfaces/TrigT1Interfaces_ClassDEF.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "TrigT2CaloJet/T2CaloJet.h" + +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigCaloEvent/TrigT2JetContainer.h" + +#include "CaloGeoHelpers/CaloSampling.h" + +#include "TrigT2CaloCommon/phiutils.h" + +#include <math.h> + +class ISvcLocator; + +T2CaloJet::T2CaloJet(const std::string & name, ISvcLocator* pSvcLocator) + : T2CaloBase(name, pSvcLocator), + m_jet(0), + m_layerInfo(0), + m_tools(this), + m_clearJetGrid(true), + m_fillLayerInfo(false), + m_timeLArUnpck(0), + m_timeTileUnpck(0), + m_timeHECUnpck(0) + +{ + declareProperty("jetOutputKey",m_jetOutputKey = "TrigT2CaloJet"); + declareProperty("clusterOutputKey",m_clusterOutputKey = "TrigT2Calo"); + // declareProperty("T2JetTools", m_toolNames); + declareProperty("T2JetTools", m_tools, "list of Jet tools"); + declareProperty("clearJetGrid",m_clearJetGrid = true); + declareProperty("fillLayerInfo",m_fillLayerInfo = false); + declareProperty("PhiIDWidth", m_phiIDWidth); + declareProperty("EtaIDWidth", m_etaIDWidth); + + declareMonitoredVariable("dR", m_dR); + declareMonitoredVariable("E", m_e); + declareMonitoredVariable("Et", m_et); + declareMonitoredVariable("Eem", m_eem0); + declareMonitoredVariable("Ehad",m_ehad0); + declareMonitoredVariable("Etem", m_etem0); + declareMonitoredVariable("Ethad",m_ethad0); + declareMonitoredVariable("Eta", m_eta); + declareMonitoredVariable("Phi", m_phi); + declareMonitoredVariable("ConversionErrors", m_conversionError); + declareMonitoredVariable("AlgorithmErrors", m_algorithmError); + m_roiEtaLimit = 4.8; +} + +HLT::ErrorCode T2CaloJet::hltInitialize() +{ + + if (timerSvc()) { + m_timer.push_back(addTimer("TimeTot")); + } + + // Create helper tools + if ( m_tools.retrieve().isFailure() ) { + msg() << MSG::ERROR << "Failed to retreive helper tools: " << m_tools << endmsg; + } else { + msg() << MSG::INFO << "Retrieved " << m_tools << endmsg; + } + + if (timerSvc()) { + ToolHandleArray< T2CaloJetBaseTool >::iterator itTool = m_tools.begin(), + itToolEnd = m_tools.end(); + for ( ; itTool != itToolEnd; ++itTool ) { + + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG <<"Tool with name " << (*itTool).name()<< endmsg; + + m_timer.push_back(addTimer((*itTool).name())); + + if(((*itTool).name() == "T2CaloJetGridFromCells")||((*itTool).name() == "T2CaloJetGridFromFEBHeader")){ + + m_timeLArUnpck = (*itTool)->getTimer("LArUnpck"); + if(m_timeLArUnpck !=0){ + declareMonitoredObject("LArUnpck",m_timeLArUnpck, + &TrigTimer::lastElapsed); + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG << "Found LArUnpck timer. Added to monitoring " + << endmsg; + } + + m_timeHECUnpck = (*itTool)->getTimer("HECUnpck"); + if(m_timeHECUnpck !=0){ + declareMonitoredObject("HECUnpck",m_timeHECUnpck, + &TrigTimer::lastElapsed); + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG << "Found HECUnpck timer. Added to monitoring " + << endmsg; + } + + m_timeTileUnpck = (*itTool)->getTimer("TileUnpck"); + if(m_timeTileUnpck !=0){ + declareMonitoredObject("TileUnpck",m_timeTileUnpck, + &TrigTimer::lastElapsed); + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG << "Found HECUnpck timer. Added to monitoring " + << endmsg; + } + } + } + } + + + return HLT::OK; +} + +T2CaloJet::~T2CaloJet(){ +} + +HLT::ErrorCode T2CaloJet::hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE) +{ + + if(timerSvc()) m_timer[0]->start(); + + m_dR = -99; + m_e = -99; + m_et = -99; + m_eem0 = -99; + m_ehad0 = -99; + m_etem0 = -99; + m_ethad0 = -99; + m_eta = -99; + m_phi = -99; + m_conversionError=0; + m_algorithmError=0; + + // Retrieve store. + // Very important! + // m_storeGate = getStore(); // not needed anymore + + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG << "in execute()" << endmsg; + + // Some debug output: + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG + << "outputTE->getId(): " + << outputTE->getId() + << endmsg; + + msg() << MSG::DEBUG + << "inputTE->getId(): " + << inputTE->getId() + << endmsg; + } + // Note: new TriggerElement has no label() anymore ! + + + // ========================= + // retrieve RoI: + // ========================= + const IRoiDescriptor* roiDescriptor = 0; + HLT::ErrorCode hltStatus; + + const TrigRoiDescriptor* trigRoiDescriptor = 0; + hltStatus = getFeature(inputTE, trigRoiDescriptor); + roiDescriptor = trigRoiDescriptor; + + + if ( hltStatus == HLT::OK ) { + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG << *roiDescriptor << endmsg; + + } else { + msg() << MSG::WARNING << " Failed to find RoiDescriptor " << endmsg; + return hltStatus; + } + + // Some debug output: + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG << "Message to count events. LVL1 phi=" + << roiDescriptor->phi() + << " & LVL1 eta=" + << roiDescriptor->eta() + << endmsg; + } + + /*** obsolete + // setup ROI bounds + double etamin = std::max(-1.0 * m_roiEtaLimit, roiDescriptor->eta0() - m_etaWidth); + double etamax = std::min( 1.0 * m_roiEtaLimit, roiDescriptor->eta0() + m_etaWidth); + double phimin = roiDescriptor->phi() - m_phiWidth; + double phimax = roiDescriptor->phi() + m_phiWidth; + while (phimin < 0) phimin += 2. * M_PI; + while (phimax > 2 * M_PI) phimax -= 2. * M_PI; + + + + //Look at RoIs in FCal - to what end ?? + if(fabs(roiDescriptor->eta())>3.2){ + if(roiDescriptor->eta()<-3.2){ + etamin = -m_fcalEtaMax; + etamax = -m_fcalEtaMin; + } + if(roiDescriptor->eta()>3.2){ + etamin = m_fcalEtaMin; + etamax = m_fcalEtaMax; + } + } + + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG << " etamin = "<< etamin << endmsg; + msg() << MSG::DEBUG << " etamax = "<< etamax << endmsg; + msg() << MSG::DEBUG << " phimin = "<< phimin << endmsg; + msg() << MSG::DEBUG << " phimax = "<< phimax << endmsg; + } + + ***/ + + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG << " roi = "<< *roiDescriptor << endmsg; + } + + // ========================= + // make Jet + // ========================= + // if(status) status = makeJet(outputTE); + + if(msgLvl() <= MSG::DEBUG) + msg() << MSG::DEBUG << " Making TrigT2Jet "<< endmsg; + + m_jet = new TrigT2Jet(); + + // jetContainer was only retrieved from StoreGate ... but never used + //TrigT2JetContainer* jetContainer; + +/* + StatusCode sc; + + if(!getStore()->transientContains<TrigT2JetContainer>(m_jetOutputKey)) { + if(msgLvl() <= MSG::DEBUG){ + msg() << MSG::DEBUG + <<" Create jetObjectMinimal container" + <<endmsg; + } + jetContainer = new TrigT2JetContainer(); + sc = m_storeGate->record(jetContainer,m_jetOutputKey); + + if (sc.isFailure()) + { + msg() << MSG::ERROR + << "Could not record TrigT2JetContainer in TDS" + << endmsg; + } + } + else{ + sc = m_storeGate->retrieve(jetContainer,m_jetOutputKey); + if(sc.isFailure()){ + msg() << MSG::ERROR + << "Could not retrieve TrigT2JetContainer " << m_jetOutputKey + << "from SG. Exiting..." + << endmsg; + return false; + } + } +*/ + //jetContainer->push_back(m_jet); + + + // Add RoI word to Jet + m_jet->set_RoIword(roiDescriptor->roiWord()); + + // Set eta,phi + m_jet->setEta(roiDescriptor->eta()); + m_jet->setPhi(roiDescriptor->phi()); + + + // do loop over tools + ToolHandleArray< T2CaloJetBaseTool >::iterator it = m_tools.begin(), + itToolEnd = m_tools.end(); + int courant=1; + uint32_t error = 0; + for ( ; it != itToolEnd; ++it ) { + if (timerSvc()) m_timer[courant]->start(); + /// if ((*it)->execute(m_jet, etamin, etamax, phimin, phimax).isFailure()){ + if ((*it)->execute(m_jet, *roiDescriptor, caloDDENull ).isFailure()){ + msg() << MSG::WARNING << "T2CaloJet AlgToolJets returned Failure" << endmsg; + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + } + uint32_t in_error = (*it)->report_error(); + if ( 0x0FFFFFFF & in_error ) m_conversionError++; + if ( 0xF0000000 & in_error ) m_algorithmError++; + error|=in_error; + if (timerSvc()) m_timer[courant]->stop(); + courant++; + } + + if(msgLvl() <= MSG::DEBUG){ + msg() << MSG::DEBUG << " Values of T2CaloJet produced: " << endmsg; + msg() << MSG::DEBUG << " REGTEST: Jet eta = " << m_jet->eta() << endmsg; + msg() << MSG::DEBUG << " REGTEST: Jet phi = " << m_jet->phi() << endmsg; + msg() << MSG::DEBUG << " REGTEST: Jet energy = " << m_jet->e() << endmsg; + } + + + double phia=roiDescriptor->phi(); + if(phia>M_PI) phia=phia-2*M_PI; + + double phib=m_jet->phi(); + if(phib>M_PI) phib=phib-2*M_PI; + + double dphi= phia-phib; + if(dphi>M_PI) dphi-=2*M_PI; + if(dphi<-M_PI) dphi+=2*M_PI; + + m_dR = sqrt( (roiDescriptor->eta()-m_jet->eta())*(roiDescriptor->eta()-m_jet->eta()) + dphi*dphi ); + + m_e = m_jet->e(); + m_eta = m_jet->eta(); + m_phi = m_jet->phi(); + + m_ehad0 = m_jet->ehad0(); + m_ethad0 = m_ehad0/cosh(m_eta); + + m_eem0 = m_jet->eem0(); + m_etem0 = m_eem0/cosh(m_eta); + + m_et = m_e/cosh(m_eta); + + // should probably set the delete the jet's vector of Trig3Momentum + // here, and set pointer to 0. + + // std::string jetKey = key2keyStore::getKey(m_jet); + // sc = m_storeGate->record( m_jet, jetKey, false, false ); + // if (sc.isFailure()){ + // msg() << MSG::ERROR << "Record of individual T2CaloJet into StoreGate failed" << endmsg; + // return false; + // }; + + std::string key = ""; + + hltStatus = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (hltStatus != HLT::OK) { + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::ERROR << "Write of TrigT2Jet into outputTE failed" + << endmsg; + } + return hltStatus; + } + + // ========================= + // make TrigCaloCluster + // ========================= + + if(msgLvl() <= MSG::DEBUG){ + msg() << MSG::DEBUG << "fillLayerInfo is set to "<< m_fillLayerInfo << endmsg; + } + + if (m_fillLayerInfo) { + if(msgLvl() <= MSG::DEBUG){ + msg() << MSG::DEBUG << "Making TrigCaloCluster "<< endmsg; + } + m_layerInfo = new TrigCaloCluster(); + + std::vector<Trig3Momentum>::iterator gridIt = m_jet->grid()->begin(); + std::vector<Trig3Momentum>::iterator gridEnd = m_jet->grid()->end(); + int nCells = 0; + double eLayer[CaloSampling::Unknown+1] = {0.0};//0 is CaloSampling::PreSamplerB, 24 is CaloSampling::Unknown + + // Loop in the jet cells: + for (; gridIt != gridEnd; ++gridIt){ + // consider only cells that are used in the cone: + if(! (*gridIt).inCone()) continue; + nCells++; + // get layer energy + const CaloSampling::CaloSample s = (*gridIt).caloSample(); + double cellE = (*gridIt).e(); + eLayer[s] = eLayer[s] + cellE; + } + + // fill TrigCaloCluster + m_layerInfo->setRawEnergy(m_jet->eem0()+m_jet->ehad0()); + m_layerInfo->setRawEt((m_jet->eem0()+m_jet->ehad0())/cosh(m_jet->eta())); + m_layerInfo->setRawEta(m_jet->eta()); + m_layerInfo->setRawPhi(m_jet->phi()); + m_layerInfo->setRoIword(m_jet->RoIword()); + m_layerInfo->setNCells(nCells); + for (int iSample=CaloSampling::PreSamplerB; iSample<CaloSampling::Unknown; ++iSample){ + const CaloSampling::CaloSample s = static_cast<CaloSampling::CaloSample> (iSample); + m_layerInfo->setRawEnergy(s,eLayer[s]); + } + + if(msgLvl() <= MSG::DEBUG){ + msg() << MSG::DEBUG << " Values of TrigCaloCluster produced: " << endmsg; + msg() << MSG::DEBUG << " REGTEST: Cluster raw eta = " << m_layerInfo->rawEta() << endmsg; + msg() << MSG::DEBUG << " REGTEST: Cluster raw phi = " << m_layerInfo->rawPhi() << endmsg; + msg() << MSG::DEBUG << " REGTEST: Cluster raw energy = " << m_layerInfo->rawEnergy() << endmsg; + msg() << MSG::DEBUG << " REGTEST: Cluster nb. of cells = " << m_layerInfo->nCells() << endmsg; + double totalE=0; + for (int iSample=CaloSampling::PreSamplerB; iSample<=CaloSampling::Unknown; ++iSample){ + const CaloSampling::CaloSample s = static_cast<CaloSampling::CaloSample> (iSample); + double layerE=m_layerInfo->rawEnergy(s); + totalE=totalE+layerE; + msg() << MSG::DEBUG << " REGTEST: Layer = " << iSample << " raw energy = " << layerE; + } + msg() << MSG::DEBUG << " REGTEST: Total = " << totalE << endmsg; + } + + // attach TrigCaloCluster + hltStatus = recordAndAttachFeature(outputTE, m_layerInfo, key, m_clusterOutputKey); + if (hltStatus != HLT::OK) { + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::ERROR << "Write of TrigCaloCluster into outputTE failed" + << endmsg; + } + return hltStatus; + } + } + + // ========================= + // make OutputTE + // ========================= + + // Create a new RoiDescriptor with updated eta and phi. + // Note that the steering will propagate l1Id and roiId automatically + // so no need to set them. + // How big is the RoI ????? + TrigRoiDescriptor* newRoiDescriptor = + //new TrigRoiDescriptor(roiDescriptor->l1Id(), roiDescriptor->roiId(), + // m_jet->eta(), m_jet->phi()); + new TrigRoiDescriptor(roiDescriptor->roiWord(), roiDescriptor->l1Id(), roiDescriptor->roiId(), + m_jet->eta(), m_jet->eta()-m_etaIDWidth, m_jet->eta()+m_etaIDWidth, + m_jet->phi(), + HLT::wrap_phi(m_jet->phi()-m_phiIDWidth), + HLT::wrap_phi(m_jet->phi()+m_phiIDWidth) ); + // We forward the roiWord to the EF (??) + + + hltStatus = attachFeature(outputTE, newRoiDescriptor, m_jetOutputKey); + + if ( hltStatus != HLT::OK ) { + msg() << MSG::ERROR << "Write of update TrigRoiDescriptor into outputTE failed" + << endmsg; + return hltStatus; + } + + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG << "Recorded an RoiDescriptor " << *newRoiDescriptor << endmsg; + } + + // Some debug output: + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG + << "We assume success, set TE with Id " + << outputTE->getId() + << " active to signal positive result." + << endmsg; + } + + + if(m_clearJetGrid) m_jet->clearGrid(); + + if (timerSvc()) { + m_timer[0]->stop(); + } + + return HLT::OK; +} + + +HLT::ErrorCode T2CaloJet::hltFinalize() +{ + if ( msgLvl() <= MSG::INFO ) + msg() << MSG::INFO << "in finalize()" << endmsg; + + return HLT::OK; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetBaseTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetBaseTool.cxx new file mode 100755 index 00000000000..3d1d006a8f6 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetBaseTool.cxx @@ -0,0 +1,61 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2CaloJetBaseTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Base Tool for all T2CaloJet tools that require + an T2CaloJet object as its input. The derived + tool must implement an execute(T2CaloJet*) method. + +********************************************************************/ +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "TrigCaloEvent/TrigT2Jet.h" + +#include "GaudiKernel/MsgStream.h" + +#include "GaudiKernel/IToolSvc.h" + +T2CaloJetBaseTool::T2CaloJetBaseTool(const std::string& type, + const std::string& name, + const IInterface* parent): + IAlgToolCalo(type, name, parent) +{ + declareInterface<T2CaloJetBaseTool>( this ); +} + + +T2CaloJetBaseTool::~T2CaloJetBaseTool() +{ +} + +StatusCode T2CaloJetBaseTool::initialize() +{ + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetBaseTool::execute() +{ + return StatusCode::SUCCESS; +} + + +//StatusCode T2CaloJetBaseTool::execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax) +// StatusCode T2CaloJetBaseTool::execute(TrigT2Jet* /*jet*/,double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/) +StatusCode T2CaloJetBaseTool::execute(TrigT2Jet* /* jet */, const IRoiDescriptor& /* roi */, + const CaloDetDescrElement*& /*caloDDE*/ ) +{ + return StatusCode::SUCCESS; +} + + +StatusCode T2CaloJetBaseTool::finalize() +{ + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetCalibTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetCalibTool.cxx new file mode 100755 index 00000000000..837153a85ea --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetCalibTool.cxx @@ -0,0 +1,422 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2CaloJetCalibTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Patricia Conde Muino <Patricia.Conde.Muino@cern.ch> + Nuno Anjos <Nuno.Anjos@cern.ch> +CREATED: May 2006 + +PURPOSE: Calibration tool for LVL2 jets. + +********************************************************************/ +#include "TrigT2CaloJet/T2CaloJetCalibTool.h" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "CaloGeoHelpers/CaloSampling.h" +#include "AthenaKernel/Timeout.h" + +#include "GaudiKernel/IToolSvc.h" + +//----------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------- +T2CaloJetCalibTool::T2CaloJetCalibTool(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent), + m_log(NULL), + m_outputLevel(0), + m_t2JetCalibTool ("T2JetCalibTool",this), + m_t2JetCorrToolTile1 ("T2JetCorrToolTile1" ,this), + m_t2JetCorrToolFcal1 ("T2JetCorrToolFcal1" ,this), + m_t2JetCorrToolEm3Bar ("T2JetCorrToolEm3Bar",this), + m_t2JetCorrToolHec0 ("T2JetCorrToolHec0" ,this), + m_t2JetCorrToolEm3Fwd ("T2JetCorrToolEm3Fwd",this), + m_t2JetCorrToolPsBar ("T2JetCorrToolPsBar" ,this)//,m_layer_info(0) +{ + declareProperty("useFebJets", m_useFEBJets = false); +//declareProperty("fillLayerInfo", m_fillLayerInfo = false); + declareProperty("doJetCalib", m_doJetCalib = false); + declareProperty("doJetCorrTile1", m_doJetCorrTile1 = false); + declareProperty("doJetCorrFcal1", m_doJetCorrFcal1 = false); + declareProperty("doJetCorrEm3Bar", m_doJetCorrEm3Bar = false); + declareProperty("doJetCorrHec0", m_doJetCorrHec0 = false); + declareProperty("doJetCorrEm3Fwd", m_doJetCorrEm3Fwd = false); + declareProperty("doJetCorrPsBar", m_doJetCorrPsBar = false); + declareProperty("T2JetCalibTool", m_t2JetCalibTool, "Tool for L2 jet trigger Jet calibration"); + declareProperty("T2JetCorrToolTile1", m_t2JetCorrToolTile1 , "Tool for L2 jet trigger Tile1 corr"); + declareProperty("T2JetCorrToolFcal1", m_t2JetCorrToolFcal1 , "Tool for L2 jet trigger Fcal1 corr"); + declareProperty("T2JetCorrToolEm3Bar", m_t2JetCorrToolEm3Bar, "Tool for L2 jet trigger Em3Bar corr"); + declareProperty("T2JetCorrToolHec0", m_t2JetCorrToolHec0 , "Tool for L2 jet trigger Hec0 corr"); + declareProperty("T2JetCorrToolEm3Fwd", m_t2JetCorrToolEm3Fwd, "Tool for L2 jet trigger Em3Fwd corr"); + declareProperty("T2JetCorrToolPsBar", m_t2JetCorrToolPsBar , "Tool for L2 jet trigger PsBar corr"); +} + +//----------------------------------------------------------------- +// Destructor +//----------------------------------------------------------------- +T2CaloJetCalibTool::~T2CaloJetCalibTool() +{ +} + +//----------------------------------------------------------------- +// Initialize: +//----------------------------------------------------------------- +StatusCode T2CaloJetCalibTool::initialize() +{ + + m_log = new MsgStream (msgSvc(), name()); + m_outputLevel = msgSvc()->outputLevel( name() ); + if(m_outputLevel <= MSG::DEBUG) + (*m_log) << MSG::DEBUG << " In initalize() " << endmsg; + + StatusCode sc; + // Retrieve the jet calibration tool: + ATH_CHECK( m_t2JetCalibTool.retrieve( DisableTool {!m_doJetCalib} )); + + // Retrieve the layer correction tools: + ATH_CHECK( m_t2JetCorrToolTile1.retrieve( DisableTool {!m_doJetCorrTile1} )); + ATH_CHECK( m_t2JetCorrToolFcal1.retrieve( DisableTool {!m_doJetCorrFcal1} )); + ATH_CHECK( m_t2JetCorrToolEm3Bar.retrieve( DisableTool {!m_doJetCorrEm3Bar} )); + ATH_CHECK( m_t2JetCorrToolHec0.retrieve( DisableTool {!m_doJetCorrHec0} )); + ATH_CHECK( m_t2JetCorrToolEm3Fwd.retrieve( DisableTool {!m_doJetCorrEm3Fwd} )); + ATH_CHECK( m_t2JetCorrToolPsBar.retrieve( DisableTool {!m_doJetCorrPsBar} )); + + // from IAlgToolCalo + m_geometryTool.disable(); + m_data.disable(); + +// if (m_fillLayerInfo) { +// m_layer_info = new TrigCaloCluster(); +// } + + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------- +// Execute +//----------------------------------------------------------------- +StatusCode T2CaloJetCalibTool::execute() +{ + return StatusCode::SUCCESS; +} + + +//----------------------------------------------------------------- +// Finalize: +//----------------------------------------------------------------- +StatusCode T2CaloJetCalibTool::finalize() +{ + delete m_log; + +// if (m_fillLayerInfo) { +// delete m_layer_info; +// } + + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------- +// Execute method of the tool. Apply energy correction to the jet. +//----------------------------------------------------------------- +StatusCode T2CaloJetCalibTool::execute(TrigT2Jet* jet, double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/) +{ + // reset error + m_error = 0x0; + + + // Calculate Hadronic and Electromagnetic transverse energies: +// double HadEn = 0, EMEn = 0; + double EMEn = jet->eem0(); + double HadEn = jet->ehad0(); + double jeta=jet->eta(); +// sc = calculateHadEMEnergy(jet, &HadEn, &EMEn); +// if(sc.isFailure()){ +// (*m_log) << MSG::WARNING << "It seems that the Had/EM energy was not properly calculated!" << endmsg; +// } +// +// if(m_outputLevel <= MSG::DEBUG){ +// (*m_log) << MSG::DEBUG << " EM, Had energy components: " << EMEn << ", " +// << HadEn << endmsg; +// } + + // Apply the calibration: + double corrEnergy=0; + if(m_doJetCalib){ + if(!m_useFEBJets){ + corrEnergy = m_t2JetCalibTool->c_energy(EMEn, HadEn, jeta); + } else { + corrEnergy = m_t2JetCalibTool->c_febenergy(EMEn, HadEn, jeta); + } + + if(corrEnergy == 0 || corrEnergy!=corrEnergy){//corrEnergy!=corrEnergy checks for nan + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG + << " JES Calibration failed. Jet energy is left uncalibrated: " + << endmsg; + } + corrEnergy = EMEn+HadEn ; + } + } else { + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG + << " Calibration not applied. Jet energy is left uncalibrated: " + << endmsg; + } + corrEnergy = EMEn+HadEn ; + } + + // Compute layer fractions: + double fTile1=0, fFcal1=0, fEm3=0, fHec0=0, fPs=0; + if( m_doJetCorrTile1 || + m_doJetCorrHec0 || + m_doJetCorrEm3Fwd || + m_doJetCorrFcal1 || + m_doJetCorrEm3Bar || + m_doJetCorrPsBar//|| m_fillLayerInfo + ) { + if (calculateLayerFracs(jet, &fTile1, &fFcal1, &fEm3, &fHec0, &fPs).isFailure()){ + (*m_log) << MSG::WARNING << "Layer Fractions not properly calculated!" << endmsg; + } + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Uncorr Jet E = " << EMEn+HadEn + << " Tile1 fraction = " << fTile1 + << " Fcal1 fraction = " << fFcal1 + << " Em3 fraction = " << fEm3 + << " Hec0 fraction = " << fHec0 + << " Ps fraction = " << fPs + << " Jet E before layer corr = " << corrEnergy << endmsg; + } + } + + // Apply layer corrections: + double response=1; + if(m_doJetCorrTile1) { + response = m_t2JetCorrToolTile1->c_energy(fTile1, corrEnergy, jeta); + if(response != 0 && response != 1 && response==response) corrEnergy = corrEnergy/response; + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Tile1 response = " << response + << " corrected E = " << corrEnergy << endmsg; + } + } + if(m_doJetCorrHec0) { + response = m_t2JetCorrToolHec0->c_energy(fHec0, corrEnergy, jeta); + if(response != 0 && response != 1 && response==response) corrEnergy = corrEnergy/response; + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Hec0 response = " << response + << " corrected E = " << corrEnergy << endmsg; + } + } + if(m_doJetCorrEm3Fwd) { + response = m_t2JetCorrToolEm3Fwd->c_energy(fEm3, corrEnergy, jeta); + if(response != 0 && response != 1 && response==response) corrEnergy = corrEnergy/response; + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Em3Fwd response = " << response + << " corrected E = " << corrEnergy << endmsg; + } + } + if(m_doJetCorrFcal1) { + response = m_t2JetCorrToolFcal1->c_energy(fFcal1, corrEnergy, jeta); + if(response != 0 && response != 1 && response==response) corrEnergy = corrEnergy/response; + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Fcal1 response = " << response + << " corrected E = " << corrEnergy << endmsg; + } + } + if(m_doJetCorrEm3Bar) { + response = m_t2JetCorrToolEm3Bar->c_energy(fEm3, corrEnergy, jeta); + if(response != 0 && response != 1 && response==response) corrEnergy = corrEnergy/response; + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Em3Bar response = " << response + << " corrected E = " << corrEnergy << endmsg; + } + } + if(m_doJetCorrPsBar) { + response = m_t2JetCorrToolPsBar->c_energy(fPs, corrEnergy, jeta); + if(response != 0 && response != 1 && response==response) corrEnergy = corrEnergy/response; + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "PsBar response = " << response + << " corrected E = " << corrEnergy << endmsg; + } + } + + + // Set jet energy: + jet->setE(corrEnergy); + + if(m_outputLevel <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Uncorrected E = " << EMEn+HadEn << ", Fully corrected E = " + << corrEnergy << ", eta = " << jet->eta() << endmsg; + } + + if ( Athena::Timeout::instance().reached() ) { + (*m_log) << MSG::ERROR << "Timeout reached in T2CaloJetCalibTool" << endmsg; + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +//--------------------------------------------------------------- +// Calculate layer fractions of the jet energy: +//--------------------------------------------------------------- +StatusCode T2CaloJetCalibTool::calculateLayerFracs(TrigT2Jet* jet, double *fTile1, double *fFcal1, double *fEm3, double *fHec0, double *fPs) +{ + + // Loop in the jet cells: + + std::vector<Trig3Momentum>::iterator gridIt = jet->grid()->begin(); + std::vector<Trig3Momentum>::iterator gridEnd = jet->grid()->end(); + + double eTile1=0, eFcal1=0, eEm3=0, eHec0=0, ePs= 0; + int nCells = 0; + + for (; gridIt != gridEnd; ++gridIt){ + + // consider only cells that are used in the cone: + if(! (*gridIt).inCone()) continue; + nCells++; + + const CaloSampling::CaloSample s = (*gridIt).caloSample(); + double cellE = (*gridIt).e(); + +// if (m_fillLayerInfo) { +// m_layer_info->setRawEnergy(s,cellE); +// } + + switch ( s ) { + case CaloSampling::PreSamplerB: + case CaloSampling::PreSamplerE: + ePs += cellE; + break; + case CaloSampling::EMB3: + case CaloSampling::EME3: + eEm3 += cellE; + break; + case CaloSampling::FCAL0: + eFcal1 += cellE; + break; + case CaloSampling::HEC0: + eHec0 += cellE; + break; + case CaloSampling::TileBar0: + case CaloSampling::TileExt0: + eTile1 += cellE; + break; + default: + /* do nothing */ + break; + + }// end switch - Jet Sampling Layers + + + } // End of loop in cells; + +// if (m_fillLayerInfo) { +// m_layer_info->setRawEnergy(jet->eem0()+jet->ehad0()); +// m_layer_info->setRawEt((jet->eem0()+jet->ehad0())/cosh(jet->eta())); +// m_layer_info->setRawEta(jet->eta()); +// m_layer_info->setRawPhi(jet->phi()); +// m_layer_info->setRoIword(jet->RoIword()); +// m_layer_info->setNCells(nCells); +// } + + if ((jet->eem0()+jet->ehad0())!=0){ + (*fTile1) = eTile1/(jet->eem0()+jet->ehad0()); + (*fFcal1) = eFcal1/(jet->eem0()+jet->ehad0()); + (*fEm3) = eEm3 /(jet->eem0()+jet->ehad0()); + (*fHec0) = eHec0 /(jet->eem0()+jet->ehad0()); + (*fPs) = ePs /(jet->eem0()+jet->ehad0()); + } else { + (*fTile1) = 0; + (*fFcal1) = 0; + (*fEm3) = 0; + (*fHec0) = 0; + (*fPs) = 0; + } + + return StatusCode::SUCCESS; +} + +//--------------------------------------------------------------- +// Calculate hadronic/Electromagnetic component of the jet energy: +//--------------------------------------------------------------- +/*StatusCode T2CaloJetCalibTool::calculateHadEMEnergy(TrigT2Jet* jet, double *HadEnergy, double * EMEnergy) +{ + + // Loop in the jet cells: + + std::vector<Trig3Momentum>::iterator gridIt = jet->grid()->begin(); + std::vector<Trig3Momentum>::iterator gridEnd = jet->grid()->end(); + + (*HadEnergy) = 0; + (*EMEnergy) = 0; + for (; gridIt != gridEnd; ++gridIt){ + + // consider only cells that are used in the cone: + if(! (*gridIt).inCone()) continue; + + const CaloSampling::CaloSample s = (*gridIt).caloSample(); + double cellE = (*gridIt).e(); + + switch ( s ) { + case CaloSampling::PreSamplerB: + case CaloSampling::PreSamplerE: + case CaloSampling::EMB1: + case CaloSampling::EMB2: + case CaloSampling::EMB3: + case CaloSampling::EME1: + case CaloSampling::EME2: + case CaloSampling::EME3: + (*EMEnergy) += cellE; + break; + case CaloSampling::HEC0: + case CaloSampling::HEC1: + case CaloSampling::HEC2: + case CaloSampling::HEC3: + case CaloSampling::TileBar0: + case CaloSampling::TileBar1: + case CaloSampling::TileBar2: + case CaloSampling::TileExt0: + case CaloSampling::TileExt1: + case CaloSampling::TileExt2: + case CaloSampling::TileGap1: + case CaloSampling::TileGap2: + case CaloSampling::TileGap3: + case CaloSampling::FCAL0: + case CaloSampling::FCAL1: + case CaloSampling::FCAL2: + (*HadEnergy) += cellE; + break; + case CaloSampling::Unknown: + (*m_log) << MSG::WARNING + << "Unknown CaloCell type " + << s + << endmsg; + break; + + }// end switch - Jet Sampling Layers + + + } // End of loop in cells; + + + // Cross check that everything went fine: +// +// double eSum = (*HadEnergy)+(*EMEnergy); +// if( eSum != jet->e()){ +// +// (*m_log) << MSG::WARNING << " HadEnergy+EMEnergy != jet->e() !!! HadEnergy, EMEnergy, eSum, jetEnergy =" +// << (*HadEnergy) << ", " << (*EMEnergy) << ", " << eSum << ", " << jet->e() << endmsg; +// std::cout << eSum << ", " << jet->e() << std::endl; +// return StatusCode::FAILURE; +// } +// + + return StatusCode::SUCCESS; +} +*/ diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetConeTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetConeTool.cxx new file mode 100755 index 00000000000..3970145a250 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetConeTool.cxx @@ -0,0 +1,352 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2CaloJetConeTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Cone Tool for all T2CaloJet. Does simple cone alg after data + preparation. + +********************************************************************/ +#include <math.h> +#include "TrigT2CaloJet/T2CaloJetConeTool.h" +#include "TrigCaloEvent/TrigT2Jet.h" + +#include "GaudiKernel/MsgStream.h" + +#include "GaudiKernel/IToolSvc.h" +#include "AthenaKernel/Timeout.h" + +#include <sstream> + + +T2CaloJetConeTool::T2CaloJetConeTool(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent), + m_inCone(0), + m_outCone(0), + m_totalCell(0), + m_pTimerService(NULL), + m_fcal_timer(NULL), + m_other_timer(NULL) +{ + declareProperty("numberOfIterations", m_nIterations = 1); + declareProperty("coneRadius", m_coneRadius = 0.7); + declareProperty("coneFJRadius", m_fj_cone_sizes); + // cleaning: + declareProperty("cellQualityThresholdLAr", m_cellQualityThresholdLAr = 4000); // for jet cleaning + declareProperty("leadingCellFraction", m_leadingCellFraction = 0.9); // for jet cleaning, e.g.: n90 -> leadingCellFraction = 0.9 +} + +T2CaloJetConeTool::~T2CaloJetConeTool() +{ +} + +StatusCode T2CaloJetConeTool::initialize() +{ + MsgStream log(msgSvc(), name()); + // Initialize timing service + if( service( "TrigTimerSvc", m_pTimerService).isFailure() ) { + log << MSG::WARNING << name() << ": Unable to locate TrigTimer Service" + << endmsg; + } + + if (m_pTimerService){ + //Add timers + m_fcal_timer = m_pTimerService->addItem("LVL2_FCal_Cone_Time"); + m_other_timer = m_pTimerService->addItem("LVL2_Other_Cone_Time"); + } + m_inCone=0; + m_outCone=0; + m_totalCell=0; + + // cleaning: + m_cellenergies.reserve(8192); + + // from IAlgToolCalo + m_geometryTool.disable(); + m_data.disable(); + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetConeTool::execute() +{ + return StatusCode::SUCCESS; +} + + +//StatusCode T2CaloJetConeTool::execute(TrigT2Jet* jet,double etamin, double etamax, double phimin, double phimax) +//StatusCode T2CaloJetConeTool::execute(TrigT2Jet* jet,double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/) +StatusCode T2CaloJetConeTool::execute(TrigT2Jet* jet, const IRoiDescriptor& /*roi*/ ) +{ + + MsgStream mLog(msgSvc(), name()); + int outputLevel = msgSvc()->outputLevel( name() ); + if(outputLevel <= MSG::DEBUG) + mLog << MSG::DEBUG << " executing T2CaloJetConeTool " << endmsg; + + + // reset error + m_error = 0x0; + + // do cone iterations on jet. + bool isFCal = fabs(jet->eta())>3.2 ? true : false; + if(isFCal){m_fcal_timer->start(); } + else{ m_other_timer->start(); } + for(int i=0; i<m_nIterations; i++){ + this->coneIteration(jet,i); + if ( Athena::Timeout::instance().reached() ) { + mLog << MSG::ERROR << "Timeout reached in coneIteration" << endmsg; + return StatusCode::FAILURE; + } + } + if(isFCal){m_fcal_timer->stop(); } + else{ m_other_timer->stop(); } + + if(m_fj_cone_sizes.size()==0||m_fj_cone_sizes.size()>3){ + mLog << MSG::WARNING << "FJ cone sizes are incorrectly setup. Using 1/7/4 technique." << endmsg; + } + return StatusCode::SUCCESS; +} + +void T2CaloJetConeTool::coneIteration(TrigT2Jet* jet, int coneIter) +{ + MsgStream mLog(msgSvc(), name()); + + std::vector<Trig3Momentum>* grid = jet->grid(); + + std::vector<Trig3Momentum>::iterator gridItr = grid->begin(); + std::vector<Trig3Momentum>::iterator gridEnd = grid->end(); + + double coneR = m_coneRadius; + + ///////////////////////// + // FCal cone algorithm // + ///////////////////////// + if(fabs(jet->eta())>3.2){ + if(m_fj_cone_sizes.size()==0||m_fj_cone_sizes.size()>3){ + mLog << MSG::DEBUG << "FJ cone sizes are incorrectly setup. Using 1/7/4 technique." << endmsg; + // Cone 1.0/0.7/0.4 Technique + // -Find inital seed looking at the full eta window + // -Subsequent iterations reduce cone size to 0.7 then 0.4 (or default) + if(fabs(jet->eta())>3.2&&coneIter==0){ + coneR=1; + } else if(fabs(jet->eta())>3.2&&coneIter==1){ + coneR=0.7; + } + } else { + coneR = m_fj_cone_sizes.at(coneIter); + } + mLog << MSG::DEBUG << "Iteration " << coneIter + << ", using cone size: " << coneR << endmsg; + } + double dEta = 0, dPhi=0; + + //Check if in FCal, if so find most energetic cell + //double max_e(-999); + double max_eta = jet->eta(); + double max_phi = jet->phi(); + + //Set jet eta & phi + jet->setEta(max_eta); + jet->setPhi(max_phi); + + // activate cells in cone + for(; gridItr!=gridEnd; gridItr++){ + dEta = fabs(jet->eta() - (*gridItr).eta()); + dPhi = fabs(jet->phi() - (*gridItr).phi()); + if (dPhi > M_PI) dPhi = 2*M_PI - dPhi; + + if( dEta*dEta + dPhi*dPhi < coneR*coneR ) { + m_inCone++; + (*gridItr).setInCone(true); + } else { + (*gridItr).setInCone(false); + m_outCone++; + } + m_totalCell++; + } + + // calculate e, eta, phi. + gridItr = grid->begin(); + double eTot=0, eta=0, phi=0, tmpE=0, eThresh=0, tmpPhi=0; + double ehad=0, eem=0; + + double tmpdPhi=0, dphi=0; + + // cleaning: + // initialize cleaning variables + int nLeadingCells = 0; // number of leading cells + float hecf = 0.; // fraction of jet energy in hec + float jetQuality = 0.; // quality of the jet + float emf = 0.; // fraction of jet energy in emc + float jetTimeCells = 0.; // jet time calculated from cells + + // helper functions / variables for cleaning: + m_cellenergies.clear(); + float HECEnergy = 0.; + float EinBadCells = 0.; + bool isTile = false; + bool isLAr = false; + bool qualityTimeIsDefined = false; + float totaltime = 0.; + float norm = 0.; + float cellNorm = 0.; + float totCellE = 0.; // sum of energy in LAr cells with quality defined + + for(; gridItr!=gridEnd; gridItr++){ + if( !(gridItr->inCone()) ) continue; + + // reset flags: + isTile = false; + isLAr = false; + + tmpE = (*gridItr).e(); + eTot += tmpE; // maybe this should be Et weighted + + // Summ contribution to hadronic/EM energy: + const CaloSampling::CaloSample s = (*gridItr).caloSample(); + if( s == CaloSampling::PreSamplerB || s == CaloSampling::PreSamplerE || + s == CaloSampling::EMB1 || s == CaloSampling::EME1 || + s == CaloSampling::EMB2 || s == CaloSampling::EME2 || + s == CaloSampling::EMB3 || s == CaloSampling::EME3 || + s == CaloSampling::FCAL0){ + eem += tmpE; + isLAr = true; // for cleaning + } + if( s == CaloSampling::HEC0 || s == CaloSampling::HEC1|| + s == CaloSampling::HEC2 || s == CaloSampling::HEC3 || + s == CaloSampling::TileBar0 || s == CaloSampling::TileExt0 || + s == CaloSampling::TileBar1 || s == CaloSampling::TileExt1 || + s == CaloSampling::TileBar2 || s == CaloSampling::TileExt2 || + s == CaloSampling::TileGap1 || s == CaloSampling::TileGap2 || + s == CaloSampling::TileGap3 || s == CaloSampling::FCAL1 || + s == CaloSampling::FCAL2) + ehad += tmpE; + + if (tmpE>0){ // threshold from job options? + eThresh += tmpE; + eta += tmpE*(*gridItr).eta(); + tmpPhi = (*gridItr).phi(); + + tmpdPhi = tmpPhi - jet->phi(); // w.r.t Jet + if (tmpdPhi > M_PI) tmpdPhi -= 2*M_PI; + if (tmpdPhi < -1*M_PI) tmpdPhi += 2*M_PI; + + dphi += tmpE*tmpdPhi; // this needs the wrap-around check + + } + + // cleaning: + m_cellenergies.push_back( tmpE ); + if( s == CaloSampling::HEC0 || s == CaloSampling::HEC1 || + s == CaloSampling::HEC2 || s == CaloSampling::HEC3 ) { + HECEnergy += tmpE; + isLAr = true; + } + if( s == CaloSampling::FCAL1 || s == CaloSampling::FCAL2 ){ + isLAr = true; + } + if( s == CaloSampling::TileBar0 || s == CaloSampling::TileBar1 || + s == CaloSampling::TileBar2 || s == CaloSampling::TileGap1 || + s == CaloSampling::TileGap2 || s == CaloSampling::TileGap3 || + s == CaloSampling::TileExt0 || s == CaloSampling::TileExt1 || + s == CaloSampling::TileExt2 ) { + isTile = true; + } + + uint16_t cellprovenance = (*gridItr).provenance(); + // grab cell quality and cell time. + uint16_t cellquality = (*gridItr).quality(); + float celltime = (*gridItr).time(); + qualityTimeIsDefined = false; + + // check for tile + if(isTile){ + // cells with bad quality are masked -> don't take tile into account + // for jet quality calculation. + // provenance not set for tile cells. but time is defined. + // timing: + cellNorm = tmpE * tmpE; + totaltime += cellNorm * celltime; + norm += cellNorm; + } + // check for LAr. only take cells into accout which have time and quality defined + if( (isLAr) && (cellprovenance & 0x2000) ){ + qualityTimeIsDefined = true; + totCellE += tmpE; + // timing: + cellNorm = tmpE * tmpE; + totaltime += cellNorm * celltime; + norm += cellNorm; + } + + if( (isLAr) && (qualityTimeIsDefined) && (cellquality > m_cellQualityThresholdLAr) ){ + EinBadCells += tmpE; + } + + } // end loop over cells + + if(eThresh != 0) { + eta /= eThresh; + phi = dphi/eThresh + jet->phi(); // recover absolute value + + // phi must be between -pi and pi : + if(phi > M_PI) phi -= 2.0* M_PI; + if(phi < -1.0*M_PI) phi += 2.0*M_PI; + } + + // calculate the jet cleaning variables: + // ------------------------------------- + + // sort cell-energy vector. (most energetic cell at end of vector) + std::sort(m_cellenergies.begin(), m_cellenergies.end()); + float sumE = 0.; + for(int k = m_cellenergies.size()-1; k > -1; k--){ + sumE += m_cellenergies[k]; + nLeadingCells++; + if(sumE > m_leadingCellFraction*eTot){ + break; + } + } + + float DELTA = 0.001; // distance to compare floats + if(fabs(eTot)>DELTA){ + hecf = HECEnergy/eTot; + emf = eem/eTot; + } + if(fabs(totCellE)>DELTA){ + jetQuality = EinBadCells/totCellE; + } + if(fabs(norm)>DELTA){ + jetTimeCells = totaltime/norm; + } + + + jet->setE(eTot); + jet->setEem0(eem); + jet->setEhad0(ehad); + jet->setEta(eta); + jet->setPhi(phi); + + // cleaning: + jet -> setNLeadingCells(nLeadingCells); + jet -> setHecf(hecf); + jet -> setJetQuality(jetQuality); + jet -> setEmf(emf); + jet -> setJetTimeCells(jetTimeCells); +} + +StatusCode T2CaloJetConeTool::finalize() +{ + m_cellenergies.clear(); + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromCells.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromCells.cxx new file mode 100644 index 00000000000..7a795861b10 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromCells.cxx @@ -0,0 +1,443 @@ +/* + Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2CaloJetGridFromCells.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Data preparation from Cells + +********************************************************************/ +#include "TrigT2CaloJet/T2CaloJetGridFromCells.h" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigT2CaloJet/T2AllRoiUnpacking.h" + +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IToolSvc.h" + +// should use this, but needs fixes +//#include "TrigT2CaloCommon/ITrigDataAccess.h" +// instead, use this one +#include "TrigT2CaloCommon/TrigDataAccess.h" +#include "AthenaKernel/Timeout.h" + +#include <algorithm> +#include <sstream> + +T2CaloJetGridFromCells::T2CaloJetGridFromCells(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent), + m_noiseCutValue(2.) , + m_cablingSvc("LArCablingLegacyService"), + m_noiseTool("CaloNoiseTool/CaloNoiseToolDefault"), + m_forbiddenRegions(0), + m_timerSvc(0) +{ + declareProperty("doTiming", m_doTiming= false ); + declareProperty("cablingSvc", m_cablingSvc, "cabling svc"); + declareProperty("noiseTool", m_noiseTool, "handle for noise tool"); + declareProperty("applyNoiseCut", m_applyNoiseCut = false); + declareProperty("noiseCutValue", m_noiseCutValue ); + declareProperty("doHECcellQualityCleaning", m_doHECcellQualityCleaning = false); // switch for cell based jet cleaning + declareProperty("cellQualityThresholdHEC", m_cellQualityThresholdHEC = 65535); // for cell based jet cleaning + +} + +T2CaloJetGridFromCells::~T2CaloJetGridFromCells() +{ +} + + +StatusCode T2CaloJetGridFromCells::initialize() +{ + + ATH_MSG_VERBOSE(" In initalize() "); + + ATH_CHECK(m_data.retrieve()); + +/// noise suppression + if(m_applyNoiseCut!=0){ + ATH_CHECK( m_noiseTool.retrieve() ); + + ATH_CHECK( m_cablingSvc.retrieve() ); + } else { + m_noiseTool.disable(); + m_cablingSvc.disable(); + } + + // Retrieve timing service + + if (m_doTiming) { + + StatusCode sc = service("TrigTimerSvc", m_timerSvc); + if (sc.isFailure()) { + ATH_MSG_ERROR( "unable to locate timing service TrigTimerSvc." + << " Setting doTiming = false!!! " ); + m_timerSvc = 0; + m_doTiming=false; + //return sc; + } + else{ + + std::string prefix = name() + ":"; + + // Define now the timers: + std::string label = prefix+"LArUnpck"; + TrigTimer *timer = m_timerSvc->addItem(label); + m_timers["LArUnpck"] = timer; + + label = prefix+"TileUnpck"; + timer = m_timerSvc->addItem( label); + m_timers["TileUnpck"] = timer; + + label = prefix+"HECUnpck"; + timer = m_timerSvc->addItem(label); + m_timers["HECUnpck"] = timer; + + } + } + + // from IAlgToolCalo + m_geometryTool.disable(); + + m_gridElement = new Trig3Momentum(); + + return StatusCode::SUCCESS; +} + +TrigTimer* T2CaloJetGridFromCells::getTimer(const std::string& timerName){ + + if (!m_doTiming ) return 0; + + std::map<std::string, TrigTimer*>::const_iterator t = m_timers.find(timerName); + if (t == m_timers.end()) { + ATH_MSG_DEBUG( " Timer " << timerName << " not found." ); + return 0; + } + + + return (*t).second; + +} + + +StatusCode T2CaloJetGridFromCells::execute() +{ + return StatusCode::SUCCESS; +} + + +//StatusCode T2CaloJetGridFromCells::execute(TrigT2Jet +//* jet,double etamin, double etamax, double phimin, double phimax) +StatusCode T2CaloJetGridFromCells::execute(TrigT2Jet +* jet,const IRoiDescriptor& roi ) +{ + + // reset error + m_error = 0x0; + + // this method should use region selector to get cells and fill grid + // of Trig3Momentum. + + // reset error + m_error = 0x0; + std::vector<Trig3Momentum>* grid = new std::vector<Trig3Momentum>(); + grid->reserve(8000); + + + //m_gridElement = new Trig3Momentum(); + // add all cells to grid + + StatusCode sc = addAllCells(roi.etaMinus(),roi.etaPlus(), roi.phiMinus(), roi.phiPlus(), grid); + if(sc.isFailure()){ + ATH_MSG_DEBUG( " Failure of addAllCells. Empty grid! " ); + } + + //then set the grid in the jet. do not delete anything. Cleanup + //happens at the end of jet finding. + jet->setGrid(grid); + + //delete m_gridElement; + //m_gridElement = 0; + + return StatusCode::SUCCESS; +} + + +StatusCode T2CaloJetGridFromCells::addAllCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid) +{ + + //This could check job options for a list of samplings to consider. + //We may not want to use presampler or strips. + + if(m_doTiming) getTimer("LArUnpck")->start(); + + //Now EM + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTEM, 0, true).isFailure() ){ + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTEM, 1, true).isFailure() ) { + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTEM, 2, true).isFailure() ) { + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTEM, 3, true).isFailure() ) { + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(m_doTiming){ + getTimer("LArUnpck")->stop(); + getTimer("HECUnpck")->start(); + } + + //Now HEC + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTHEC, 0, true).isFailure() ) { + if(m_doTiming) getTimer("HECUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTHEC, 1, true).isFailure() ) { + if(m_doTiming) getTimer("HECUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTHEC, 2, true).isFailure() ) { + if(m_doTiming) getTimer("HECUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArCells(etamin, etamax, phimin, phimax, grid, TTHEC, 3, true).isFailure() ) { + if(m_doTiming) getTimer("HECUnpck")->stop(); + return StatusCode::FAILURE; + } + if(m_doTiming){ + getTimer("HECUnpck")->stop(); + getTimer("TileUnpck")->start(); + } + + //Now Tile + // only prepare for first sampling, because containers created then. + if(addTileCells(etamin, etamax, phimin, phimax, grid, TILE, 0, true).isFailure() ){ + if(m_doTiming) getTimer("TileUnpck")->stop(); + return StatusCode::FAILURE; + } + + //Now FCAL + if(addLArCells(etamin, etamax, phimin, phimax, grid, FCALEM, 0, true).isFailure() ) + return StatusCode::FAILURE; + + if(addLArCells(etamin, etamax, phimin, phimax, grid, FCALHAD, 0, true).isFailure() ) + return StatusCode::FAILURE; + + if(addLArCells(etamin, etamax, phimin, phimax, grid, FCALHAD, 1, true).isFailure() ) + return StatusCode::FAILURE; + +/* if(addTileCells(etamin, etamax, phimin, phimax, grid, TILE, 1, false).isFailure() ) { + if(m_doTiming) getTimer("TileUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addTileCells(etamin, etamax, phimin, phimax, grid, TILE, 2, false).isFailure() ) { + if(m_doTiming) getTimer("TileUnpck")->stop(); + return StatusCode::FAILURE; + }*/ + + if(m_doTiming) getTimer("TileUnpck")->stop(); + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromCells::addLArCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool prepare) +{ + + // Get detector offline ID's for Collections + m_data->RegionSelector(sampling,etamin,etamax,phimin,phimax, detectorID); + + // Prepare data, load collections + if ( m_data->LoadCollections(m_iBegin,m_iEnd, sampling, prepare).isFailure() ){ + return StatusCode::FAILURE; + } + + m_error|=m_data->report_error(); + + bool vetoRegions(m_forbiddenRegions.size() > 0); + // Main Loop over cells + const LArCell* larcell; + for(m_it = m_iBegin;m_it != m_iEnd; ++m_it) { + + // possibly do some noise thresholding + larcell = *m_it; + + // possibly do some calibration + // may want sampling. example: + CaloSampling::CaloSample samp; + //samp = CaloSampling::getSampling(*larcell); + samp = larcell->caloDDE()->getSampling(); + + // cell based cleaning: + // -------------------- + // check if cell cleaning is requested and if the cell is in hec: + bool isHECandDoCleaning = false; + if( m_doHECcellQualityCleaning && ( samp == CaloSampling::HEC0 || samp == CaloSampling::HEC1 || + samp == CaloSampling::HEC2 || samp == CaloSampling::HEC3 ) ) { + isHECandDoCleaning = true; + } + // now test for cell quality + if( isHECandDoCleaning && larcell -> quality() >= m_cellQualityThresholdHEC ) { + continue; + } + // end (cell based) cleaning + + // possibly do some tower building + + double cellE = larcell->e(); + if(m_applyNoiseCut){ + double larnoise = m_noiseTool->getNoise(larcell, + ICalorimeterNoiseTool::TOTALNOISE); + //std::cout << "noise rms in LAr = " << larnoise << std::endl; + if(m_applyNoiseCut && fabs(cellE) < (m_noiseCutValue*larnoise)) continue; + } + + double eta(larcell->eta()); + double phi(larcell->phi()); + if(vetoRegions && isInVetoRegion(eta, phi)) continue; + // for now fill grid elements like this +// gridElement = new Trig3Momentum(); + m_gridElement->setE(cellE); + m_gridElement->setEta(eta); + m_gridElement->setPhi(phi); + m_gridElement->setCaloSample(samp); + // jet cleaning: + m_gridElement->setProvenance( larcell -> provenance() ); + m_gridElement->setQuality( larcell -> quality() ); + m_gridElement->setTime( larcell -> time() ); + + //push them back into the grid + grid->push_back(*m_gridElement); + + } + + if ( Athena::Timeout::instance().reached() ) { + ATH_MSG_ERROR( "Timeout reached in addLArCells " ); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + + +StatusCode T2CaloJetGridFromCells::addTileCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool /*prepare*/) +{ + + // Get detector offline ID's for Collections + m_data->RegionSelector(sampling,etamin,etamax,phimin,phimax, detectorID); + + // Prepare data, load collections + + for( unsigned int iR=0; iR!=m_data->TileContSize();++iR ){ + if ( m_data->LoadCollections(m_itBegin,m_itEnd, iR, !iR).isFailure() ){ + return StatusCode::FAILURE; + } + + m_error|=m_data->report_error(); + + bool vetoRegions(m_forbiddenRegions.size() > 0); + +// std::cout << "No of cells in Tile = " << m_data->TileContSize() << std::endl; + // Main Loop over cells + const TileCell* tilecell; + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) { + tilecell = *m_itt; + + // possibly do some noise thresholding + + // possibly do some calibration + // may want sampling. example: + CaloSampling::CaloSample samp; + //samp = CaloSampling::getSampling(*tilecell); + samp = tilecell->caloDDE()->getSampling(); + + + double cellE = tilecell->e(); +// do noise thresholding + + if(m_applyNoiseCut) { + double tilenoise = m_noiseTool->getNoise(tilecell, + ICalorimeterNoiseTool::TOTALNOISE); + if(m_applyNoiseCut && fabs(cellE) < (m_noiseCutValue*tilenoise)) continue; + } + + // possibly do some tower building + + double eta(tilecell->eta()); + double phi(tilecell->phi()); + if(vetoRegions && isInVetoRegion(eta, phi)) continue; + + // for now fill grid elements like this +// gridElement = new Trig3Momentum(); + m_gridElement->setE(cellE); + m_gridElement->setEta(eta); + m_gridElement->setPhi(phi); + m_gridElement->setCaloSample(samp); + // jet cleaning: + m_gridElement->setProvenance( tilecell -> provenance() ); + m_gridElement->setQuality( tilecell -> quality() ); + m_gridElement->setTime( tilecell -> time() ); + + //push them back into the grid + grid->push_back(*m_gridElement); + + + } + if ( Athena::Timeout::instance().reached() ) { + ATH_MSG_ERROR( "Timeout reached in addTileCells " ); + return StatusCode::FAILURE; + } + } + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromCells::finalize() +{ + delete m_gridElement; + m_gridElement = 0; + return StatusCode::SUCCESS; +} + +// Just a functor so that I can use EtaPhiRectangle::contains within a std algorithm. +struct EtaPhiRectInsideChecker : public std::unary_function<EtaPhiRectangle, bool> { + double eta_, phi_; + EtaPhiRectInsideChecker(const double &eta, const double &phi): eta_(eta), phi_(phi) {} ; + bool operator() (const EtaPhiRectangle &r) const { + return r.contains(eta_, phi_); + } +}; + +bool T2CaloJetGridFromCells::isInVetoRegion(const double &eta, const double &phi){ + ATH_MSG_DEBUG("T2CaloJetGridFromCells::isInVetoRegion --DG-- checking" + <<" ("<<eta<<", "<<phi<<")" + <<" against "<<m_forbiddenRegions.size()<<" forbidden regions" ); + return + m_forbiddenRegions.end() != + std::find_if(m_forbiddenRegions.begin(), + m_forbiddenRegions.end(), + EtaPhiRectInsideChecker(eta,phi)); +} + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromFEBHeader.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromFEBHeader.cxx new file mode 100755 index 00000000000..1039d73c23f --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromFEBHeader.cxx @@ -0,0 +1,381 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2CaloJetGridFromFEBHeader.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> + Ignacio Aracena <ignacio.aracena@cern.ch> + +CREATED: November, 2005 + +PURPOSE: Data preparation from FEB Header (Ex,Ey,Ez) + +********************************************************************/ +#include "TrigT2CaloJet/T2CaloJetGridFromFEBHeader.h" +#include "TrigCaloEvent/TrigT2Jet.h" + +#include "GaudiKernel/MsgStream.h" + +#include "GaudiKernel/IToolSvc.h" +#include "TrigT2CaloCommon/TrigDataAccess.h" +#include "AthenaKernel/Timeout.h" + +T2CaloJetGridFromFEBHeader::T2CaloJetGridFromFEBHeader(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent), + m_gridElement(NULL), + m_usedfeb(NULL), + m_timerSvc(0) +{ + declareProperty("doTiming", m_doTiming= false ); +} + +T2CaloJetGridFromFEBHeader::~T2CaloJetGridFromFEBHeader() +{ +} + +StatusCode T2CaloJetGridFromFEBHeader::initialize() +{ + + ATH_MSG_VERBOSE(" In initalize() "); + + ATH_CHECK( m_data.retrieve() ); + + // Retrieve timing service + + if (m_doTiming) { + + StatusCode sc = service("TrigTimerSvc", m_timerSvc); + if (sc.isFailure()) { + ATH_MSG_ERROR( "unable to locate timing service TrigTimerSvc." + << " Setting doTiming = false!!! " ); + m_timerSvc = 0; + m_doTiming=false; + //return sc; + } + else{ + + std::string prefix = name() + ":"; + + // Define now the timers: + std::string label = prefix+"LArUnpck"; + TrigTimer *timer = m_timerSvc->addItem(label); + m_timers["LArUnpck"] = timer; + + label = prefix+"TileUnpck"; + timer = m_timerSvc->addItem( label); + m_timers["TileUnpck"] = timer; + + label = prefix+"HECUnpck"; + timer = m_timerSvc->addItem(label); + m_timers["HECUnpck"] = timer; + + } + } + + // from IAlgToolCalo + m_geometryTool.disable(); + + return StatusCode::SUCCESS; +} + +TrigTimer* T2CaloJetGridFromFEBHeader::getTimer(const std::string& timerName){ + + if (!m_doTiming ) return 0; + + std::map<std::string, TrigTimer*>::const_iterator t = m_timers.find(timerName); + if (t == m_timers.end()) { + ATH_MSG_DEBUG(" Timer " << timerName << " not found."); + return 0; + } + + + return (*t).second; + +} + +StatusCode T2CaloJetGridFromFEBHeader::execute() +{ + return StatusCode::SUCCESS; +} + + +StatusCode T2CaloJetGridFromFEBHeader::execute(TrigT2Jet +* jet,double etamin, double etamax, double phimin, double phimax) +{ + + // Time total AlgTool time +// if (m_timersvc) m_timer[0]->start(); + + // this method should use region selector to get RODs, retrieve FEB + // Header, find eta for each FEB, and fill grid of Trig3Momentum. + + ATH_MSG_DEBUG(" executing T2CaloJetGridFromFEBHeader "); + + + std::vector<Trig3Momentum>* grid = new std::vector<Trig3Momentum>(); + + // now get ROD, FEB + + // turn ex,ey to e,eta,phi + + // possibly do some calibration + + // possibly do some tower building + + // now fill grid elements like this + m_gridElement = new Trig3Momentum(); + + m_usedfeb = new std::vector<int>; +/* if (m_timersvc) m_timer[1]->start(); + if (m_timersvc) m_timer[1]->pause(); + if (m_timersvc) m_timer[2]->start(); + if (m_timersvc) m_timer[2]->pause(); + if (m_timersvc) m_timer[3]->start(); + if (m_timersvc) m_timer[3]->pause(); + if (m_timersvc) m_timer[4]->start(); + if (m_timersvc) m_timer[4]->pause(); + + if (m_timersvc) m_timer[5]->start();*/ + + StatusCode sc = addFebEnergies(etamin, etamax, phimin, phimax, grid); + if(sc.isFailure()){ + ATH_MSG_DEBUG(" Failure of addFebEnergies. Empty grid! "); + } + +// gridElement->setE(10000.); +// gridElement->setEta(1.); +// gridElement->setPhi(0.); + + //push them back into the grid +// grid->push_back(*gridElement); + + + //then set the grid in the jet. do not delete anything. Cleanup + //happens at the end of jet finding. + jet->setGrid(grid); + + delete m_gridElement; + m_gridElement = 0; + delete m_usedfeb; + m_usedfeb = 0; + +/* if (m_timersvc) m_timer[5]->stop(); + if (m_timersvc) m_timer[0]->stop(); + if (m_timersvc) m_timer[1]->stop(); + if (m_timersvc) m_timer[2]->stop(); + if (m_timersvc) m_timer[3]->stop(); + if (m_timersvc) m_timer[4]->stop(); +*/ + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromFEBHeader::addFebEnergies(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid) +{ + + + if(m_doTiming) getTimer("LArUnpck")->start(); + if(addLArFebEnergy(etamin,etamax,phimin,phimax,grid,TTEM, 0, true).isFailure() ){ + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArFebEnergy(etamin,etamax,phimin,phimax,grid,TTEM, 1, true).isFailure() ){ + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArFebEnergy(etamin,etamax,phimin,phimax,grid,TTEM, 2, true).isFailure() ){ + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + if(addLArFebEnergy(etamin,etamax,phimin,phimax,grid,TTEM, 3, true).isFailure() ){ + if(m_doTiming) getTimer("LArUnpck")->stop(); + return StatusCode::FAILURE; + } + + if(m_doTiming){ + getTimer("LArUnpck")->stop(); + getTimer("HECUnpck")->start(); + } + + //Now HEC + // Do not need to loop over all the samplings when reading HEC FEBs + if(addLArFebEnergy(etamin, etamax, phimin, phimax, grid, TTHEC, 0, true).isFailure() ){ + if(m_doTiming) getTimer("HECUnpck")->stop(); + return StatusCode::FAILURE; + } +// if(addLArFebEnergy(etamin, etamax, phimin, phimax, grid, TTHEC, 1, true).isFailure() ) +// return StatusCode::FAILURE; +// if(addLArFebEnergy(etamin, etamax, phimin, phimax, grid, TTHEC, 2, true).isFailure() ) +// return StatusCode::FAILURE; +//Now FCAL + if(addLArFebEnergy(etamin, etamax, phimin, phimax, grid, FCALEM, 0, true).isFailure() ) + return StatusCode::FAILURE; + //std::cout << "NOW TRY FCALHAD 0" << std::endl; + if(addLArFebEnergy(etamin, etamax, phimin, phimax, grid, FCALHAD, 0, true).isFailure() ) + return StatusCode::FAILURE; + //std::cout << "NOW TRY FCALHAD 1" << std::endl; + if(addLArFebEnergy (etamin, etamax, phimin, phimax, grid, FCALHAD, 1, true).isFailure() ) + return StatusCode::FAILURE; + if(m_doTiming){ + getTimer("HECUnpck")->stop(); + getTimer("TileUnpck")->start(); + } + + + + if(addTileCells(etamin, etamax, phimin, phimax, grid, TILE, 0, true).isFailure() ){ + if(m_doTiming) getTimer("TileUnpck")->stop(); + return StatusCode::FAILURE; + } + + if(m_doTiming) getTimer("TileUnpck")->stop(); + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromFEBHeader::addLArFebEnergy(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool prepare) +{ + + // Time to access RegionSelector +// if (m_timersvc) m_timer[1]->resume(); + + m_data->RegionSelector(sampling,etamin,etamax,phimin,phimax,detectorID); +// if (m_timersvc) m_timer[1]->pause(); + + // Time to access Collection +// if (m_timersvc) m_timer[2]->resume(); + + if ( m_data->LoadCollections(m_iFebBegin,m_iFebEnd, sampling , prepare).isFailure() ) + return StatusCode::FAILURE; +// if (m_timersvc) m_timer[2]->pause(); + + // Algorithmic time +// if (m_timersvc) m_timer[4]->resume(); + + for(m_Febit=m_iFebBegin ;m_Febit!=m_iFebEnd; ++m_Febit){ + + bool used=false; + CaloSampling::CaloSample samp=CaloSampling::Unknown; + if(detectorID == TTHEC){ +// + samp = CaloSampling::HEC0; + } + if(detectorID == TTEM){ + int febid = (*m_Febit)->getFebId(); + int idit = 0; + int iditend = m_usedfeb->size(); + /* avoid double-counting of EM FEBs */ + for(;idit!=iditend; ++idit){ + if(febid == (*m_usedfeb)[idit] ){ + used = true; + idit++; + break; + } + } + m_usedfeb->push_back(febid); + samp = CaloSampling::EMB1; + // std::cout << "In the TTEM; E_tot = " << FebEnergy << std::endl; + } + + if(!used ){ + double FebEnergy = sqrt( ((*m_Febit)->getFebEx())*((*m_Febit)->getFebEx()) + + ((*m_Febit)->getFebEy())*((*m_Febit)->getFebEy()) + + ((*m_Febit)->getFebEz())*((*m_Febit)->getFebEz()) ); + + double phi = atan2((*m_Febit)->getFebEy(),(*m_Febit)->getFebEx()); + double eta = atanh((*m_Febit)->getFebEz()/FebEnergy); + m_gridElement->setE(FebEnergy); + m_gridElement->setEta(eta); + m_gridElement->setPhi(phi); + m_gridElement->setCaloSample(samp); + grid->push_back(*m_gridElement); + } + } + + if ( Athena::Timeout::instance().reached() ) { + ATH_MSG_ERROR("Timeout reached in addLArFebEnergy"); + return StatusCode::FAILURE; + } +// if (m_timersvc) m_timer[4]->pause(); + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromFEBHeader::addTileCells(double etamin, double etamax, + double phimin, double phimax, + std::vector<Trig3Momentum>* grid, + DETID detectorID, int sampling, + bool /*prepare*/) +{ + + // Time to access RegionSelector +// if (m_timersvc) m_timer[1]->resume(); + // Get detector offline ID's for Collections + m_data->RegionSelector(sampling,etamin,etamax,phimin,phimax, detectorID); + +// if (m_timersvc) m_timer[1]->pause(); + // Prepare data, load collections + + for( unsigned int iR=0; iR!=m_data->TileContSize();++iR ){ + // Time to access Collection +// if (m_timersvc) m_timer[3]->resume(); + + if ( m_data->LoadCollections(m_itBegin,m_itEnd, iR, !iR).isFailure() ) + return StatusCode::FAILURE; + +// if (m_timersvc) m_timer[3]->pause(); + // } + + + // Algorithmic time +// if (m_timersvc) m_timer[4]->resume(); + + // Main Loop over cells + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) { + + // possibly do some noise thresholding + + // possibly do some calibration + // may want sampling. example: + CaloSampling::CaloSample samp; + //samp = CaloSampling::getSampling(*(*m_itt)); + samp = (*m_itt)->caloDDE()->getSampling(); + + // possibly do some tower building + + // for now fill grid elements like this +// gridElement = new Trig3Momentum(); + m_gridElement->setE((*m_itt)->e()); + m_gridElement->setEta((*m_itt)->eta()); + m_gridElement->setPhi((*m_itt)->phi()); + m_gridElement->setCaloSample(samp); + //push them back into the grid + grid->push_back(*m_gridElement); + + } +// if (m_timersvc) m_timer[4]->pause(); + } + + if ( Athena::Timeout::instance().reached() ) { + ATH_MSG_ERROR( "Timeout reached in addTileCells " ); + return StatusCode::FAILURE; + } + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromFEBHeader::finalize() +{ + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromLvl1Ppr.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromLvl1Ppr.cxx new file mode 100755 index 00000000000..0e89335a84d --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2CaloJetGridFromLvl1Ppr.cxx @@ -0,0 +1,92 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2CaloJetGridFromLvl1Ppr.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Kyle Cranmer <cranmer@cern.ch> +CREATED: November, 2005 + +PURPOSE: Data preparation from Lvl1 Calo + +********************************************************************/ +#include "TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h" +#include "TrigCaloEvent/TrigT2Jet.h" + +#include "GaudiKernel/MsgStream.h" + +#include "GaudiKernel/IToolSvc.h" + +T2CaloJetGridFromLvl1Ppr::T2CaloJetGridFromLvl1Ppr(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent), m_gridElement(0) +{ +} + +T2CaloJetGridFromLvl1Ppr::~T2CaloJetGridFromLvl1Ppr() +{ +} + +StatusCode T2CaloJetGridFromLvl1Ppr::initialize() +{ + if ( !m_gridElement ) m_gridElement = new Trig3Momentum(); + + // from IAlgToolCalo + m_geometryTool.disable(); + m_data.disable(); + + return StatusCode::SUCCESS; +} + +StatusCode T2CaloJetGridFromLvl1Ppr::execute() +{ + return StatusCode::SUCCESS; +} + + +//StatusCode T2CaloJetGridFromLvl1Ppr::execute(TrigT2Jet +//* jet,double etamin, double etamax, double phimin, double phimax) +StatusCode T2CaloJetGridFromLvl1Ppr::execute(TrigT2Jet* jet, + double /*etamin*/, + double /*etamax*/, + double /*phimin*/, + double /*phimax*/) +{ + + // this method should use region selector to get TriggerTowers from + // the Lvl1 PreProcessor. Will require some chages to Region Selector + + std::vector<Trig3Momentum>* grid = new std::vector<Trig3Momentum>(); + + // now get TT's + + // possibly do some calibration + + // now fill grid elements like this + Trig3Momentum* gridElement = m_gridElement; + gridElement->setE(10000.); + gridElement->setEta(1.); + gridElement->setPhi(0.); + + //push them back into the grid + grid->push_back(*gridElement); + + + //then set the grid in the jet. do not delete anything. Cleanup + //happens at the end of jet finding. + jet->setGrid(grid); + + return StatusCode::SUCCESS; +} + + +StatusCode T2CaloJetGridFromLvl1Ppr::finalize() +{ + if ( m_gridElement ) delete m_gridElement; + m_gridElement = 0; + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloFullScanJet.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloFullScanJet.cxx new file mode 100644 index 00000000000..750fde7e612 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloFullScanJet.cxx @@ -0,0 +1,322 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2L1CaloFullScanJet.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett +// ******************************************************************** + + +#include "GaudiKernel/IToolSvc.h" + + +#include "TrigT1Interfaces/TrigT1Interfaces_ClassDEF.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigCaloEvent/TrigT2JetContainer.h" +#include "TrigT2CaloJet/T2L1CaloFullScanJet.h" +#include "TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h" +#include "TrigTimeAlgs/TrigTimer.h" + +#include <sys/time.h> + +#include <math.h> + +class ISvcLocator; + +T2L1CaloFullScanJet::T2L1CaloFullScanJet(const std::string & name, ISvcLocator* pSvcLocator) + : HLT::AllTEAlgo(name, pSvcLocator), + m_jets(0), + m_tools(this) + +{ declareProperty("T2JetTools", m_tools, "L1.5 Full Scan Tools"); + declareProperty("jetOutputKey", m_jetOutputKey = "TrigT2CaloJet"); + // debug + declareProperty("recordOutput", m_recordOutput = true); + + declareMonitoredVariable("nJets", m_nJets); + declareMonitoredVariable("nTowers", m_nTowers); + declareMonitoredVariable("UnpckTime", m_UnpckTime); + declareMonitoredVariable("L1_UnpckTime", m_L1_UnpckTime); + declareMonitoredVariable("FastJetTime", m_FastJetTime); + declareMonitoredVariable("JetFindingTime", m_JetFindingTime); + declareMonitoredVariable("OverallTime", m_TotalTime); + declareMonitoredVariable("RoITime", m_RoITime); + declareMonitoredStdContainer("E", m_e); + declareMonitoredStdContainer("Et", m_et); + declareMonitoredStdContainer("Eem", m_eem); + declareMonitoredStdContainer("Ehad", m_ehad); + declareMonitoredStdContainer("Etem", m_etem); + declareMonitoredStdContainer("Ethad",m_ethad); + declareMonitoredStdContainer("Eta", m_eta); + declareMonitoredStdContainer("Phi", m_phi); + declareMonitoredStdContainer("Emf", m_emfrac); + declareMonitoredStdContainer("nLeadingTowers", m_nLeadingTowers); +} + +HLT::ErrorCode T2L1CaloFullScanJet::hltInitialize() +{ + m_log = new MsgStream(msgSvc(), name()); + + if((*m_log).level() <= MSG::INFO){ + (*m_log) << MSG::INFO << " Initalizing FEX algorithm: " << name() << endmsg; + (*m_log) << MSG::DEBUG << "Options: " << endmsg; + (*m_log) << MSG::DEBUG << " jetOutputKey: " << m_jetOutputKey << endmsg; + (*m_log) << MSG::DEBUG << " recordOutput: " << m_recordOutput << endmsg; + } + + if (timerSvc()) { + m_timer.push_back(addTimer("TimeTot")); + m_timer.push_back(addTimer("RoIMaking")); + } + + if ( m_tools.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_tools << endmsg; + } else { + (*m_log) << MSG::DEBUG << "Retrieved l1.5 full scan tools: " << m_tools << endmsg; + } + + // add timers for the tools + if (timerSvc()) { + ToolHandleArray< T2L1CaloJetFullScanBaseTool >::iterator itTool = m_tools.begin(), + itToolEnd = m_tools.end(); + for ( ; itTool != itToolEnd; ++itTool ) { + if((*m_log).level() <= MSG::DEBUG) + (*m_log) << MSG::DEBUG <<"Tool with name " << (*itTool).name()<< endmsg; + + m_timer.push_back(addTimer((*itTool).name())); + } + } + + m_jets = new DataVector<TrigT2Jet>(SG::VIEW_ELEMENTS); + m_jets->reserve(100); + + m_e.reserve(100); + m_et.reserve(100); + m_eem.reserve(100); + m_ehad.reserve(100); + m_etem.reserve(100); + m_ethad.reserve(100); + m_eta.reserve(100); + m_phi.reserve(100); + m_emfrac.reserve(100); + m_nLeadingTowers.reserve(100); + + return HLT::OK; +} + +T2L1CaloFullScanJet::~T2L1CaloFullScanJet(){ +} + +HLT::ErrorCode T2L1CaloFullScanJet::hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& /*tes_in*/, + unsigned int type_out) +{ + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + beforeExecMonitors().ignore(); + + if(timerSvc()) m_timer[0]->start(); + + m_nJets = -99; + m_nTowers = -99; + m_UnpckTime = -99; + m_L1_UnpckTime = -99; + m_FastJetTime = -99; + m_JetFindingTime = -99; + m_TotalTime = -99; + m_RoITime = -99; + m_e.clear(); + m_et.clear(); + m_eem.clear(); + m_ehad.clear(); + m_etem.clear(); + m_ethad.clear(); + m_eta.clear(); + m_phi.clear(); + m_emfrac.clear(); + m_nLeadingTowers.clear(); + m_jets->clear(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "================= Executing T2L1CaloFullScanJet FEX " << name() << endmsg; + //(*m_log) << MSG::DEBUG << "m_jetOutputKey: " << m_jetOutputKey << endmsg; + } +#endif + + DataVector<TrigT2Jet>::const_iterator begin_jet, end_jet; // iterators for the produced jets + + // ====== Run the tools + // do loop over tools + ToolHandleArray< T2L1CaloJetFullScanBaseTool >::iterator itTool = m_tools.begin(), + itToolEnd = m_tools.end(); + + int currant_tool=0; + //uint32_t error = 0; + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Looping over tools vector" << endmsg; + } +#endif + + for ( ; itTool != itToolEnd; ++itTool ) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Running tool: [" << currant_tool+1 << "] of " << m_tools.size() << endmsg; + (*m_log) << MSG::DEBUG << "Alg name: " << (*itTool)->name() << endmsg; + } +#endif + + if (timerSvc()) m_timer[currant_tool+2]->start(); // offset = number of other timers + + if ((*itTool)->execute(m_jets,m_nTowers,m_L1_UnpckTime,m_UnpckTime,m_FastJetTime,m_JetFindingTime).isFailure()){ + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::WARNING << "T2L1CaloJet AlgTool returned Failure" << endmsg; + } + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + } + + //uint32_t in_error = (*itTool)->report_error(); + //error|=in_error; + + if (timerSvc()) m_timer[currant_tool+2]->stop(); + currant_tool++; + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "=== Finished jet finding" << endmsg; + (*m_log) << MSG::DEBUG << " Towers unpacked: " << m_nTowers << " in " << m_UnpckTime << " ms, of this L1 unpacking took "<< m_L1_UnpckTime << " ms" << endmsg; + (*m_log) << MSG::DEBUG << " T2CaloJets found: " << m_jets->size() << " in " << m_JetFindingTime << " ms, of this FastJet took " << m_FastJetTime << " ms" << endmsg; + if (m_UnpckTime > 50){ + (*m_log) << MSG::DEBUG << " That was a long time " << endmsg; + } + + begin_jet = m_jets->begin(); + end_jet = m_jets->end(); + int jet_counter = 0; + for (; begin_jet != end_jet; ++begin_jet){ + (*m_log) << MSG::DEBUG << " T2CaloJet["<<jet_counter + << "]: Et: " << (*begin_jet)->et() + << " MeV, eta: " << (*begin_jet)->eta() + << ", phi; " << (*begin_jet)->phi() << endmsg; + jet_counter++; + } + } +#endif + // ====== now monitor record and attach features + + if(timerSvc()) m_timer[1]->start(); // start of RoI recording + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Monitoring, recording and attaching features" << endmsg; + (*m_log) << MSG::DEBUG << "Using L2 output jet key = " << m_jetOutputKey << endmsg; + } +#endif + + m_nJets = m_jets->size(); + + // store the final jets into an output TE. + HLT::TriggerElement* outputTE = 0; + std::string key = ""; + int recorded_jet_counter = 0; + if (m_recordOutput){ + outputTE = addRoI(type_out, new TrigRoiDescriptor(true)); + outputTE->setActiveState(true); + + } else { + //outputTE->setActiveState(false); + } + + begin_jet = m_jets->begin(); + end_jet = m_jets->end(); + for (; begin_jet != end_jet; ++begin_jet){ + m_jet = (*begin_jet); + + // Monitor + m_e.push_back( m_jet->e()); + m_et.push_back( m_jet->et()); + m_eta.push_back( m_jet->eta() ); + m_phi.push_back( m_jet->phi() ); + m_eem.push_back( m_jet->eem0()); + m_ehad.push_back( m_jet->ehad0()); + m_etem.push_back( (m_jet->eem0()/cosh(m_jet->eta()))); + m_ethad.push_back( (m_jet->ehad0()/cosh(m_jet->eta()))); + m_emfrac.push_back( m_jet->emf() ); + m_nLeadingTowers.push_back( m_jet->nLeadingCells() ); + + if (m_recordOutput){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " recording T2CaloJet["<<recorded_jet_counter<<"]"<<endmsg; + } +#endif + // store each jet as we go along so they're in the standard T2JetContainer + + HLT::ErrorCode hltStatus = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (hltStatus != HLT::OK){ + (*m_log) << MSG::ERROR << "recording of TrigT2Jet into StoreGate failed" << endmsg; + return hltStatus; + } + + recorded_jet_counter++; + } + + + + } + + + if(timerSvc()) m_timer[1]->stop(); // end of RoI recording + + if(timerSvc()) m_timer[0]->stop(); // end of execute + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "RoI making time: " << m_timer[1]->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "Total time: " << m_timer[0]->elapsed() << " ms " << endmsg; + if (m_timer[0]->elapsed() > 50){ + (*m_log) << MSG::DEBUG << "That was a long time " << endmsg; + } + (*m_log) << MSG::DEBUG << "================= Finished T2L1CaloFullScanJet FEX " << name() << endmsg; + } +#endif + + m_TotalTime = m_timer[0]->elapsed(); + m_RoITime = m_timer[1]->elapsed(); + + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + afterExecMonitors().ignore(); + + return HLT::OK; +} + + +HLT::ErrorCode T2L1CaloFullScanJet::hltFinalize() +{ + if ( (*m_log).level() <= MSG::DEBUG ) + (*m_log) << MSG::DEBUG << "Finalizing T2L1CaloFullScanJet FEX " << name() << endmsg; + + m_jets->clear(); + delete m_jets; + m_timer.clear(); + m_e.clear(); + m_et.clear(); + m_eta.clear(); + m_phi.clear(); + m_eem.clear(); + m_ehad.clear(); + m_emfrac.clear(); + m_nLeadingTowers.clear(); + + delete m_log; + + return HLT::OK; +} + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJet.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJet.cxx new file mode 100755 index 00000000000..be69e0b9a97 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJet.cxx @@ -0,0 +1,371 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2L1CaloJet.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Denis Oliveira Damazio +// ******************************************************************** + + +#include "GaudiKernel/IToolSvc.h" + + +#include "TrigT1Interfaces/TrigT1Interfaces_ClassDEF.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + +#include "TrigCaloEvent/TrigT2Jet.h" +#include "TrigCaloEvent/TrigT2JetContainer.h" +#include "TrigT2CaloJet/T2L1CaloJet.h" +#include "TrigT1CaloByteStream/ITrigT1CaloDataAccess.h" +#include "TrigT1CaloToolInterfaces/IL1JetTools.h" +#include "TrigTimeAlgs/TrigTimer.h" +#include <sys/time.h> + +#include <math.h> + +class ISvcLocator; + +T2L1CaloJet::T2L1CaloJet(const std::string & name, ISvcLocator* pSvcLocator) + : HLT::FexAlgo(name, pSvcLocator), + m_jet(0), + m_log(NULL), + m_dataL1("LVL1BS__TrigT1CaloDataAccess/TrigT1CaloDataAccess",0), + m_jetL1Tools("LVL1::L1JetTools/L1JetTools",this),m_storedJEs(0), + m_retrievedJetTool(false) +{ + declareProperty("TrigT1CaloDataAccess", m_dataL1, "L1 Calo Data Access"); + declareProperty("L1JetTool", m_jetL1Tools, "L1 Calo Jet Algorithm"); + declareProperty("jetOutputKey",m_jetOutputKey = "TrigT2L1CaloJet"); + + + declareMonitoredVariable("E", m_e); + declareMonitoredVariable("Et", m_et); + declareMonitoredVariable("Eta", m_eta); + declareMonitoredVariable("Phi", m_phi); +} + +HLT::ErrorCode T2L1CaloJet::hltInitialize() +{ + m_log = new MsgStream(msgSvc(), name()); + + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Intializing: " << name() <<endmsg; + } + + if (timerSvc()) { + m_timer.push_back(addTimer("TimeTot")); + m_timer.push_back(addTimer("JEUnpacking")); + m_timer.push_back(addTimer("JEformsums")); + m_timer.push_back(addTimer("RoIMaking")); + } + + // Create helper tools + if ( m_dataL1.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_dataL1 << endmsg; + m_retrievedJetTool = false; + } else { + m_retrievedJetTool = true; + (*m_log) << MSG::INFO << "Retrieved " << m_dataL1 << endmsg; + } + + if ( m_jetL1Tools.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_jetL1Tools << endmsg; + } else { + (*m_log) << MSG::INFO << "Retrieved " << m_jetL1Tools << endmsg; + } + + m_storedJEs = new ConstDataVector<DataVector<LVL1::JetElement> >(SG::VIEW_ELEMENTS); + + + return HLT::OK; +} + +T2L1CaloJet::~T2L1CaloJet(){ +} + +HLT::ErrorCode T2L1CaloJet::hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE) +{ + + if(timerSvc()){ + m_timer[0]->start(); + } + + m_e = -99; + m_et = -99; + //m_eem0 = -99; + //m_ehad0 = -99; + m_eta = -99; + m_phi = -99; + + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Executing T2L1CaloJet FEX " << name() << endmsg; + (*m_log) << MSG::DEBUG << "m_jetOutputKey: " << m_jetOutputKey << endmsg; + (*m_log) << MSG::DEBUG + << "outputTE->getId(): " + << outputTE->getId() << endmsg; + (*m_log) << MSG::DEBUG + << "inputTE->getId(): " + << inputTE->getId() << endmsg; + } +#endif + + // Note: new TriggerElement has no label() anymore ! + + + // ========================= + // retrieve RoI: + // ========================= +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "getting RoI" << endmsg; + } +#endif + + const TrigRoiDescriptor* roiDescriptor = 0; + + HLT::ErrorCode hltStatus = getFeature(inputTE, roiDescriptor); + + if ( hltStatus == HLT::OK ) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << "got the roi descriptor" << endmsg; + (*m_log) << MSG::DEBUG << *roiDescriptor << endmsg; + } +#endif + + } else { + (*m_log) << MSG::WARNING << " Failed to find RoiDescriptor " << endmsg; + return hltStatus; + } + + // Some debug output: +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) { + (*m_log) << MSG::DEBUG << "Inspect the LVL1 object; LVL1 phi=" + << roiDescriptor->phi() + << ", LVL1 eta=" + << roiDescriptor->eta() + << endmsg; + } +#endif + + // ========================= + // make Jet + // ========================= +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Making TrigT2Jet "<< endmsg; + } +#endif + m_jet = new TrigT2Jet(); + + // Add RoI word to Jet + m_jet->set_RoIword(roiDescriptor->roiWord()); + + // Set eta,phi + m_jet->setEta(roiDescriptor->eta()); + m_jet->setPhi(roiDescriptor->phi()); + + if(timerSvc()) m_timer[1]->start(); // start of JE unpacking + int counter=0; + DataVector<LVL1::JetElement>::const_iterator begj, endj; + + if ( m_retrievedJetTool ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loading the L1 data using ITrigT1CaloDataAccess tool, this loads the jet elements for the entire event"<< endmsg; + } +#endif + (m_dataL1->loadCollection(begj,endj)).ignore(); + } + + m_storedJEs->clear(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Looping over the jet elements"<< endmsg; + } +#endif + + for(; begj!=endj;begj++){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "JetElement["<<counter<<"]: ETs [GeV]: EM: "<< (*begj)->emEnergy()<<", HAD: "<< (*begj)->hadEnergy()<<", Total: "<<(*begj)->energy()<<", eta: "<<(*begj)->eta()<<", phi: "<<(*begj)->phi()<<endmsg; + } +#endif + + m_storedJEs->push_back(*begj); + counter++; + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Stored L1 data as DataVector<LVL1::JetElement>* m_storedJEs" << endmsg; + (*m_log) << MSG::DEBUG << "A total of " << counter << " elements were retreived" << endmsg; + (*m_log) << MSG::DEBUG << "These will now be mapped onto a map of ints and LVL1::JetInput[s]" << endmsg; + } +#endif + + std::map<int, LVL1::JetInput*> jetInputs; // This will have to be cleared after being used + if (m_retrievedJetTool) { + m_jetL1Tools->mapJetInputs(m_storedJEs->asDataVector(), &jetInputs); + } + + double roiPhi = (roiDescriptor)->phi(); + if( roiPhi < 0 ) roiPhi += 2 * M_PI; + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "RoI descriptor phi: "<<(roiDescriptor)->phi()<<", in L1 coordinates: "<<roiPhi<<endmsg; + } +#endif + + if(timerSvc()) m_timer[1]->stop(); // end of JE unpacking + if(timerSvc()) m_timer[2]->start(); // start of jet finding + + if ( m_retrievedJetTool ) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Using m_jetL1Tools to 'formSums' at the roi descriptor coordinates, this reproduces the L1 Jet object"<<endmsg; + } +#endif + m_jetL1Tools->formSums( (roiDescriptor)->eta(), roiPhi, & jetInputs ); + // now we must clear the map of jet inputs + std::map<int, LVL1::JetInput*> ::const_iterator begin_JetInputMap, + end_JetInputMap; + begin_JetInputMap = jetInputs.begin(); + end_JetInputMap = jetInputs.end(); + for(; begin_JetInputMap!=end_JetInputMap;begin_JetInputMap++){ + delete begin_JetInputMap->second; + } + + m_jet->setEta( (roiDescriptor)->eta() ); + // The L1 roiDescriptor phi0 can sometimes be == Pi which causes navigation errors + if ((roiDescriptor)->phi() >= M_PI){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "RoI descriptor phi >= M_PI, this causes issues with the creation of RoI descriptors: therefore setting phi to M_PI-0.001"<<endmsg; + } +#endif + m_jet->setPhi( M_PI-0.001 ); + } + else{ + m_jet->setPhi( (roiDescriptor)->phi() ); + } + //m_jet->setPhi( (roiDescriptor)->phi() ); + m_jet->setE ( m_jetL1Tools->ET8x8()*1e3*cosh((roiDescriptor)->eta()) ); + //m_jet->setEem0 ( 0.0 ); + //m_jet->setEhad0 ( 0.0 ); + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Values of T2L1CaloJet produced: " << endmsg; + (*m_log) << MSG::DEBUG << " REGTEST: Jet eta = " << m_jet->eta() << endmsg; + (*m_log) << MSG::DEBUG << " REGTEST: Jet phi = " << m_jet->phi() << endmsg; + (*m_log) << MSG::DEBUG << " REGTEST: Jet energy = " << m_jet->e() << endmsg; + (*m_log) << MSG::DEBUG << " REGTEST: Jet et = " << m_jet->et() << endmsg; + } +#endif + + m_e = m_jet->e(); + //m_ehad0 = m_jet->ehad0(); + //m_eem0 = m_jet->eem0(); + m_eta = m_jet->eta(); + m_et = m_e/cosh(m_eta); + m_phi = m_jet->phi(); + + if(timerSvc()) m_timer[2]->stop(); // end of jet finding + if(timerSvc()) m_timer[3]->start(); // start of RoI creation + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Recording created features"<<endmsg; + } +#endif + + std::string key = ""; + + hltStatus = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (hltStatus != HLT::OK) { + if((*m_log).level() <= MSG::DEBUG) { + (*m_log) << MSG::ERROR << "Write of TrigT2Jet into outputTE failed" + << endmsg; + } + return hltStatus; + } + + + // ========================= + // make OutputTE + // ========================= + + // Create a new RoiDescriptor with updated eta and phi. + // Note that the steering will propagate l1Id and roiId automatically + // so no need to set them. + // How big is theis RoI ????? + TrigRoiDescriptor* newRoiDescriptor = + new TrigRoiDescriptor(roiDescriptor->roiWord(), roiDescriptor->l1Id(), roiDescriptor->roiId(), + m_jet->eta(), m_jet->eta(), m_jet->eta(), + m_jet->phi(), m_jet->phi(), m_jet->phi() + ); // We forward the roiWord to the EF + + + hltStatus = attachFeature(outputTE, newRoiDescriptor, m_jetOutputKey); + + if ( hltStatus != HLT::OK ) { + (*m_log) << MSG::ERROR << "Write of update TrigRoiDescriptor into outputTE failed" + << endmsg; + return hltStatus; + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) { + (*m_log) << MSG::DEBUG << "Recorded an RoiDescriptor " + << " phi " << newRoiDescriptor->phi() + << " eta " << newRoiDescriptor->eta() << endmsg; + (*m_log) << MSG::DEBUG + << "We assume success, set TE with Id " + << outputTE->getId() + << " active to signal positive result." + << endmsg; + } +#endif + + if (timerSvc()) { + m_timer[3]->stop();// end of RoI creation + m_timer[0]->stop();// end of algorithm + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Finished T2L1CaloJet FEX " << name() << endmsg; + } +#endif + + return HLT::OK; +} + + +HLT::ErrorCode T2L1CaloJet::hltFinalize() +{ + m_storedJEs->clear(); + delete m_storedJEs; + + if ( (*m_log).level() <= MSG::INFO ){ + (*m_log) << MSG::INFO << "Finalizing: " << name() << endmsg; + + } + delete m_log; + + return HLT::OK; +} + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetCalibTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetCalibTool.cxx new file mode 100644 index 00000000000..79d9f082ad6 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetCalibTool.cxx @@ -0,0 +1,236 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2L1CaloJetCalibTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett <tamsett@cern.ch> +CREATED: June 2012 + + +PURPOSE: Calibration tool for L2FS jets. + + + +********************************************************************/ +#include "TrigT2CaloJet/T2L1CaloJetCalibTool.h" +#include "TrigCaloEvent/Trig3Momentum.h" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "AthenaKernel/Timeout.h" + +#include "GaudiKernel/IToolSvc.h" + +//----------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------- +T2L1CaloJetCalibTool::T2L1CaloJetCalibTool(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent) +{ + declareInterface<T2L1CaloJetCalibTool>( this ); + // configurables + declareConstant("Calib_Factors", m_CalibConstants); + //declareProperty("Et_bin_edges", m_et_bin_lower_edges); + declareProperty("Eta_bin_edges", m_eta_bin_lower_edges); + //declareConstant("Phi_bin_edges", m_phi_bin_lower_edges); + + +} + +//----------------------------------------------------------------- +// Destructor +//----------------------------------------------------------------- +T2L1CaloJetCalibTool::~T2L1CaloJetCalibTool() +{ +} + +//----------------------------------------------------------------- +// Initialize: +//----------------------------------------------------------------- +StatusCode T2L1CaloJetCalibTool::initialize() +{ + m_log = new MsgStream(msgSvc(), name()); + (*m_log) << MSG::INFO << " Initalizing Tool: " << name () << endmsg; + + if ( m_eta_bin_lower_edges.empty() ) { + (*m_log) << MSG::ERROR << name() << ": No eta bin edges provided " << endmsg; + return StatusCode::FAILURE; + } else { + (*m_log) << MSG::INFO << " eta bin edges provided: " << m_eta_bin_lower_edges.size() << endmsg; + if((*m_log).level() <= MSG::DEBUG){ + for ( unsigned i=0 ; i<m_eta_bin_lower_edges.size() ; i++ ) { + (*m_log) << MSG::DEBUG << " - bin[" << i << "] lower edge: " << m_eta_bin_lower_edges[i] << endmsg; + } + } + } + + + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------- +// Execute +//----------------------------------------------------------------- +StatusCode T2L1CaloJetCalibTool::execute() +{ + return StatusCode::SUCCESS; +} + +StatusCode T2L1CaloJetCalibTool::execute(TrigT2Jet* jet, double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/) +{ + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "===== Executing: T2L1CaloJetCalibTool " << name() << endmsg; + } +#endif + + // === get the input jet + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Initial TrigT2CaloJet Et: " << jet->e()/cosh(jet->eta()) + << " MeV, eta: " << jet->eta() + << ", phi: " << jet->phi() + << endmsg; + (*m_log) << MSG::DEBUG << " - EM Et: " << jet->eem0()/cosh(jet->eta()) + << " MeV, Had Et: " << jet->ehad0()/cosh(jet->eta()) + << " MeV, emf: " << jet->emf() + << endmsg; + } +#endif + // calibrate the jet + int eta_bin = GetEtaBin(jet->eta()); + double transverse_energy = jet->e()/cosh(jet->eta()); + + double CalibFactor = GetCalibFactor(eta_bin,transverse_energy/1000.); + double correction_factor = 1. / (1. + CalibFactor); + double em_correction_factor = correction_factor; + double had_correction_factor = correction_factor; + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " - Eta Bin: " << eta_bin << endmsg; + (*m_log) << MSG::DEBUG << " - CalibFactor: " << CalibFactor << endmsg; + (*m_log) << MSG::DEBUG << " - Multiplicative correction: " << correction_factor << endmsg; + (*m_log) << MSG::DEBUG << " - em correction: " << em_correction_factor << endmsg; + (*m_log) << MSG::DEBUG << " - had correction: " << had_correction_factor << endmsg; + + } +#endif + + double corrected_transverse_energy = (jet->e()/cosh(jet->eta()))*correction_factor; + double corrected_energy = corrected_transverse_energy*cosh(jet->eta() ); + jet->setE(corrected_energy); + + double corrected_em_transverse_energy = (jet->eem0()/cosh(jet->eta()))*em_correction_factor; + double corrected_em_energy = corrected_em_transverse_energy*cosh(jet->eta() ); + jet->setEem0(corrected_em_energy); + + double corrected_had_transverse_energy = (jet->ehad0()/cosh(jet->eta()))*had_correction_factor; + double corrected_had_energy = corrected_had_transverse_energy*cosh(jet->eta() ); + jet->setEhad0(corrected_had_energy); + + double emf = 0; + if (corrected_em_transverse_energy){ + emf = jet->eem0() / jet->e(); + } + jet->setEmf(emf); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Calibrated TrigT2CaloJet: Et: " << jet->e()/cosh(jet->eta()) + << " MeV, eta: " << jet->eta() + << ", phi: " << jet->phi() + << endmsg; + (*m_log) << MSG::DEBUG << " - EM Et: " << jet->eem0()/cosh(jet->eta()) + << " MeV, Had Et: " << jet->ehad0()/cosh(jet->eta()) + << " MeV, emf: " << jet->emf() + << endmsg; + } +#endif + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "===== Finished: T2L1CaloJetCalibTool " << name() << endmsg; + } +#endif + + return StatusCode::SUCCESS; +} + + +//----------------------------------------------------------------- +// Finalize: +//----------------------------------------------------------------- +StatusCode T2L1CaloJetCalibTool::finalize() +{ + delete m_log; + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------- +// Calibration tools: +//----------------------------------------------------------------- +StatusCode T2L1CaloJetCalibTool::setProperty (const std::string& propname, + const std::string& value) +{ + StatusCode sc = AlgTool::setProperty (propname, value); + if (sc.isFailure()) return sc; + + sc=CaloRec::ToolWithConstantsMixin::setProperty (propname, value); + if (sc.isFailure()) return sc; + + return StatusCode::SUCCESS; +} + +StatusCode T2L1CaloJetCalibTool::setProperty (const Property& p) +{ + StatusCode sc=AlgTool::setProperty (p); + if (sc.isFailure()) return sc; + + sc=CaloRec::ToolWithConstantsMixin::setProperty (p); + if (sc.isFailure()) return sc; + + return StatusCode::SUCCESS; + +} + +int T2L1CaloJetCalibTool::GetEtaBin(double jet_eta) +{ + for ( unsigned i=0 ; i<m_eta_bin_lower_edges.size(); i++ ) { + if (jet_eta < m_eta_bin_lower_edges[i]){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " eta: " << jet_eta + << " < bin edge[" << i + << "]: " << m_eta_bin_lower_edges[i] + << endmsg; + } +#endif + return i-1; + } + } + if (jet_eta < 0) return 0; + return m_eta_bin_lower_edges.size()-1; +} + + +double T2L1CaloJetCalibTool::GetCalibFactor(int etabin, double transverse_energy) +{ + //up to 7 parameter for the pol-fit + unsigned Npar=7; + double logET=1./log10(transverse_energy); + double y=0; + for (unsigned i=0;i<Npar;++i) + y += m_CalibConstants[etabin][i]*pow(logET,i); + return y; +} + + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanBaseTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanBaseTool.cxx new file mode 100644 index 00000000000..b67bd030f11 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanBaseTool.cxx @@ -0,0 +1,57 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2L1CaloJetFullScanBaseTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett <tamsett@cern.ch> +CREATED: July, 2011 + +PURPOSE: Base Tool for all T2L1CaloJetFullScan tools that require + a vector of T2CaloJet objects as its input. The derived + tool must implement an execute(DataVector<T2CaloJet*>) method. + +********************************************************************/ +#include "TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h" +#include "TrigCaloEvent/TrigT2Jet.h" + +#include "GaudiKernel/MsgStream.h" + +#include "GaudiKernel/IToolSvc.h" + +T2L1CaloJetFullScanBaseTool::T2L1CaloJetFullScanBaseTool(const std::string& type, + const std::string& name, + const IInterface* parent): + IAlgToolCalo(type, name, parent) +{ + declareInterface<T2L1CaloJetFullScanBaseTool>( this ); +} + + +T2L1CaloJetFullScanBaseTool::~T2L1CaloJetFullScanBaseTool() +{ +} + +StatusCode T2L1CaloJetFullScanBaseTool::initialize() +{ + return StatusCode::SUCCESS; +} + +StatusCode T2L1CaloJetFullScanBaseTool::execute() +{ + return StatusCode::SUCCESS; +} + +StatusCode T2L1CaloJetFullScanBaseTool::execute(DataVector<TrigT2Jet>* /*output jets*/,int& /*n_towers*/,float& /*L1 unpack time*/, float& /*all unpack time*/,float& /*fastjet time*/,float& /*all jet finding time*/) +{ + return StatusCode::SUCCESS; +} + + +StatusCode T2L1CaloJetFullScanBaseTool::finalize() +{ + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanFastJetTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanFastJetTool.cxx new file mode 100644 index 00000000000..8bba44d7f6b --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1CaloJetFullScanFastJetTool.cxx @@ -0,0 +1,568 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2L1CaloJetFullScanFastJetTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett <tamsett@cern.ch> +CREATED: July, 2011 + +PURPOSE: FastJet Tool for full scan reconstruction of jets from Lvl-1 + inputs. + +********************************************************************/ +#include "TrigT2CaloJet/T2L1CaloJetFullScanFastJetTool.h" +#include "TrigCaloEvent/TrigT2Jet.h" + +#include "TrigT1CaloByteStream/ITrigT1CaloDataAccess.h" +#include "TrigT1CaloToolInterfaces/IL1JetTools.h" +#include "TrigT1CaloEvent/TriggerTower.h" + +#include "fastjet/ClusterSequence.hh" + +#include "GaudiKernel/MsgStream.h" + +#include "GaudiKernel/IToolSvc.h" + + +T2L1CaloJetFullScanFastJetTool::T2L1CaloJetFullScanFastJetTool(const std::string& type, + const std::string& name, + const IInterface* parent): + T2L1CaloJetFullScanBaseTool(type, name, parent), + m_dataL1("LVL1BS__TrigT1CaloDataAccess/TrigT1CaloDataAccess",0), + m_jet(0), + m_total_timer(0), + m_unpacking_timer(0), + m_load_collection_timer(0), + m_jet_finding_timer(0), + m_jet_def(0) + +{ + declareInterface<T2L1CaloJetFullScanFastJetTool>( this ); + // configurables + declareProperty("TrigT1CaloDataAccess", m_dataL1, "L1 Calo Data Access"); + declareProperty("doTriggerTowers", m_doTriggerTowers = false); + declareProperty("coneRadius", m_coneRadius = 0.4); + declareProperty("pTmin", m_pTmin = 5000.); + declareProperty("inputType", m_inputType = T2L1::NONE); + // cleaning: + declareProperty("doCleaning", m_doCleaning = true); + declareProperty("leadingCellFraction", m_leadingCellFraction = 0.9); // for jet cleaning, e.g.: n90 -> leadingCellFraction = 0.9 + // debug + declareProperty("doJetFinding", m_doJetFinding = true); +} + + +T2L1CaloJetFullScanFastJetTool::~T2L1CaloJetFullScanFastJetTool() +{ +} + +StatusCode T2L1CaloJetFullScanFastJetTool::initialize() +{ + m_log = new MsgStream(msgSvc(), name()); + + + (*m_log) << MSG::INFO << " Initalizing Tool: " << name () << endmsg; + (*m_log) << MSG::DEBUG << "Options: " << endmsg; + (*m_log) << MSG::DEBUG << " doTriggerTowers: " << m_doTriggerTowers << endmsg; + (*m_log) << MSG::DEBUG << " coneRadius: " << m_coneRadius << endmsg; + (*m_log) << MSG::DEBUG << " pTmin: " << m_pTmin << endmsg; + (*m_log) << MSG::DEBUG << " inputType (hex): " << std::hex << m_inputType << std::dec << endmsg; + (*m_log) << MSG::DEBUG << " doCleaning: " << m_doCleaning << endmsg; + (*m_log) << MSG::DEBUG << " leadingCellFraction: " << m_leadingCellFraction << endmsg; + (*m_log) << MSG::DEBUG << " doJetFinding: " << m_doJetFinding << endmsg; + + // Initialize timing service + if( service( "TrigTimerSvc", m_pTimerService).isFailure() ) { + (*m_log) << MSG::WARNING << name() << ": Unable to locate TrigTimer Service" << endmsg; + } + + if (m_pTimerService){ + (*m_log) << MSG::DEBUG << " Adding timers" << endmsg; + //Add timers + m_total_timer = m_pTimerService->addItem("LVL1_5_total_time"); + m_unpacking_timer = m_pTimerService->addItem("LVL1_5_FS_unpacking_time"); + m_load_collection_timer = m_pTimerService->addItem("LVL1_5_FS_load_collection_time"); + m_jet_finding_timer = m_pTimerService->addItem("LVL1_5_FS_jet_finding_time"); + m_fastjet_timer = m_pTimerService->addItem("LVL1_5_FS_fastjet_time"); + } + + // Create helper tools + if ( m_dataL1.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_dataL1 << endmsg; + m_retrievedJetTool = false; + } else { + m_retrievedJetTool = true; + (*m_log) << MSG::DEBUG << "Retrieved " << m_dataL1 << endmsg; + } + + // settings for Trigger tower retrieval + m_etaMin = -5.; + m_etaMax = 5.; + m_phiMin = 0.; + m_phiMax = 2 * M_PI; + m_fullScan = true; + + // initialise storage for l1 towers + m_l1_tower_information.reserve(1000); + m_cellenergies.reserve(100); + + // initialise fast jet + m_particles.reserve(100); + m_constituents.reserve(100); + m_jets.reserve(100); + + if (m_doJetFinding){ + (*m_log) << MSG::INFO << " Setting up fastjet jet definition" << endmsg; + m_jet_def = new fastjet::JetDefinition(fastjet::antikt_algorithm, m_coneRadius); + // dummy call to fast jet so it's internal initalize methods are set (and we don't print the banner during execute) + (*m_log) << MSG::INFO << " Making dummy call to fast jet cluster sequence" << endmsg; + m_particles.clear(); + fastjet::ClusterSequence* cs(0); + cs = new fastjet::ClusterSequence(m_particles, *m_jet_def); + delete cs; + } + + + + return StatusCode::SUCCESS; +} + +StatusCode T2L1CaloJetFullScanFastJetTool::execute() +{ + return StatusCode::SUCCESS; +} + + +StatusCode T2L1CaloJetFullScanFastJetTool::execute(DataVector<TrigT2Jet>* output_t2_jets,int& n_towers,float& l1_unpack_time, float& all_unpack_time, float& fastjet_time, float& all_jet_finding_time) +{ + m_total_timer->reset(); + m_unpacking_timer->reset(); + m_load_collection_timer->reset(); + m_jet_finding_timer->reset(); + m_fastjet_timer->reset(); + m_total_timer->start(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "===== Executing: T2L1CaloJetFullScanFastJetTool " << name() << endmsg; + } +#endif + + // output_t2_jets->clear(); // this should be cleared when it arrives + m_particles.clear(); + m_constituents.clear(); + m_jets.clear(); + m_l1_tower_information.clear(); + m_cellenergies.clear(); + + n_towers = -9; + all_unpack_time = -9; + l1_unpack_time = -9; + fastjet_time = -9; + all_jet_finding_time = -9; + // === now fill the particles vector, this is different for jet elements and trigger towers + // eventually this could be split off into a seperate FEX to be reused by this, vl1 etc. + m_unpacking_timer->start(); + + int counter = 0; + if ( m_doTriggerTowers ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Trigger tower version" <<endmsg; + } +#endif + + DataVector<LVL1::TriggerTower>::const_iterator tt_begj, tt_endj; + + // now get TT's + if ( m_retrievedJetTool ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loading the L1 data using ITrigT1CaloDataAccess tool"<< endmsg; + (*m_log) << MSG::DEBUG << "Getting trigger towers using m_etaMin: " << m_etaMin + << ", etaMax: " << m_etaMax + << ", phiMin: " << m_phiMin + << ", phiMax: " << m_phiMax + << ", full: " << m_fullScan << endmsg; + } +#endif + m_load_collection_timer->start(); + StatusCode sc = m_dataL1->loadCollection(tt_begj,tt_endj,m_etaMin,m_etaMax,m_phiMin,m_phiMax,m_fullScan); + if (sc.isFailure()) { + (*m_log) << MSG::WARNING << "Error accessing trigger tower data" << endmsg; + return sc; + } + m_load_collection_timer->stop(); + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loaded trigger towers in "<< m_load_collection_timer->elapsed() << " ms" << endmsg; + (*m_log) << MSG::DEBUG << "Looping over trigger towers"<< endmsg; + } +#endif + + for(; tt_begj!=tt_endj;++tt_begj){ + const LVL1::TriggerTower* TT = (*tt_begj); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "TriggerTower[" << counter + << "]: ETs [GeV]: EM: " << TT->emEnergy() + << ", HAD: " << TT->hadEnergy() + << ", eta: " << TT->eta() + << ", phi: " << TT->phi() << endmsg; + } +#endif + // change to a more standard phi definition + float tt_phi = TT->phi(); + if( tt_phi >= M_PI ) tt_phi -= 2 * M_PI; + float transverse_energy = (TT->emEnergy() + TT->hadEnergy())*1000.; + float cosh_eta = cosh(TT->eta()); + float energy = transverse_energy*cosh_eta; + // possibly do some calibration + + // now fill fast jet particles + float px = transverse_energy*cos(tt_phi); + float py = transverse_energy*sin(tt_phi); + float pz = transverse_energy*sinh(TT->eta()); + + if (m_doJetFinding){ + if (transverse_energy > 0.99){ // some Jet Elements have zero energy (this may also be true for trigger towers), there is no need to give these to fastjet + fastjet::PseudoJet pseudo_jet( px, py, pz, energy); + pseudo_jet.set_user_index(counter); + m_particles.push_back( pseudo_jet ); + } + + // now fill these into a vector of floats so we can construct cleaning variables later + if (m_doCleaning) { + m_l1_tower_information.push_back(energy); + m_l1_tower_information.push_back(TT->eta()); + m_l1_tower_information.push_back(TT->phi()); + m_l1_tower_information.push_back(TT->emEnergy()*cosh_eta*1000.); + m_l1_tower_information.push_back(TT->hadEnergy()*cosh_eta*1000.); + } + } + + counter++; + } + } else { // if we aren't running on trigger towers we use jet elements instead +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Jet element version" <<endmsg; + } +#endif + DataVector<LVL1::JetElement>::const_iterator je_begj, je_endj; + + if ( m_retrievedJetTool ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loading the L1 data using ITrigT1CaloDataAccess tool, this loads the jet elements for the entire event"<< endmsg; + } +#endif + m_load_collection_timer->start(); + StatusCode sc = m_dataL1->loadCollection(je_begj,je_endj); + if (sc.isFailure()) { + (*m_log) << MSG::WARNING << "Error accessing jet element data" << endmsg; + return sc; + } + m_load_collection_timer->stop(); + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loaded jet elements in "<< m_load_collection_timer->elapsed() << " ms" << endmsg; + (*m_log) << MSG::DEBUG << "Looping over the jet elements"<< endmsg; + } +#endif + + for(; je_begj!=je_endj;++je_begj){ + const LVL1::JetElement* JE = (*je_begj); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "JetElement[" << counter + << "]: ETs [GeV]: EM: " << JE->emEnergy() + << ", HAD: " << JE->hadEnergy() + << ", Total: " << JE->energy() + << ", eta: " << JE->eta() + << ", phi: " << JE->phi() << endmsg; + } +#endif + + // change to a more standard phi definition + float je_phi = JE->phi(); + if( je_phi >= M_PI ) je_phi -= 2 * M_PI; + float transverse_energy = JE->energy()*1000.; + float cosh_eta = cosh(JE->eta()); + float energy = transverse_energy*cosh_eta; + // possibly do some calibration + + // now fill fast jet particles + float px = transverse_energy*cos(je_phi); + float py = transverse_energy*sin(je_phi); + float pz = transverse_energy*sinh(JE->eta()); + + if (m_doJetFinding){ + if (JE->energy() > 0.99){ // some Jet Elements have zero energy, there is no need to give these to fastjet + fastjet::PseudoJet pseudo_jet( px, py, pz, energy); + pseudo_jet.set_user_index(counter); + m_particles.push_back( pseudo_jet ); + } + // now fill these into a vector of floats so we can construct cleaning variables later + if (m_doCleaning) { + m_l1_tower_information.push_back(energy); + m_l1_tower_information.push_back(JE->eta()); + m_l1_tower_information.push_back(JE->phi()); + m_l1_tower_information.push_back(JE->emEnergy()*cosh_eta*1000.); + m_l1_tower_information.push_back(JE->hadEnergy()*cosh_eta*1000.); + } + } + counter++; + } + } // end of particle creation step + m_unpacking_timer->stop(); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "A total of " << m_particles.size() << " L1 particles are to be clustered" << endmsg; + if (m_doCleaning) { (*m_log) << MSG::DEBUG << "A total of " << m_l1_tower_information.size()/5. << " are saved as L1 towers for the cleaning" << endmsg; } + } +#endif + // ===== now find the jets + m_jet_finding_timer->start(); + if (m_doJetFinding){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Performing jet finding " << endmsg; + } +#endif + // run the clustering, extract the jets + m_fastjet_timer->start(); + fastjet::ClusterSequence* cs(0); + cs = new fastjet::ClusterSequence(m_particles, *m_jet_def); + + m_jets = fastjet::sorted_by_pt(cs->inclusive_jets(m_pTmin)); // sorted by increasing pt + m_fastjet_timer->stop(); + std::reverse(m_jets.begin(),m_jets.end()); // sorted by decreasing pt + + // inspect the output jets and make some cleaning variables +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "== Resultant jets " << endmsg; + } +#endif + for (unsigned i = 0; i < m_jets.size(); ++i) { + m_constituents = fastjet::sorted_by_pt(cs->constituents(m_jets[i])); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " fastjet jet " << i + << ": Et: " << m_jets[i].e()/cosh(m_jets[i].eta()) + << " MeV, eta: " << m_jets[i].eta() + << ", phi: " << m_jets[i].phi_std() + << ", rapidity: " << m_jets[i].rapidity() + << ", n constituents: " << m_constituents.size() << endmsg; + } +#endif + int nLeadingCells = -9; + float em_energy = -9; + float em_frac = -9; + float had_energy = -9; + + if (m_doCleaning) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Computing cleaning variables "<< endmsg; + } +#endif + float total_energy = 0.; + //float had_frac = 0.; + em_energy = 0.; + em_frac = 0.; + had_energy = 0.; + //had_frac = 0.; + for (unsigned ii = 0; ii < m_constituents.size(); ++ii){ + int l1_id = m_constituents[ii].user_index(); + float energy = m_l1_tower_information.at((l1_id*5)); + float emEnergy = m_l1_tower_information.at((l1_id*5)+3); + float hadEnergy = m_l1_tower_information.at((l1_id*5)+4); + +#ifndef NDEBUG + float eta = m_l1_tower_information.at((l1_id*5)+1); + float phi = m_l1_tower_information.at((l1_id*5)+2); + float transverse_energy = energy / cosh(eta); + + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " constituent[" << std::setw(3) << ii + << "]: Et: " << std::setw(8) << m_constituents[ii].e()/cosh(m_constituents[ii].eta()) + //<< " MeV (em,had) (" << std::setw(8) << emEnergy/cosh(eta) + //<<"," << std::setw(8) << hadEnergy/cosh(eta) + << ", eta: " << std::setw(8) << m_constituents[ii].eta() + << ", phi: " << std::setw(8) << m_constituents[ii].phi_std() + << ", rapidity: " << std::setw(6) << m_constituents[ii].rapidity() + << ", user index: " << std::setw(5) << m_constituents[ii].user_index() << endmsg; + + (*m_log) << MSG::VERBOSE << " L1 tower[" << l1_id + << "]: Et: " << transverse_energy + << " GeV (em,had) (" << emEnergy / cosh(eta) + << "," << hadEnergy / cosh(eta) + << "), energy: " << energy + << ", eta: " << eta + << ", phi: " << phi << endmsg; + } +#endif + + // cleaning: + total_energy+=energy; + em_energy+=emEnergy; + had_energy+=hadEnergy; + m_cellenergies.push_back( energy ); + + } + + if (total_energy > 0.){ + em_frac = em_energy / total_energy; + //had_frac= had_energy / total_energy; + } + + // sort cell-energy vector. (most energetic cell at end of vector) + nLeadingCells = 0; + std::sort(m_cellenergies.begin(), m_cellenergies.end()); + float running_energy_sum = 0.; + for(int k = m_cellenergies.size()-1; k > -1; --k){ + running_energy_sum += m_cellenergies[k]; + nLeadingCells++; + if(running_energy_sum > m_leadingCellFraction*total_energy){ + break; + } + } +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " total Et: " << total_energy/cosh(m_jets[i].eta()) + << " MeV (em,had) (" << em_energy/cosh(m_jets[i].eta()) + << "," << had_energy/cosh(m_jets[i].eta()) + << "), em frac: " << em_frac + << ", had frac: " << (total_energy ? had_energy / total_energy : 0) + << ", nLeadingCells: " << nLeadingCells + << endmsg; + } +#endif + } + + // ========================= + // Record the final jet + // ========================= +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " making TrigT2Jet "<< endmsg; + } +#endif + + m_jet = new TrigT2Jet(); + + // Add RoI word to Jet + int outputType = T2L1::UNKNOWN; + if (m_doTriggerTowers){ + if (m_coneRadius==0.4){ + outputType = T2L1::A4TT; + } else if (m_coneRadius==1.0){ + outputType = T2L1::A10TT; + } else { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) + (*m_log) << MSG::DEBUG << " unable to determine RoI type from m_coneRadius = " << m_coneRadius << ", setting output RoI type to UNKNOWN" << endmsg; +#endif + outputType = T2L1::UNKNOWN; + } + } else { + if (m_coneRadius==0.4){ + outputType = T2L1::A4JE; + } else if (m_coneRadius==1.0){ + outputType = T2L1::A10JE; + } else { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) + (*m_log) << MSG::DEBUG << " unable to determine RoI type from m_coneRadius = " << m_coneRadius << ", setting output RoI type to UNKNOWN" << endmsg; +#endif + outputType = T2L1::UNKNOWN; + } + } + + m_jet->set_RoIword(T2L1::BLANKWORD+T2L1::INPUT*m_inputType+T2L1::OUTPUT*outputType+i); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG) + (*m_log) << MSG::DEBUG << " RoI word set to: " << std::hex << m_jet->RoIword() << std::dec << endmsg; +#endif + + // Set properties + m_jet->setE(m_jets[i].e()); + m_jet->setEta(m_jets[i].eta()); + m_jet->setPhi(m_jets[i].phi_std()); + m_jet->setEem0(em_energy); + m_jet->setEhad0(had_energy); + m_jet->setEmf(em_frac); + m_jet->setNLeadingCells(nLeadingCells); + + // look at the jet produced +#ifndef NDEBUG + if((*m_log).level() <= MSG::VERBOSE){ + (*m_log) << MSG::VERBOSE << " Values of T2CaloJet produced: " << endmsg; + (*m_log) << MSG::VERBOSE << " REGTEST: Jet eta = " << m_jet->eta() << endmsg; + (*m_log) << MSG::VERBOSE << " REGTEST: Jet phi = " << m_jet->phi() << endmsg; + (*m_log) << MSG::VERBOSE << " REGTEST: Jet energy = " << m_jet->e() << endmsg; + (*m_log) << MSG::VERBOSE << " REGTEST: Jet et = " << m_jet->et() << endmsg; + } +#endif + output_t2_jets->push_back(m_jet); + } // end of loop on found jets + + // delete the fast jet cluster sequence + delete cs; + } + m_jet_finding_timer->stop(); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "FastJet completed in " << m_fastjet_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "Jet finding completed in " << m_jet_finding_timer->elapsed() << " ms " << endmsg; + } +#endif + m_total_timer->stop(); + // fill monitoring variables + n_towers = counter; + l1_unpack_time = m_load_collection_timer->elapsed(); + all_unpack_time = m_unpacking_timer->elapsed(); + fastjet_time = m_fastjet_timer->elapsed(); + all_jet_finding_time = m_jet_finding_timer->elapsed(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "================= Finished T2L1CaloFullScanFastJetTool " << name() << " in " << m_total_timer->elapsed() << " ms " << endmsg; + } +#endif + + return StatusCode::SUCCESS; +} + + +StatusCode T2L1CaloJetFullScanFastJetTool::finalize() +{ + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Finalising: T2L1CaloJetFullScanFastJetTool " << name() << endmsg; + } + delete m_log; + m_particles.clear(); + m_jets.clear(); + m_constituents.clear(); + m_l1_tower_information.clear(); + m_cellenergies.clear(); + + if ( bool(m_jet_def) ){ + delete m_jet_def; + } + return StatusCode::SUCCESS; +} + + + + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1TowerCalibTool.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1TowerCalibTool.cxx new file mode 100644 index 00000000000..4ba90e3381a --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1TowerCalibTool.cxx @@ -0,0 +1,255 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + +NAME: T2L1TowerCalibTool.cxx +PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet + +AUTHORS: Matthew Tamsett <tamsett@cern.ch>, Carlos Sandoval <csandova@mail.cern.ch> +CREATED: December 2011 + + +PURPOSE: Calibration tool for L1 towers. + + + +********************************************************************/ +#include "TrigT2CaloJet/T2L1TowerCalibTool.h" +#include "TrigCaloEvent/Trig3Momentum.h" +#include "TrigCaloEvent/TrigT2Jet.h" +#include "AthenaKernel/Timeout.h" + +#include "GaudiKernel/IToolSvc.h" + +//----------------------------------------------------------------- +// Constructor +//----------------------------------------------------------------- +T2L1TowerCalibTool::T2L1TowerCalibTool(const std::string& type, + const std::string& name, + const IInterface* parent): + T2CaloJetBaseTool(type, name, parent), + m_grid_element(0) +{ + declareInterface<T2L1TowerCalibTool>( this ); + // configurables + declareConstant("Calib_Factors", m_CalibConstants); + + +} + +//----------------------------------------------------------------- +// Destructor +//----------------------------------------------------------------- +T2L1TowerCalibTool::~T2L1TowerCalibTool() +{ +} + +//----------------------------------------------------------------- +// Initialize: +//----------------------------------------------------------------- +StatusCode T2L1TowerCalibTool::initialize() +{ + m_log = new MsgStream(msgSvc(), name()); + (*m_log) << MSG::INFO << " Initalizing Tool: " << name () << endmsg; + + // output + m_grid_element = new Trig3Momentum(); + + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------- +// Execute +//----------------------------------------------------------------- +StatusCode T2L1TowerCalibTool::execute() +{ + return StatusCode::SUCCESS; +} + +StatusCode T2L1TowerCalibTool::execute(TrigT2Jet* jet, double /*etamin*/, double /*etamax*/, double /*phimin*/, double /*phimax*/) +{ + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "===== Executing: T2L1TowerCalibTool " << name() << endmsg; + } +#endif + + // === get the input particles + + std::vector<Trig3Momentum>* old_grid = jet->grid(); + std::vector<Trig3Momentum>* new_grid = new std::vector<Trig3Momentum>(); + new_grid->reserve(8000); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "A total of " << old_grid->size() << " particles are to be calibrated" << endmsg; + } +#endif + + // === Unpack the grid + std::vector<Trig3Momentum>::const_iterator begin_grid, end_grid; + begin_grid = old_grid->begin(); + end_grid = old_grid->end(); + int jet_counter = 0; + for (; begin_grid != end_grid; ++begin_grid){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::VERBOSE){ + (*m_log) << MSG::VERBOSE << " Initial Trig3Momentum[" << jet_counter + << "]: Et: " << begin_grid->e()/cosh(begin_grid->eta()) + << " MeV, eta: " << begin_grid->eta() + << ", phi: " << begin_grid->phi() + << ", sampling: " << std::hex << begin_grid->caloSample() << std::dec + << ", provenance: " << begin_grid->provenance() << endmsg; + } +#endif + // calibrate the towers + double transverse_energy_uncorrected = begin_grid->e()/cosh(begin_grid->eta()); + if (begin_grid->provenance()!=9999){ + // If provenance is set then this tower has been split into its EM and HAD components for clustering. + // Calibration is currently based on the sum of energy, therefore we must recover the sum energy before + // obtaining the calibration factor + double extra_energy = old_grid->at(begin_grid->provenance()).e()/cosh(begin_grid->eta()); + transverse_energy_uncorrected = transverse_energy_uncorrected + extra_energy; +#ifndef NDEBUG + if((*m_log).level() <= MSG::VERBOSE){ + (*m_log) << MSG::VERBOSE << " - EM + HAD ET: " << transverse_energy_uncorrected << endmsg; + } +#endif + } + + int eta_bin = GetEtaBin(begin_grid->eta() ); + int phi_bin = GetPhiBin(begin_grid->phi()); + int et_bin = GetEtBin(transverse_energy_uncorrected); + double CalibFactor = GetEtaCalibFactor(eta_bin,phi_bin,et_bin); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::VERBOSE){ + (*m_log) << MSG::VERBOSE << " - Eta Bin: " << eta_bin << endmsg; + (*m_log) << MSG::VERBOSE << " - Phi Bin: " << phi_bin << endmsg; + (*m_log) << MSG::VERBOSE << " - Et Bin: " << et_bin << endmsg; + (*m_log) << MSG::VERBOSE << " - CalibFactor: " << CalibFactor << endmsg; + } +#endif + + double corrected_transverse_energy = (begin_grid->e()/cosh(begin_grid->eta()))*CalibFactor; + double corrected_energy = corrected_transverse_energy*cosh(begin_grid->eta() ); + + m_grid_element->setE(corrected_energy); + m_grid_element->setEta(begin_grid->eta()); + m_grid_element->setPhi(begin_grid->phi()); + m_grid_element->setCaloSample(begin_grid->caloSample()); + + new_grid->push_back(*m_grid_element); + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << " Calibrated Trig3Momentum[" << jet_counter + << "]: Et: " << m_grid_element->e()/cosh(m_grid_element->eta()) + << " MeV, eta: " << m_grid_element->eta() + << ", phi: " << m_grid_element->phi() + << ", sampling: " << std::hex << m_grid_element->caloSample() << std::dec << endmsg; + } +#endif + jet_counter++; + + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "A total of " << new_grid->size() << " particles were calibrated" << endmsg; + } +#endif + + jet->setGrid(new_grid); + delete old_grid; + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "===== Finished: T2L1TowerCalibTool " << name() << endmsg; + } +#endif + + return StatusCode::SUCCESS; +} + + +//----------------------------------------------------------------- +// Finalize: +//----------------------------------------------------------------- +StatusCode T2L1TowerCalibTool::finalize() +{ + delete m_log; + delete m_grid_element; + return StatusCode::SUCCESS; +} + +//----------------------------------------------------------------- +// Calibration tools: +//----------------------------------------------------------------- +StatusCode T2L1TowerCalibTool::setProperty (const std::string& propname, + const std::string& value) +{ + StatusCode sc = AlgTool::setProperty (propname, value); + if (sc.isFailure()) return sc; + + sc=CaloRec::ToolWithConstantsMixin::setProperty (propname, value); + if (sc.isFailure()) return sc; + + return StatusCode::SUCCESS; +} + +StatusCode T2L1TowerCalibTool::setProperty (const Property& p) +{ + StatusCode sc=AlgTool::setProperty (p); + if (sc.isFailure()) return sc; + + sc=CaloRec::ToolWithConstantsMixin::setProperty (p); + if (sc.isFailure()) return sc; + + return StatusCode::SUCCESS; + +} + +int T2L1TowerCalibTool::GetEtaBin(double jet_eta) +{ + //45 eta bins + int ieta=int(((jet_eta*10)+45)/2); + // if (jet_eta<0) ieta-=1; + if ( ieta < 0 ) return 0; + if ( ieta > 43 ) return 44; + return ieta; +} + + +int T2L1TowerCalibTool::GetPhiBin(double jet_phi) +{ + //32 eta bins + int iphi=int(((jet_phi*10)+M_PI*10)/2); + // if (jet_eta<0) ieta-=1; + if ( iphi < 0 ) return 0; + if ( iphi > 31 ) return 31; + return iphi; +} + + + +int T2L1TowerCalibTool::GetEtBin(double jet_et) +{ + //21 Et bins + int iet = int(log10(jet_et/1000.)*10-10); + if ( iet < 0 ) return 0; + if ( iet > 19 ) return 20; + return iet; +} + + +double T2L1TowerCalibTool::GetEtaCalibFactor(int etabin, int /* phibin */, int etbin) +{ + return m_CalibConstants[etabin][etbin]; +} + + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1Unpacking.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1Unpacking.cxx new file mode 100644 index 00000000000..008cfa2e914 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/T2L1Unpacking.cxx @@ -0,0 +1,649 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2L1Unpacking.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloJet +// +// AUTHOR: Matthew Tamsett, tamsett@cern.ch +// +// Description: Level 1.5 unpacking FEX algorithm +// ******************************************************************** + +#include "TrigT2CaloJet/T2L1Unpacking.h" +#include "TrigCaloEvent/Trig3Momentum.h" +#include "TrigCaloEvent/TrigT2Jet.h" +//#include "TrigCaloEvent/TrigT2JetContainer.h" +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" + +#include "TrigT1CaloByteStream/ITrigT1CaloDataAccess.h" +#include "TrigT1CaloToolInterfaces/IL1JetTools.h" +#include "TrigT1CaloEvent/TriggerTower.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + + + +T2L1Unpacking::T2L1Unpacking(const std::string & name, ISvcLocator* pSvcLocator) + : HLT::AllTEAlgo(name, pSvcLocator), + m_tools(this), + //m_total_timer(0), + m_l1_unpacking_timer(0), + m_unpacking_timer(0), + m_calibration_timer(0), + m_RoI_timer(0), + m_dataL1("LVL1BS__TrigT1CaloDataAccess/TrigT1CaloDataAccess",0), + m_jet(0), + m_grid_element(0) +{ + // configurables + declareProperty("TrigT1CaloDataAccess", m_dataL1, "L1 Calo Data Access"); + declareProperty("jetOutputKey", m_jetOutputKey = "T2L1Towers"); + declareProperty("doTriggerTowers", m_doTriggerTowers = false); + declareProperty("T2JetTools", m_tools, "list of Jet tools"); + + // monitoring + declareMonitoredVariable("L1UnpckTime", m_L1UnpckTime); + declareMonitoredVariable("UnpckTime", m_UnpckTime); + declareMonitoredVariable("CalibrationTime",m_CalibrationTime); + declareMonitoredVariable("RoITime", m_RoITime); + //declareMonitoredVariable("OverallTime", m_TotalTime); + declareMonitoredVariable("nTowers", m_nTowers); + declareMonitoredVariable("nEMTowers", m_nEMTowers); + declareMonitoredVariable("nHADTowers", m_nHADTowers); + declareMonitoredVariable("nTowers_zoom", m_nTowers); + declareMonitoredVariable("nEMTowers_zoom", m_nEMTowers); + declareMonitoredVariable("nHADTowers_zoom",m_nHADTowers); + declareMonitoredStdContainer("Et", m_et); + declareMonitoredStdContainer("EtEM", m_et_em); + declareMonitoredStdContainer("EtHAD", m_et_had); + declareMonitoredStdContainer("Eta", m_eta); + declareMonitoredStdContainer("EtaEM", m_eta_em); + declareMonitoredStdContainer("EtaHAD", m_eta_had); + declareMonitoredStdContainer("Phi", m_phi); + declareMonitoredStdContainer("PhiEM", m_phi_em); + declareMonitoredStdContainer("PhiHAD", m_phi_had); + +} + +HLT::ErrorCode T2L1Unpacking::hltInitialize() +{ + m_log = new MsgStream(msgSvc(), name()); + + if((*m_log).level() <= MSG::INFO){ + (*m_log) << MSG::INFO << " Initalizing FEX algorithm: " << name() << endmsg; + //(*m_log) << MSG::DEBUG << "Options: " << endmsg; + } + + // Initialize timing service + if( service( "TrigTimerSvc", m_pTimerService).isFailure() ) { + (*m_log) << MSG::WARNING << name() << ": Unable to locate TrigTimer Service" << endmsg; + } + + if (m_pTimerService){ + (*m_log) << MSG::DEBUG << " Adding timers" << endmsg; + //Add timers + //m_total_timer = addTimer("total_time"); + m_l1_unpacking_timer = addTimer("l1_unpacking_time"); + m_unpacking_timer = addTimer("unpacking_time"); + m_calibration_timer = addTimer("calibration_time"); + m_RoI_timer = addTimer("RoI_time"); + } + + // Create helper tools + if ( m_dataL1.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_dataL1 << endmsg; + m_retrievedJetTool = false; + } else { + m_retrievedJetTool = true; + (*m_log) << MSG::DEBUG << "Retrieved " << m_dataL1 << endmsg; + } + + if ( m_tools.retrieve().isFailure() ) { + (*m_log) << MSG::ERROR << "Failed to retreive helper tools: " << m_tools << endmsg; + } else { + (*m_log) << MSG::INFO << "Retrieved " << m_tools << endmsg; + } + + // settings for Trigger tower retrieval + m_etaMin = -5.; + m_etaMax = 5.; + m_phiMin = 0.; + m_phiMax = 2 * M_PI; + m_fullScan = true; + + /// aha! fullscan should be from -pi to pi + + // output + m_grid_element = new Trig3Momentum(); + + + + return HLT::OK; +} + +T2L1Unpacking::~T2L1Unpacking(){ +} + +HLT::ErrorCode T2L1Unpacking::hltExecute(std::vector<std::vector<HLT::TriggerElement*> >& /*tes_in*/, + unsigned int type_out) +{ + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + beforeExecMonitors().ignore(); + + // ==== pre-execute setup + if(doTiming()) { + //m_total_timer->reset(); + m_l1_unpacking_timer->reset(); + m_unpacking_timer->reset(); + m_calibration_timer->reset(); + m_RoI_timer->reset(); + //m_total_timer->start(); + } + m_nTowers = -99; + m_nEMTowers = -99; + m_nHADTowers = -99; + m_UnpckTime = -99; + m_RoITime = -99; + //m_TotalTime = -99; + m_et.clear(); + m_et_em.clear(); + m_et_had.clear(); + m_eta.clear(); + m_eta_em.clear(); + m_eta_had.clear(); + m_phi.clear(); + m_phi_em.clear(); + m_phi_had.clear(); + + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "================= Executing T2L1Unpacking FEX " << name() << endmsg; + + } +#endif + + // === setup the output trigger element + if(doTiming()) m_RoI_timer->start(); + + TrigRoiDescriptor* roi = new TrigRoiDescriptor( true ); + + HLT::TriggerElement* outputTE = addRoI(type_out, roi ); /// NB: a fullscan RoI !!! + outputTE->setActiveState(true); + if(doTiming()) m_RoI_timer->stop(); + + if(doTiming()) m_unpacking_timer->start(); + std::vector<Trig3Momentum>* grid = new std::vector<Trig3Momentum>(); + grid->reserve(8000); + + // === unpacking + int counter = 0; + uint16_t tower_by_sampling_counter = 0; + int recorded_counter = 0; + int EM_recorded_counter = 0; + int HAD_recorded_counter = 0; + if ( m_doTriggerTowers ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Trigger tower version" <<endmsg; + } +#endif + // now get TT's + DataVector<LVL1::TriggerTower>::const_iterator tt_begj, tt_endj; + if ( m_retrievedJetTool ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loading the L1 data using ITrigT1CaloDataAccess tool"<< endmsg; + (*m_log) << MSG::DEBUG << "Getting trigger towers using " + << " roi: " << *roi + // << " etaMin: " << m_etaMin + // << ", etaMax: " << m_etaMax + // << ", phiMin: " << m_phiMin + // << ", phiMax: " << m_phiMax + << ", full: " << m_fullScan << endmsg; + } +#endif + if(doTiming()) m_l1_unpacking_timer->start(); + StatusCode sc = m_dataL1->loadCollection( tt_begj, tt_endj, + roi->etaMinus(), roi->etaPlus(), + roi->phiMinus(), roi->phiPlus(), roi->isFullscan() ); + if(doTiming()) m_l1_unpacking_timer->stop(); + if (sc.isFailure()) { + (*m_log) << MSG::WARNING << "Error accessing trigger tower data" << endmsg; + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loaded trigger towers in "<< m_l1_unpacking_timer->elapsed() << " ms" << endmsg; + (*m_log) << MSG::DEBUG << "Looping over trigger towers"<< endmsg; + } +#endif + } + for(; tt_begj!=tt_endj;++tt_begj){ + const LVL1::TriggerTower* TT = (*tt_begj); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "TriggerTower[" << counter + << "]: ETs [GeV]: EM: " << TT->emEnergy() + << ", HAD: " << TT->hadEnergy() + << ", eta: " << TT->eta() + << ", phi: " << TT->phi() << endmsg; + } +#endif + counter++; + // To remove ambiguities due to degenerate distance measures we deform the calorimeter: + // low eta, low phi cells are marginally closer together than high eta, high phi cells. + // + // It's best to use slightly different deformations for eta and phi. + // taken from recomendation 5. from here: http://fastjet.fr/FAQ.html + double tt_eta = TT->eta() + 1.000000e-6 * pow(TT->eta(),2); + double tt_phi = TT->phi() + 1.047198e-6 * pow(TT->phi(),2); + // change to a more standard phi definition + if( tt_phi >= M_PI ) tt_phi -= 2 * M_PI; + double transverse_energy = (TT->emEnergy() + TT->hadEnergy())*1000.; + //double cosh_eta = cosh(tt_eta); + //double energy = transverse_energy*cosh_eta; + // possibly do some calibration + + + if (transverse_energy > 0.99){ // some Jet Elements have zero energy (this may also be true for trigger towers), there is no need to give these to fastjet + // Set properties, EM and HAD seperately + // EM + if (TT->emEnergy()){ + tower_by_sampling_counter++; + double this_eta = determineTriggerTowerEta(tt_eta,true); + double this_cosh_eta = cosh(this_eta); + m_grid_element->setE((TT->emEnergy()*1000.)*this_cosh_eta); + m_grid_element->setEta(this_eta); // map this eta to a physical eta + m_grid_element->setPhi(tt_phi); + CaloSampling::CaloSample sampling = determineCaloSampling(fabs(tt_eta), true); + m_grid_element->setCaloSample(sampling); + if (TT->hadEnergy()){ + // record provenance of this jet + // in this context this means that if the tower was split into two we keep the index of its other half + m_grid_element->setProvenance(tower_by_sampling_counter); + } else { + m_grid_element->setProvenance(uint16_t(9999)); + } + + grid->push_back(*m_grid_element); + EM_recorded_counter++; + // Monitor + m_et_em.push_back( TT->emEnergy()*1000. ); + m_eta_em.push_back( m_grid_element->eta() ); + m_phi_em.push_back( m_grid_element->phi() ); + + } + // HAD + if (TT->hadEnergy()){ + tower_by_sampling_counter++; + double this_eta = determineTriggerTowerEta(tt_eta,false); + double this_cosh_eta = cosh(this_eta); + m_grid_element->setE((TT->hadEnergy()*1000.)*this_cosh_eta); + m_grid_element->setEta(this_eta); // map this eta to a physical eta + m_grid_element->setPhi(tt_phi); + CaloSampling::CaloSample sampling = determineCaloSampling(fabs(tt_eta), false); + m_grid_element->setCaloSample(sampling); + if (TT->emEnergy()){ + // record provenance of this jet + // in this context this means that if the tower was split into two we keep the index of its other half + m_grid_element->setProvenance(tower_by_sampling_counter-2); + } else { + m_grid_element->setProvenance(uint16_t(9999)); + } + + grid->push_back(*m_grid_element); + HAD_recorded_counter++; + // Monitor + m_et_had.push_back( TT->hadEnergy()*1000. ); + m_eta_had.push_back( m_grid_element->eta() ); + m_phi_had.push_back( m_grid_element->phi() ); + } + + // Monitor + recorded_counter++; + m_et.push_back( transverse_energy ); + m_eta.push_back( tt_eta ); + m_phi.push_back( tt_phi ); + + } + } + } else { // if we aren't running on trigger towers we use jet elements instead +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Jet element version" <<endmsg; + } +#endif + DataVector<LVL1::JetElement>::const_iterator je_begj, je_endj; + + if ( m_retrievedJetTool ){ +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loading the L1 data using ITrigT1CaloDataAccess tool, this loads the jet elements for the entire event"<< endmsg; + } +#endif + if(doTiming()) m_l1_unpacking_timer->start(); + StatusCode sc = m_dataL1->loadCollection(je_begj,je_endj); + if(doTiming()) m_l1_unpacking_timer->stop(); + if (sc.isFailure()) { + (*m_log) << MSG::WARNING << "Error accessing jet element data" << endmsg; + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Loaded jet elements in "<< m_l1_unpacking_timer->elapsed() << " ms" << endmsg; + (*m_log) << MSG::DEBUG << "Looping over jet elements"<< endmsg; + } +#endif + } + + for(; je_begj!=je_endj;++je_begj){ + const LVL1::JetElement* JE = (*je_begj); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "JetElement[" << counter + << "]: ETs [GeV]: EM: " << JE->emEnergy() + << ", HAD: " << JE->hadEnergy() + << ", Total: " << JE->energy() + << ", eta: " << JE->eta() + << ", phi: " << JE->phi() << endmsg; + } +#endif + counter++; + // To remove ambiguities due to degenerate distance measures we deform the calorimeter: + // low eta, low phi cells are marginally closer together than high eta, high phi cells. + // + // It's best to use slightly different deformations for eta and phi. + // taken from recomendation 5. from here: http://fastjet.fr/FAQ.html + double je_eta = JE->eta() + 1.000000e-6 * pow(JE->eta(),2); + double je_phi = JE->phi() + 1.047198e-6 * pow(JE->phi(),2); + // change to a more standard phi definition + if( je_phi >= M_PI ) je_phi -= 2 * M_PI; + double transverse_energy = (JE->energy())*1000.; + double cosh_eta = cosh(je_eta); + //double energy = transverse_energy*cosh_eta; + // possibly do some calibration + + + if (transverse_energy > 0.99){ // some Jet Elements have zero energy, there is no need to give these to fastjet + // Set properties, EM and HAD seperately + // EM + if (JE->emEnergy()){ + tower_by_sampling_counter++; + m_grid_element->setE((JE->emEnergy()*1000.)*cosh_eta); + m_grid_element->setEta(je_eta); + m_grid_element->setPhi(je_phi); + CaloSampling::CaloSample sampling = determineCaloSampling(fabs(je_eta), true); + m_grid_element->setCaloSample(sampling); + if (JE->hadEnergy()){ + // record provenance of this jet + // in this context this means that if the tower was split into two we keep the index of its other half + m_grid_element->setProvenance(tower_by_sampling_counter); + } else { + m_grid_element->setProvenance(uint16_t(9999)); + } + + grid->push_back(*m_grid_element); + EM_recorded_counter++; + // Monitor + m_et_em.push_back( JE->emEnergy()*1000. ); + m_eta_em.push_back( m_grid_element->eta() ); + m_phi_em.push_back( m_grid_element->phi() ); + + } + // HAD + if (JE->hadEnergy()){ + tower_by_sampling_counter++; + m_grid_element->setE((JE->hadEnergy()*1000.)*cosh_eta); + m_grid_element->setEta(je_eta); + m_grid_element->setPhi(je_phi); + CaloSampling::CaloSample sampling = determineCaloSampling(fabs(je_eta), false); + m_grid_element->setCaloSample(sampling); + if (JE->emEnergy()){ + // record provenance of this jet + // in this context this means that if the tower was split into two we keep the index of its other half + m_grid_element->setProvenance(tower_by_sampling_counter-2); + } else { + m_grid_element->setProvenance(uint16_t(9999)); + } + + grid->push_back(*m_grid_element); + HAD_recorded_counter++; + // Monitor + m_et_had.push_back( JE->hadEnergy()*1000. ); + m_eta_had.push_back( m_grid_element->eta() ); + m_phi_had.push_back( m_grid_element->phi() ); + } + + // Monitor + recorded_counter++; + m_et.push_back( transverse_energy ); + m_eta.push_back( je_eta ); + m_phi.push_back( je_phi ); + } + } + } + + // monitor + //m_nTowers = outJets->size(); + m_nTowers = recorded_counter; + m_nEMTowers = EM_recorded_counter; + m_nHADTowers = HAD_recorded_counter; + if(doTiming()) m_unpacking_timer->stop(); + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "A total of " << grid->size() << " L1 particles are to be clustered" << endmsg; + } + + if((*m_log).level() <= MSG::VERBOSE){ + std::vector<Trig3Momentum>::const_iterator begin_jet, end_jet; // iterators for the produced jets + begin_jet = grid->begin(); + end_jet = grid->end(); + int jet_counter = 0; + for (; begin_jet != end_jet; ++begin_jet){ + (*m_log) << MSG::VERBOSE << "Trig3Momentum[" <<jet_counter + << "]: Et: " << begin_jet->e()/cosh(begin_jet->eta()) + << " MeV, " + << "eta: " << begin_jet->eta() + << ", phi: " << begin_jet->phi() + << ", sampling: " << std::hex << begin_jet->caloSample() << std::dec + << ", provenance: " << begin_jet->provenance() << endmsg; + jet_counter++; + } + } +#endif + + if(doTiming()) m_RoI_timer->start(); + m_jet = new TrigT2Jet(); + m_jet->setGrid(grid); + //// RoI word +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Making TrigT2Jet to save" << endmsg; + } +#endif + if(doTiming()) m_RoI_timer->pause(); + + // do loop over tools, e.g tower level correction tool + // === calibration + if(doTiming()) m_calibration_timer->start(); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << m_tools.size() << " calibration tools to be run"<< endmsg; + + } +#endif + + ToolHandleArray< T2CaloJetBaseTool >::iterator it = m_tools.begin(), + itToolEnd = m_tools.end(); + int current=1; + for (; it != itToolEnd; ++it) { +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "Executing tool [" << current << "]"<< endmsg; + } +#endif + if ((*it)->execute(m_jet, TrigRoiDescriptor(true), caloDDENull ).isFailure()){ // the zeros are the unused eta phi coordinates used by many base tools to define the RoI region + msg() << MSG::WARNING << "T2CaloFastJet AlgToolJets returned Failure" << endmsg; + return HLT::ErrorCode(HLT::Action::ABORT_CHAIN,HLT::Reason::USERDEF_1); + } + current++; + } + if(doTiming()) m_calibration_timer->stop(); + + // === finaly recored the output jet + if(doTiming()) m_RoI_timer->resume(); + std::string key = ""; + HLT::ErrorCode stat = recordAndAttachFeature(outputTE, m_jet, key, m_jetOutputKey); + if (stat != HLT::OK){ + (*m_log) << MSG::ERROR << "recording of TrigT2Jets into StoreGate failed" << endmsg; + return stat; + } + if(doTiming()) m_RoI_timer->stop(); + + + // === post-execute admin + if(doTiming()) { + //m_total_timer->stop(); + m_L1UnpckTime = m_l1_unpacking_timer->elapsed(); + m_UnpckTime = m_unpacking_timer->elapsed(); + m_RoITime = m_RoI_timer->elapsed(); + //m_TotalTime = m_total_timer->elapsed(); +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "L1 unpacking completed in " << m_l1_unpacking_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "All unpacking completed in " << m_unpacking_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "Calibration completed in " << m_calibration_timer->elapsed() << " ms " << endmsg; + (*m_log) << MSG::DEBUG << "RoI making completed in " << m_RoI_timer->elapsed() << " ms " << endmsg; + //(*m_log) << MSG::DEBUG << "T2L1Unpacking completed in " << m_total_timer->elapsed() << " ms " << endmsg; + } +#endif + } + +#ifndef NDEBUG + if((*m_log).level() <= MSG::DEBUG){ + (*m_log) << MSG::DEBUG << "================= Finished T2L1Unpacking " << name() << endmsg; + } +#endif + + // since this is an AllTEAlgo, we have to call the monitoring ourselves: + afterExecMonitors().ignore(); + + return HLT::OK; +} + + +HLT::ErrorCode T2L1Unpacking::hltFinalize() +{ + if ( (*m_log).level() <= MSG::DEBUG ) + (*m_log) << MSG::DEBUG << "Finalizing T2L1Unpacking FEX " << name() << endmsg; + + m_et.clear(); + m_et_em.clear(); + m_et_had.clear(); + m_eta.clear(); + m_eta_em.clear(); + m_eta_had.clear(); + m_phi.clear(); + m_phi_em.clear(); + m_phi_had.clear(); + delete m_grid_element; + m_grid_element = 0; + + delete m_log; + + return HLT::OK; +} + +double T2L1Unpacking::determineTriggerTowerEta(double eta, bool isEM) +{ + /* + Determines a more realistic eta coordinate for the forward trigger towers + + The mapping used is: + * "EM" + ---- + Tower "eta" : -4.7 -4.3 -3.8 -3.4 3.4 3.8 4.3 4.7 + Physical eta: -4.45 -3.75 -3.35 -3.15 3.15 3.35 3.75 4.45 + Module : FCAL1 FCAL1 FCAL1 FCAL1 FCAL1 FCAL1 FCAL1 FCAL1 + + * "Had": + ------ + Tower "eta" : -4.7 -4.3 -3.8 -3.4 3.4 3.8 4.3 4.7 + Physical eta: -4.2 -4.2 -3.4 -3.4 3.4 3.4 4.2 4.2 + Module : FCAL2 FCAL3 FCAL2 FCAL3 FCAL2 FCAL3 FCAL2 FCAL3 + + You'll note that each L1 tower is either FCAL2 or FCAL3, not the sum of the two. + */ + + double fabs_eta = fabs(eta); + + if (fabs_eta < 3.3) return eta; // for non-forward towers return eta + + double sign_eta = 1; + if (eta < 0.) sign_eta = -1; + + if (fabs_eta > 4.5){ + if (isEM) return sign_eta*4.45; + return sign_eta*4.2; + + } else if (fabs_eta > 4.1){ + if (isEM) return sign_eta*3.75; + return sign_eta*4.2; + + } else if (fabs_eta > 3.6){ + if (isEM) return sign_eta*3.35; + return sign_eta*3.4; + + } else { + if (isEM) return sign_eta*3.15; + return sign_eta*3.4; + } +} + +CaloSampling::CaloSample T2L1Unpacking::determineCaloSampling(double fabs_eta, bool isEM) +{ + /* + Determine the calo sampling of trigger towers and jet elements based on their eta + + For Trigger towers this mapping is + EM layer: |eta| = 0 - 1.5 LArg EM Barrel + |eta| = 1.4 - 3.2 LArg EM Endcap: note the overlap here + + Had layer: |eta| = 0 - 0.9 Tile Long Barrel + |eta| = 0.9 - 1.5 Tile Extended Barrel + |eta| = 1.5 - 3.2 LArg Hadronic Endcap + + FCAL: anything above |eta| = 3.2 + + In addition, for jet elements: + [em] |eta| = 1.4-1.6 spans EMB+EMEC (1.5 in JE eta) + + [had] |eta| = 0.8-1.0 partly tile barrel, partly extended barrel (0.9 in JE eta) + |eta| = 1.4-1.6 Tile-HEC transition (1.5 in JE eta) + + [em?] |eta| = 2.4-2.7, i.e. the OW+IW boundary. (2.55 in JE eta) + + As these are summed over layers we'll return the middle sampling + */ + + if (fabs_eta > 3.2) { // FCAL + if (isEM) return CaloSampling::FCAL0; // EM FCAL + return CaloSampling::FCAL1; // HAD FCAL + } else if (isEM && (fabs_eta < 1.4)) { // EM, cut at 1.4 assigns overlap region to the EME + return CaloSampling::EMB1; + } else if (isEM) { + return CaloSampling::EME1; + } else if (fabs_eta < 0.8) { // HAD, cut at 0.8 assigns overlap region to TileExt + return CaloSampling::TileBar1; + } else if (fabs_eta < 1.4) { // cut at 1.4 assigne overlap region to HEC + return CaloSampling::TileExt1; + } else { + return CaloSampling::HEC1; + } +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/Trig3MomentumMerger.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/Trig3MomentumMerger.cxx new file mode 100644 index 00000000000..daa54180b57 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/Trig3MomentumMerger.cxx @@ -0,0 +1,140 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigT2CaloJet/Trig3MomentumMerger.h" + +#include <iostream> +#include <algorithm> +#include <cmath> // M_PI, fabs + +//------------------------------------------------ +Trig3MomentumMerger::Trig3MomentumMerger() : +m_hashMap(), m_gridsHandler() +{ +} +//------------------------------------------------ +void resetCell(HashedTrig3Momentum &c) +{ + c.reset(); +} +//------------------------------------------------ +// match criterion to be used with find_if +struct HashMatchCriterion +{ + HashMatchCriterion(const u_int value, const EtaPhiSampleHash &hm): + hash_(value), m_hashMap(hm) {}; + bool operator() (const HashedTrig3Momentum &cell) { + return hash_ == cell.hash(); + }; + u_int hash_; + EtaPhiSampleHash m_hashMap; +}; + +//------------------------------------------------ +// functor to be used with for_each +struct CellMerger +{ + CellMerger(const EtaPhiSampleHash &hm, GridsHandler &gridsHandler) : + hm_(hm), m_gridsHandler(gridsHandler) {} + void operator() (const Trig3Momentum &t3m) { + u_int hash(hm_.hash(t3m)); + HashMatchCriterion hmc(hash, hm_); + Vmc &grid = m_gridsHandler.grid(t3m.caloSample()); + Vmc::iterator mergeCell = find_if(grid.begin(), grid.end(), hmc); + if(mergeCell != grid.end()) mergeCell->addE(t3m); + else grid.push_back(HashedTrig3Momentum(t3m, hash)); + } + EtaPhiSampleHash hm_; + GridsHandler &m_gridsHandler; +}; +//------------------------------------------------ +bool Trig3MomentumMerger::mergeCells(const Vt3m &input, Vt3m &output) +{ + m_gridsHandler.clearAllGrids(); + CellMerger merger(m_hashMap, m_gridsHandler); + std::for_each(input.begin(), input.end(), merger); + m_gridsHandler.appendAllGrids(output); + return true; +} +//------------------------------------------------ +unsigned int Trig3MomentumMerger::expectedLength(const Vt3m &input) +{ + // 4*4 b/c we should reduce the (eta,phi) granularity from 0.025x0.025 -> 0.1x0.1 + unsigned int expectedRedFactor=4*4; + return input.size()/expectedRedFactor; +} +//------------------------------------------------ +void testEtaPhiSampleHash(){ + using std::cout; + using std::endl; + double epsilon = 1.0e-9; + double eta = EtaPhiSampleHash::kMinEta + epsilon; + double phi = EtaPhiSampleHash::kMinPhi + epsilon; + double dEta(2.0*5.0/100.), dPhi(2.0*M_PI/64.); + const int nSamples = 25; + // drop this and use GridsHandler::allSamples_ + CaloSampling::CaloSample samples[nSamples] = + { + CaloSampling::PreSamplerB, + CaloSampling::EMB1, + CaloSampling::EMB2, + CaloSampling::EMB3, + CaloSampling::PreSamplerE, + CaloSampling::EME1, + CaloSampling::EME2, + CaloSampling::EME3, + CaloSampling::HEC0, + CaloSampling::HEC1, + CaloSampling::HEC2, + CaloSampling::HEC3, + CaloSampling::TileBar0, + CaloSampling::TileBar1, + CaloSampling::TileBar2, + CaloSampling::TileGap1, + CaloSampling::TileGap2, + CaloSampling::TileGap3, + CaloSampling::TileExt0, + CaloSampling::TileExt1, + CaloSampling::TileExt2, + CaloSampling::FCAL0, + CaloSampling::FCAL1, + CaloSampling::FCAL2, + CaloSampling::Unknown + }; + + CaloSampling::CaloSample sample = CaloSampling::PreSamplerB; + EtaPhiSampleHash eph; + int iSample(0); + eta = EtaPhiSampleHash::kMinEta + epsilon; + while(eta<EtaPhiSampleHash::kMaxEta){ + phi = EtaPhiSampleHash::kMinPhi + epsilon; + while(phi<EtaPhiSampleHash::kMaxPhi){ + iSample = 0; + while(iSample<nSamples){ + sample = samples[iSample]; + u_int hash(eph.hash(eta,phi,sample)); + cout<<"(eta, phi, sample) " + <<"= ("<<eta<<", "<<phi<<", "<<sample<<")" + <<" -> "<<hash<<endl; + double oEta(0.), oPhi(0.); + CaloSampling::CaloSample oSample(CaloSampling::Unknown); + eph.etaPhiSample(hash, oEta, oPhi, oSample); + if(fabs(eta-oEta)>dEta) + cout<<"deltaEta("<<hash<<", "<<fabs(eta-oEta)<<")" + <<" : in "<<eta<<" out "<<oEta<<endl; + if(fabs(phi-oPhi)>dPhi) + cout<<"deltaPhi("<<hash<<", "<<fabs(phi-oPhi)<<")" + <<" : in "<<phi<<" out "<<oPhi<<endl; + if(sample!=oSample) + cout<<"sample("<<hash<<")" + <<" : in "<<sample<<" out "<<oSample<<endl; + iSample++; + } // end while(iSample) + phi += dPhi; + } // end while(phi) + eta += dEta; + } // end while(eta) +} +//------------------------------------------------ + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloJet/src/components/TrigT2CaloJet_entries.cxx b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/components/TrigT2CaloJet_entries.cxx new file mode 100644 index 00000000000..3fb3d02c56c --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloJet/src/components/TrigT2CaloJet_entries.cxx @@ -0,0 +1,35 @@ +#include "TrigT2CaloJet/T2CaloJet.h" +#include "TrigT2CaloJet/T2L1CaloJet.h" +#include "TrigT2CaloJet/T2L1CaloFullScanJet.h" +#include "TrigT2CaloJet/T2L1Unpacking.h" +#include "TrigT2CaloJet/Trig3MomentumMerger.h" +#include "TrigT2CaloJet/T2AllRoiUnpacking.h" +#include "TrigT2CaloJet/T2CaloFastJet.h" +#include "TrigT2CaloJet/T2CaloJetBaseTool.h" +#include "TrigT2CaloJet/T2CaloJetConeTool.h" +#include "TrigT2CaloJet/T2CaloJetCalibTool.h" +#include "TrigT2CaloJet/T2CaloJetGridFromCells.h" +#include "TrigT2CaloJet/T2CaloJetGridFromFEBHeader.h" +#include "TrigT2CaloJet/T2CaloJetGridFromLvl1Ppr.h" +#include "TrigT2CaloJet/T2L1CaloJetFullScanBaseTool.h" +#include "TrigT2CaloJet/T2L1CaloJetFullScanFastJetTool.h" +#include "TrigT2CaloJet/T2L1TowerCalibTool.h" +#include "TrigT2CaloJet/T2L1CaloJetCalibTool.h" + +DECLARE_COMPONENT( T2CaloJet ) +DECLARE_COMPONENT( T2L1CaloJet ) +DECLARE_COMPONENT( T2L1CaloFullScanJet ) +DECLARE_COMPONENT( T2CaloFastJet ) +DECLARE_COMPONENT( T2L1Unpacking ) +DECLARE_COMPONENT( T2AllRoiUnpacking ) +DECLARE_COMPONENT( T2CaloJetBaseTool ) +DECLARE_COMPONENT( T2CaloJetConeTool ) +DECLARE_COMPONENT( T2CaloJetCalibTool ) +DECLARE_COMPONENT( T2CaloJetGridFromCells ) +DECLARE_COMPONENT( T2CaloJetGridFromFEBHeader ) +DECLARE_COMPONENT( T2CaloJetGridFromLvl1Ppr ) +DECLARE_COMPONENT( T2L1CaloJetFullScanBaseTool ) +DECLARE_COMPONENT( T2L1CaloJetFullScanFastJetTool ) +DECLARE_COMPONENT( T2L1TowerCalibTool ) +DECLARE_COMPONENT( T2L1CaloJetCalibTool ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/CMakeLists.txt b/Trigger/TrigAlgorithms/TrigT2CaloTau/CMakeLists.txt new file mode 100644 index 00000000000..3c3d84b5f7e --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/CMakeLists.txt @@ -0,0 +1,42 @@ +################################################################################ +# Package: TrigT2CaloTau +################################################################################ + +# Declare the package name: +atlas_subdir( TrigT2CaloTau ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + Calorimeter/CaloInterface + GaudiKernel + Trigger/TrigAlgorithms/TrigT2CaloCommon + Trigger/TrigEvent/TrigCaloEvent + Trigger/TrigEvent/TrigSteeringEvent + Trigger/TrigSteer/TrigInterfaces + Trigger/TrigTools/TrigT2CaloCalibration + PRIVATE + Calorimeter/CaloEvent + Calorimeter/CaloGeoHelpers + Calorimeter/CaloIdentifier + Control/AthenaKernel + Trigger/TrigT1/TrigT1Interfaces ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( TrigT2CaloTauLib + src/*.cxx + PUBLIC_HEADERS TrigT2CaloTau + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel TrigCaloEvent TrigSteeringEvent TrigT2CaloCommonLib TrigInterfacesLib TrigT2CaloCalibrationLib + PRIVATE_LINK_LIBRARIES CaloEvent CaloGeoHelpers CaloIdentifier AthenaKernel TrigT1Interfaces ) + +atlas_add_component( TrigT2CaloTau + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel TrigT2CaloCommonLib TrigCaloEvent TrigSteeringEvent TrigInterfacesLib TrigT2CaloCalibrationLib CaloEvent CaloGeoHelpers CaloIdentifier AthenaKernel TrigT1Interfaces TrigT2CaloTauLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CalibrationTau.h b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CalibrationTau.h new file mode 100755 index 00000000000..8bad3b2b7a6 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CalibrationTau.h @@ -0,0 +1,52 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CalibrationTau.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTau +// +// AUTHOR: D.O. Damazio +// +// Object only designed to understand cluster calibration +// Should be used by EM and Tau people in the near future +// It should be possible to introduce the calibration configuration +// from a jobOption file. Not possible now. +// +// ******************************************************************** + +#ifndef TRIGT2CALOTAU_T2CALIBRATIONTAU +#define TRIGT2CALOTAU_T2CALIBRATIONTAU +#include <vector> +#include <math.h> +#include "TrigT2CaloCommon/T2Calibration.h" + +class T2CalibrationTau : public T2Calibration { +public: + +/** Constructor */ + T2CalibrationTau() : T2Calibration(){} +/** Destructor */ + ~T2CalibrationTau(){} + + // The two methods of this class, initialize and Calib, are virtual + // in the base class T2Calibration and implemented there as for the + // moment calibration is the same for egamma/tau. For an specific + // calibration override these methods. + + // In the initialize, one should provide a vector with the + // Eta limits (eg.: 0-2.5), the dimensions of the correction + // vector (eg: 2 100 - for 2 lines of one hundred constants - the + // first line is the eta of that bin and the second brings + // the calibration constant for that bin +// void initialize(const std::vector<float>& limit, const std::vector<int>& +// dimension, const std::vector<float>& correction); + + // This, for a given cluster eta and energy (not being used yet), + // provides the calibration constant +// double Calib( const double ClusterEta, const double EnergyCluster); + +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTau.h b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTau.h new file mode 100755 index 00000000000..f9dad2ab720 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTau.h @@ -0,0 +1,144 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2Calo.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTau +// +// AUTHORS: M.P. Casado +// C. Osuna +// updates: 3/3/11 ccuenca, added new vars for monitoring +// +// - Add new variables to allow job option control of eta/phi regions +// used in each tool. Also hardcode in eta ranges and granularities +// for all layers and add a new function so that tools can adjust the +// number of strips used in energy sums for changes in granularity. +// The goal is to try to sample a constant eta/phi area. - R. Soluk +// ******************************************************************** + +#ifndef TRIGT2CALOTAU_T2CALOTAU_H +#define TRIGT2CALOTAU_T2CALOTAU_H + +#include <string> +#include "GaudiKernel/ToolHandle.h" +#include "TrigInterfaces/FexAlgo.h" +#include "TrigT2CaloCommon/T2CaloBase.h" +#include "TrigT2CaloCalibration/IT2HadCalibTool.h" +#include "TrigT2CaloTau/T2CaloTauErrorMon.h" +#include "TrigCaloEvent/TrigTauCluster.h" + +class StoreGateSvc; +namespace HLT +{ + class TriggerElement; +} +class IAlgToolCalo; + +class T2CaloTau : public T2CaloBase +{ +public: + /** Constructor */ + T2CaloTau(const std::string & name, ISvcLocator* pSvcLocator); + /** Destructor */ + ~T2CaloTau(); + /** HLT method to execute */ + HLT::ErrorCode hltExecute(const HLT::TriggerElement* inputTE, HLT::TriggerElement* outputTE); + + /** HLT method to initialize */ + HLT::ErrorCode hltInitialize(); + /** HLT method to finalize */ + HLT::ErrorCode hltFinalize(); + +private: + // Properties: + + /** SG key for TrigTauCluster*/ + std::string m_trigTauClusterKey; + + /** EMRadius variable for monitoring */ + double m_EMRadius; + /** EMRadius3S variable for monitoring */ + double m_EMRadius3S; + /** CaloRadius variable for monitoring */ + double m_CaloRadius; + + /** HadRad variable for monitoring */ + double m_HadRad; + + /** Isofrac variable for monitoring */ + double m_IsoFrac ; + /** stripWidth variable for monitoring*/ + double m_StripWidth ; + + /** Fraction of EM energy over total energy in a normal (dR<0.3) cone for monitoring */ + double m_EMFraction; + + /** Raw Et in wide 0.3 cone for monitoring */ + double m_EtRawWide; + + /** EM Energy in (dR<0.2) cone for monitoring */ + double m_EMEnMedium; + /** HAD Energy in (dR<0.2) cone for monitoring */ + double m_HADEnMedium; + + /** EM Energy in (dR<0.1) cone for monitoring */ + double m_EMEnNarrow; + /** HAD Energy in (dR<0.1) cone for monitoring */ + double m_HADEnNarrow; + /** Raw Et in medium cone for monitoring */ + double m_EtRawMedium; + /** Raw Et in medium cone for monitoring (EM Sampling 0) */ + double m_EtRawMediumEM0; + /** Raw Et in medium cone for monitoring (EM Sampling 1) */ + double m_EtRawMediumEM1; + /** Raw Et in medium cone for monitoring (EM Sampling 2) */ + double m_EtRawMediumEM2; + /** Raw Et in medium cone for monitoring (EM Sampling 3) */ + double m_EtRawMediumEM3; + /** Raw Et in medium cone for monitoring (Had Sampling 0) */ + double m_EtRawMediumHad0; + /** Raw Et in medium cone for monitoring (Had Sampling 1) */ + double m_EtRawMediumHad1; + /** Raw Et in medium cone for monitoring (Had Sampling 2) */ + double m_EtRawMediumHad2; + + /** EtRawNarrow/EtRawMedium */ + double m_CoreFraction; + + /** eta of seed of L1 ROI */ + double m_EtaL1 ; + /** phi of seed of L1 ROI */ + double m_PhiL1 ; + + /** eta of seed of calo Cluster */ + double m_Eta ; + /** phi of seed of calo Cluster */ + double m_Phi ; + /** Difference in Eta at L2 and L1 for monitoring */ + double m_dEtaL2Tau_RoI ; + /** Difference in Phi at L2 and L1 for monitoring */ + double m_dPhiL2Tau_RoI ; + + /** counter for conversion error */ + unsigned int m_conversionError; + /** counter for algorithm error */ + unsigned int m_algorithmError; + /** error monitoring of cluster quality */ + std::vector<unsigned char> m_quality; + + /** Should or not storeCells into a cell container attached to output RoI */ + bool m_storeCells; + /** container pointer */ + CaloCellContainer* m_Container; + + /** option to update RoiDescriptor after execution (important for following trigger chain steps) */ + bool m_updateRoiDescriptor; + + /** phi, eta EM width */ + double m_phiWidthEM; + double m_etaWidthEM; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorHandler.h b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorHandler.h new file mode 100755 index 00000000000..8fde34fa3a7 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorHandler.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOTAU_T2CALOTAUERRORHANDLER_H +#define TRIGT2CALOTAU_T2CALOTAUERRORHANDLER_H + +namespace TAUCLUSTERROR { + + /** enumerate tau-specific errors */ + enum TAUCLUSTERROR{ + FAILPRESEED=31, + FAILSEED=30, + HADS1E0=11, + HADS2E0=10, + HADS3E0=9, + EMS0E0=15, + EMS1E0=14, + EMS2E0=13, + EMS3E0=12 + }; + + +} +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorMon.h b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorMon.h new file mode 100755 index 00000000000..9288f4befa1 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/T2CaloTauErrorMon.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#ifndef TRIGT2CALOTAU_T2CALOTAUERRORMON_H +#define TRIGT2CALOTAU_T2CALOTAUERRORMON_H +#include "TrigT2CaloTau/T2CaloTauErrorHandler.h" + +namespace TAUCLUSTMON { + + /** enumerate tau-specific errors for monitoring */ + enum TAUCLUSTMON{ + LARPROB=0, + TILEPROB=1, + ROBPROB=2, + RODPROB=3, + FAILSEED=4, + FAILPRESEED=5, + EMS0E0=6, + EMS1E0=7, + EMS2E0=8, + EMS3E0=9, + HADS1E0=10, + HADS2E0=11, + HADS3E0=12, + OTHERERRORS=13, + GOODCLUST=14, + ALLCLUST=15 + }; + + bool GetClusterError(unsigned int bit,uint32_t error ) { return ((error >> bit)&0x1)!=0 ;} + + void FillErrorMonitoring(uint32_t error, std::vector<unsigned char> * quality){ + bool isError=false; + if ( 0x000000FF & error ) {isError=true; quality->push_back(LARPROB); } + if ( 0x0FFF0000 & error ) {isError=true; quality->push_back(TILEPROB); } + if ( 0x10000000 & error ) {isError=true; quality->push_back(ROBPROB); } + if ( 0x20000000 & error ) {isError=true; quality->push_back(RODPROB); } + if ( GetClusterError( TAUCLUSTERROR::FAILSEED , error) ) {isError=true; quality->push_back(FAILSEED); } + if ( GetClusterError( TAUCLUSTERROR::FAILPRESEED , error) ) {isError=true; quality->push_back(FAILPRESEED); } + if ( GetClusterError( TAUCLUSTERROR::EMS0E0 , error) ) {isError=true; quality->push_back(EMS0E0); } + if ( GetClusterError( TAUCLUSTERROR::EMS1E0 , error) ) {isError=true; quality->push_back(EMS1E0); } + if ( GetClusterError( TAUCLUSTERROR::EMS2E0 , error) ) {isError=true; quality->push_back(EMS2E0); } + if ( GetClusterError( TAUCLUSTERROR::EMS3E0 , error) ) {isError=true; quality->push_back(EMS3E0); } + if ( GetClusterError( TAUCLUSTERROR::HADS1E0 , error) ) {isError=true; quality->push_back(HADS1E0); } + if ( GetClusterError( TAUCLUSTERROR::HADS2E0 , error) ) {isError=true; quality->push_back(HADS2E0); } + if ( GetClusterError( TAUCLUSTERROR::HADS3E0 , error) ) {isError=true; quality->push_back(HADS3E0); } + if (isError==false && error>0 ) {quality->push_back(OTHERERRORS); } + } + +} +#endif + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/TauAllCaloDRFex.h b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/TauAllCaloDRFex.h new file mode 100644 index 00000000000..8e3b993182e --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/TrigT2CaloTau/TauAllCaloDRFex.h @@ -0,0 +1,90 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: TauAllCaloDRFex.h +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTau +// +// AUTHOR: Olga Igonkina (Nikhef), Pilar Casado (IFAE), Mogens Dam (NBI) +// +// CREATED: June-09 +// +// DESCRIPTION: Tool to compute calorimeter tau variables in EM and HAD +// ******************************************************************** + +#ifndef TRIGT2CALOTAU_TAUALLCALODRFEX_H +#define TRIGT2CALOTAU_TAUALLCALODRFEX_H + + +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "GaudiKernel/AlgTool.h" +#include "TrigCaloEvent/TrigTauCluster.h" +#include "TrigT2CaloTau/T2CaloTauErrorHandler.h" +#include "CaloInterface/ICalorimeterNoiseTool.h" + +class TauAllCaloDRFex : public IAlgToolCalo +{ +public: + /** Constructor */ + TauAllCaloDRFex(const std::string& type, const std::string& name, const IInterface* parent); + /** virtual Destructor */ + virtual ~TauAllCaloDRFex(); + /** execute method of IAlgToolCalo */ + using IAlgToolCalo::execute; + /** execute method */ + + /// take two roi descriptors into the shower + HLT::ErrorCode execute(TrigTauCluster &rtrigTauCluster, const IRoiDescriptor& roi, + const CaloDetDescrElement*& /*caloDDE*/); + + // HLT::ErrorCode execute(TrigTauCluster &rtrigTauCluster, double phiWidth, + // double etaWidth, double phiWidthEM, + // double etaWidthEM, double RoIeta, double RoIphi); + + // HLT::ErrorCode execute(TrigTauCluster &rtrigTauCluster,double phiWidth, + // double etaWidth, double RoIeta, double RoIphi); + + /** initialize function **/ + StatusCode initialize(); + +private: + /** Energy threshold for numStrips counting */ + double m_stripEthr; + + /** dR cut for reconstruction of the seed */ + double m_dRSeed; + /** dR cut for full region, Wide (previously called Normal) */ + double m_dRConeWide; + /** dR cut for Medium region (previously called Med) */ + double m_dRConeMedium; + /** dR cut for Narrow region (previously called Nar) */ + double m_dRConeNarrow; + + /** Variable to control noise substraction */ + bool m_applyNoiseCut; + /** Number of sigmas for noise cut */ + double m_noiseNSigmaCut; + /** int for hecQualityCut */ + int m_hecQualityCut; + + /** choose default width: 0 Narrow, 1 Medium, 2 Wide (Normal) */ + int m_defaultWidth; + + + /** Tool for noise substraction */ + ToolHandle<ICalorimeterNoiseTool> m_noiseTool; + + double emRadiusAllSampl(const TrigTauClusterDetails* clusterDetails, int maxEmSamp=100); + double caloRadius(const TrigTauClusterDetails* clusterDetails); + double coreFraction(const TrigTauClusterDetails* clusterDetails); + double emFraction(const TrigTauCluster* ptrigTauCluster); + double hadRadius(const TrigTauClusterDetails* clusterDetails); + double calcEnergyPhi(double energyNegPhi, double energyPosPhi, double EnergyWidNegPhi, double EnergyWidPosPhi, double energyNegPhiConv); + bool getdR(double compPhi, double compEta, double etaCell, double phiCell, double dRCut, double& dR); + double getEMEnergy(const TrigTauClusterDetails* clusterDetails, int widthChoice); + double getHADEnergy(const TrigTauClusterDetails* clusterDetails, int widthChoice); +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/doc/packagedoc.h b/Trigger/TrigAlgorithms/TrigT2CaloTau/doc/packagedoc.h new file mode 100644 index 00000000000..2f753fb3ea3 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/doc/packagedoc.h @@ -0,0 +1,21 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/** + +@page TrigT2CaloTau_page +@author Carlos Osuna +@author Stefania Xella +@author M. Pilar Casado +@author Olga Igonkina + +@section TrigT2CaloTau_TrigT2CaloTauOverview Overview +This package is in charge of the calorimeter reconstruction in +the trigger LVL2 for taus. It builds a set of shower shape variables +to discriminate jet and taus. +Deposited energy is available in 3 different window sizes for all sampling. + + + +*/ diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauConfig.py b/Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauConfig.py new file mode 100755 index 00000000000..a53ce9b16fd --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauConfig.py @@ -0,0 +1,104 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +#------------------------------------------------ +# T2CaloTau Calibration Options +#------------------------------------------------ + +from TrigT2CaloTau.TrigT2CaloTauConf import T2CaloTau, TauAllCaloDRFex + +from CaloTools.CaloNoiseToolDefault import CaloNoiseToolDefault +theCaloNoiseTool=CaloNoiseToolDefault() + +from AthenaCommon.AppMgr import ToolSvc +ToolSvc+=theCaloNoiseTool + +from AthenaCommon.Constants import VERBOSE,DEBUG,INFO + +#Make changes to TauAllCaloDRFex parameters here: + +class TauAllCaloDRFexConfig (TauAllCaloDRFex): + __slots__ = [] + def __init__ (self, name="TauAllCaloDRFexConfig",tdRNar=0.1,tdRMed=0.2,tdRWid=0.4,tdefWidth=2): + super(TauAllCaloDRFexConfig, self).__init__(name) + # here put your customizations + self.CaloNoiseTool = theCaloNoiseTool + self.applyNoiseCut = True + self.noiseNSigmaCut = 2. + self.hecQualityCut = 0 + self.dRSeed = 0.15 + self.StripEthr = 200. + self.defaultWidth = tdefWidth #Sets which width size is saved for EMEnergy (0:Narrow,1:Medium,2:Wide) + self.dRConeNarrow = tdRNar + self.dRConeMedium = tdRMed + self.dRConeWide = tdRWid + + +## configurable class +class T2CaloTau_Tau_custom (T2CaloTau): + __slots__ = [] + def __init__ (self, name="T2CaloTau_Tau_custom"): + super(T2CaloTau_Tau_custom, self).__init__(name) + self.EtaWidth = 0.4 + self.PhiWidth = 0.4 + self.EtaWidthForID = 0.3 + self.PhiWidthForID = 0.3 + + tauAllCaloDRFex = TauAllCaloDRFexConfig() + + self.IAlgToolList=[tauAllCaloDRFex] + self.TimerNtuple="T2CaloTau.T2CaTautTot" + self.TrigTauClusterKey = "T2CaloTrigTauCluster" + +# monitoring part. To switch off do in topOption TriggerFlags.enableMonitoring = [] + from TrigT2CaloTau.TrigT2CaloTauMonitoring import T2CaloTauValidationMonitoring, T2CaloTauOnlineMonitoring, T2CaloTauCosmicMonitoring + validation = T2CaloTauValidationMonitoring() + online = T2CaloTauOnlineMonitoring() + cosmic = T2CaloTauCosmicMonitoring() + + from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig + time = TrigTimeHistToolConfig("Time") + + self.AthenaMonTools = [ time, validation, online, cosmic ] + + +## calo monitoring class +class T2CaloTau_cells (T2CaloTau_Tau_custom): + __slots__ = [] + def __init__ (self, name="T2CaloTau_cells"): + super(T2CaloTau_cells, self).__init__(name) + # here put your customizations + self.IAlgToolList= [TauAllCaloDRFexConfig('tauAllCaloDRFexCells')] + # Save cells + for item in self.IAlgToolList: + item.SaveCellsInContainer=True + item.ThresholdKeepCells=-100000. + item.hecQualityCut=0 + item.CaloNoiseTool=theCaloNoiseTool + item.applyNoiseCut=False + item.noiseNSigmaCut=2. + + self.StoreCells=True + self.EtaWidth = 0.4 + self.PhiWidth = 0.4 + self.TimerNtuple="T2CaloTau.T2CaTautTot" + self.TrigTauClusterKey = "T2CaloTrigTauCluster" + + +############### to be imported by the menu ############### + +# default class (2011) +class T2CaloTau_Tau (T2CaloTau_Tau_custom): + __slots__ = [] + #def __init__ (self, name="T2CaloTau_Tau"): + def __init__ (self, name="T2CaloTau_Tau"): + T2CaloTau_Tau_custom.__init__(self,name) + tauAllCaloDRFex = TauAllCaloDRFexConfig(tdRNar=0.1,tdRMed=0.2,tdRWid=0.4,tdefWidth=2) # use Wide (Nor in 2011), cone size 0.4 + self.IAlgToolList=[tauAllCaloDRFex] + +# class for 2012: uses Medium cone size as default +class T2CaloTau_Tau_Med (T2CaloTau_Tau_custom): + __slots__ = [] + def __init__ (self, name="T2CaloTau_Tau_Med"): + T2CaloTau_Tau_custom.__init__(self,name) + tauAllCaloDRFex = TauAllCaloDRFexConfig(tdRNar=0.1,tdRMed=0.2,tdRWid=0.4,tdefWidth=1) # use Medium cone size (0.2) variables + self.IAlgToolList=[tauAllCaloDRFex] diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauMonitoring.py b/Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauMonitoring.py new file mode 100755 index 00000000000..2d831bbe61f --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/python/TrigT2CaloTauMonitoring.py @@ -0,0 +1,109 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + +################# Validation, DQ checks +from TrigMonitorBase.TrigGenericMonitoringToolConfig import defineHistogram, TrigGenericMonitoringToolConfig + +# Set labels for error monitoring histogram. The order has to match with T2CaloTauErrorMon.h file! Number has to match with histo definition. +errorlabels = 'LAr_Problem:Tile_Problem:N_ROBs<requested:empty_ROD_block:Fail_Seed:Fail_PreSeed:EM_S0_E0:EM_S1_E0:EM_S2_E0:EM_S3_E0:HAD_S1_E0:HAD_S2_E0:HAD_S3_E0:Other_Errors:Good_Clusters:All_Clusters' + +class T2CaloTauOnlineMonitoring(TrigGenericMonitoringToolConfig): + def __init__ (self, name="T2CaloTauOnlineMonitoring"): + super(T2CaloTauOnlineMonitoring, self).__init__(name) + self.defineTarget("Online") + + self.Histograms += [ defineHistogram('EMRadius', type='TH1F', title="L2CaloTau FEX EMRadius;EMRadius; nevents", xbins=100, xmin=-0.5, xmax=1.5) ] + self.Histograms += [ defineHistogram('EMRadius3S', type='TH1F', title="L2CaloTau FEX EMRadius3S;EMRadius3S; nevents", xbins=100, xmin=-0.5, xmax=1.5) ] + self.Histograms += [ defineHistogram('HadRad', type='TH1F', title="L2CaloTau FEX HadRad;HadRad; nevents", xbins=100, xmin=-0.5, xmax=1.5) ] + self.Histograms += [ defineHistogram('CaloRadius', type='TH1F', title="L2CaloTau FEX CaloRadius;CaloRadius; nevents", xbins=100, xmin=-0.5, xmax=1.5) ] + + self.Histograms += [ defineHistogram('IsoFrac', type='TH1F', title="L2CaloTau FEX IsoFrac;IsoFrac; nevents", xbins=80, xmin=-1.0, xmax=3.0) ] + self.Histograms += [ defineHistogram('StripWidth', type='TH1F', title="L2CaloTau FEX StripWidth;StripWidth; nevents", xbins=70, xmin=-0.1, xmax=0.6) ] + + self.Histograms += [ defineHistogram('EMFraction', type='TH1F', title="L2CaloTau FEX EM Energy Fraction;EMFraction; nevents", xbins=90, xmin=-0.6, xmax=1.2) ] + + ##Medium: cone 0.2 + self.Histograms += [ defineHistogram('EMEnMedium', type='TH1F', title="L2CaloTau FEX EMEnMedium in (dR<0.2) cone;EMEnMedium [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('HADEnMedium', type='TH1F', title="L2CaloTau FEX HADEnMedium in (dR<0.2) cone;HADEnMedium [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + + ##Narrow: cone 0.1 + self.Histograms += [ defineHistogram('EMEnNarrow', type='TH1F', title="L2CaloTau FEX EMEnNarrow in (dR<0.1) cone;EMEnNarrow [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('HADEnNarrow', type='TH1F', title="L2CaloTau FEX HADEnNarrow in (dR<0.1) cone;HADEnNarrow [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + + self.Histograms += [ defineHistogram('EtRawMedium', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone;EtRawMedium [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumEM0', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 0 of EM;EtRawMediumEM0 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumEM1', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 1 of EM;EtRawMediumEM1 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumEM2', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 2 of EM;EtRawMediumEM2 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumEM3', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 3 of EM;EtRawMediumEM3 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumHad0', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 0 of Had;EtRawMediumHad0 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumHad1', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 1 of Had;EtRawMediumHad1 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + self.Histograms += [ defineHistogram('EtRawMediumHad2', type='TH1F', title="L2CaloTau FEX EtRaw in a medium (dR<0.2) cone - Layer 2 of Had;EtRawMediumHad2 [MeV]; nevents", xbins=171, xmin=-13000, xmax=500000) ] + + self.Histograms += [ defineHistogram('CoreFraction', type='TH1F', title="EtRawNarrow/EtRawMedium; Core Fraction; nevents", xbins=70, xmin=-0.2, xmax=1.2) ] + + self.Histograms += [ defineHistogram('EtaL1, PhiL1', type='TH2F', title="L1 ROI Eta vs Phi in T2CaloTau FEX; #eta; #varphi; nevents", xbins=51, xmin=-2.55, xmax=2.55, + ybins=65, ymin=-3.1415936-0.098174/2., ymax=3.1415936+0.098174/2.)] + + self.Histograms += [ defineHistogram('EtaL1', type='TH1F', title="T2CaloTau L1 Eta; Eta; nevents", xbins=80, xmin=-4, xmax=4) ] + self.Histograms += [ defineHistogram('PhiL1', type='TH1F', title="T2CaloTau L1 Phi; Phi; nevents", xbins=65, xmin=-3.1415936-0.098174/2., xmax=3.1415936+0.098174/2.)] + + self.Histograms += [ defineHistogram('Eta', type='TH1F', title="T2CaloTau FEX Eta; Eta; nevents", xbins=80, xmin=-4, xmax=4) ] + self.Histograms += [ defineHistogram('Phi', type='TH1F', title="T2CaloTau FEX Phi; Phi; nevents", xbins=65, xmin=-3.1415936-0.098174/2., xmax=3.1415936+0.098174/2.)] + + self.Histograms += [ defineHistogram('dEtaL2Tau_RoI, dPhiL2Tau_RoI', type='TH2F', title="dEta vs dPhi in L2CaloTau FEX; Delta-eta; Delta-phi", xbins=40 , xmin=-0.2, xmax=0.2, + ybins=40 , ymin=-0.2, ymax=0.2) ] + + self.Histograms += [ defineHistogram('ConversionErrors',type='TH1F',title='L2CaloTau Conversion Errors; # Errors; # Clusters',xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram('AlgorithmErrors', type='TH1F',title='L2CaloTau Algorithm Errors; # Errors; # Clusters', xbins=10,xmin=0,xmax=10)] + self.Histograms += [ defineHistogram('Quality', type='TH1I',title='L2CaloTau FEX Error bit mask; Error; # Clusters', xbins=16,xmin=0,xmax=16,labels=errorlabels )] + +########## ############################################################## +# add validation specific histograms. +# If you ever remove histograms from Online - move them into Validation +# +######################################################################### +class T2CaloTauValidationMonitoring(T2CaloTauOnlineMonitoring): + def __init__ (self, name="T2CaloTauValidationMonitoring"): + super(T2CaloTauValidationMonitoring, self).__init__(name) + self.defineTarget("Validation") + +########## ############################################################## +# add cosmic specific histograms. +# +######################################################################### +class T2CaloTauCosmicMonitoring(T2CaloTauOnlineMonitoring): + def __init__ (self, name="T2CaloTauCosmicMonitoring"): + super(T2CaloTauCosmicMonitoring, self).__init__(name) + self.defineTarget("Cosmic") + + self.Histograms += [ defineHistogram('EtaL2vsL1', type='TH1F', title="L2CaloTau FEX Eta_L2 - Eta_L1; dEta; nevents", xbins=40, xmin=-0.4, xmax=0.4) ] + self.Histograms += [ defineHistogram('PhiL2vsL1', type='TH1F', title="L2CaloTau FEX Phi_L2 - Phi_L1; dPhi; nevents", xbins=40, xmin=-0.4, xmax=0.4) ] + self.Histograms += [ defineHistogram('EMFraction', type='TH1F', title="L2CaloTau FEX EM Energy Fraction;EMFraction; nevents",xbins=90, xmin=-0.6, xmax=1.2) ] + self.Histograms += [ defineHistogram('EMEnMedium', type='TH1F', title="L2CaloTau FEX EMEnMedium in (dR<0.3) cone;EMEnMedium [MeV]; nevents", xbins=54, xmin=-12000, xmax=150000) ] + self.Histograms += [ defineHistogram('HADEnMedium', type='TH1F', title="L2CaloTau FEX HADEnMedium in (dR<0.3) cone;HADEnMedium [MeV]; nevents", xbins=54, xmin=-12000, xmax=150000) ] + self.Histograms += [ defineHistogram('EMEnNarrow', type='TH1F', title="L2CaloTau FEX EMEnNarrow in (dR<0.1) cone;EMEnNarrow [MeV]; nevents", xbins=54, xmin=-12000, xmax=150000) ] + self.Histograms += [ defineHistogram('HADEnNarrow', type='TH1F', title="L2CaloTau FEX HADEnNarrow in (dR<0.1) cone;HADEnNarrow [MeV]; nevents", xbins=54, xmin=-12000, xmax=150000) ] + +class TrigT2CaloTauTimeMonitoring(TrigGenericMonitoringToolConfig) : + def __init__ (self, name="TrigT2CaloTauTimeMonitoring"): + super(TrigT2CaloTauTimeMonitoring,self).__init__(name) + self.defineTarget("Time") + + types_list=['Total','RegSel','BSCnv','Algor','SaveEM'] + tools_list=['ESamp2','ESamp1','EaEmEn','EHadEn'] + for tool in tools_list: + for type in types_list: + hist_title=tool+type + thismax=1.0 + if ( (type.find("RegSel")>-1) or (type.find("SaveEM")>-1) ): + thismax=0.2 + if ( (type.find("Algor")>-1) ): + thismax=0.5 + self.Histograms+= [defineHistogram (hist_title, + type='TH1F',title=hist_title + ,xbins=40,xmin=0.0,xmax=thismax)] + self.Histograms+= [defineHistogram ('TotalTime', + type='TH1F',title=hist_title + ,xbins=50,xmin=0.0,xmax=5)] + self.Histograms += [ defineHistogram('Eta, TotalTime', + type='TH2F', title="#eta vs. time", xbins=50, xmin=-2.5, + xmax=2.5, ybins=50, ymin=0, ymax=5) ] diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/src/T2CaloTau.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTau/src/T2CaloTau.cxx new file mode 100755 index 00000000000..cc794e7f57c --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/src/T2CaloTau.cxx @@ -0,0 +1,663 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloTau.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTau +// +// AUTHOR: M.P. Casado +// S.R. Armstrong +// updates: 3/3/11 ccuenca, added new vars for monitoring +// +// - Add variables for job option controlled region limits, set defaults +// to most likely values. +// - Add function EtaPhiRange to return the maximum and minimum eta or phi +// values to use when calculating energy sums over a region - R. Soluk +// ******************************************************************** + +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IToolSvc.h" +#include "GaudiKernel/StatusCode.h" +#include "GaudiKernel/ITHistSvc.h" + +#include "TrigT1Interfaces/RecEmTauRoI.h" +#include "TrigT1Interfaces/TrigT1Interfaces_ClassDEF.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" + +#include "CaloEvent/CaloCluster.h" +#include "CaloEvent/CaloClusterContainer.h" +#include "TrigCaloEvent/TrigTauCluster.h" +#include "TrigCaloEvent/TrigTauClusterDetails.h" +#include "TrigCaloEvent/TrigTauClusterDetailsContainer.h" + +#include "TrigT2CaloCommon/T2CaloBase.h" +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "TrigT2CaloCommon/phiutils.h" +#include "TrigT2CaloTau/T2CaloTau.h" + +//#include <TH1F.h> +#include "AthenaKernel/errorcheck.h" + +#define NEG_ENERGY_CLUSTER HLT::Reason::USERDEF_1 +#define NULL_ENERGY_SAMPLING HLT::Reason::USERDEF_2 + +class ISvcLocator; + +T2CaloTau::T2CaloTau(const std::string & name, ISvcLocator* pSvcLocator) : T2CaloBase(name, pSvcLocator), + m_storeCells(false), + m_updateRoiDescriptor(false), + m_phiWidthEM(0.4), + m_etaWidthEM(0.4) +{ + + //properties + declareProperty("TrigTauClusterKey", m_trigTauClusterKey = "T2CaloTrigTauCluster"); + + declareProperty("StoreCells", m_storeCells,"store cells in container attached to RoI"); + declareProperty("updateRoiDescriptor", m_updateRoiDescriptor, "option to update RoiDescriptor after execution"); + declareProperty("PhiWidthEM", m_phiWidthEM, "phi width EM calo"); + declareProperty("EtaWidthEM", m_etaWidthEM, "eta width EM calo"); + + //Monitored variables + declareMonitoredVariable("EMRadius", m_EMRadius); + declareMonitoredVariable("EMRadius3S", m_EMRadius3S); + declareMonitoredVariable("CaloRadius", m_CaloRadius); + declareMonitoredVariable("HadRad", m_HadRad); + + declareMonitoredVariable("IsoFrac", m_IsoFrac); + declareMonitoredVariable("StripWidth", m_StripWidth); + + declareMonitoredVariable("EMFraction", m_EMFraction); + + //Wide, cone 0.3 (Wide in TrigTauClusterDetails) + declareMonitoredVariable("EtRawWide", m_EtRawWide); + + //Medium, cone 0.2 (Medium in TrigTauClusterDetails) + declareMonitoredVariable("EMEnMedium", m_EMEnMedium); + declareMonitoredVariable("HADEnMedium", m_HADEnMedium); + + //Narrow, cone 0.1 (Narrow in TrigTauClusterDetails) + declareMonitoredVariable("EMEnNarrow", m_EMEnNarrow); + declareMonitoredVariable("HADEnNarrow", m_HADEnNarrow); + + declareMonitoredVariable("EtRawMedium", m_EtRawMedium); + declareMonitoredVariable("EtRawMediumEM0", m_EtRawMediumEM0); + declareMonitoredVariable("EtRawMediumEM1", m_EtRawMediumEM1); + declareMonitoredVariable("EtRawMediumEM2", m_EtRawMediumEM2); + declareMonitoredVariable("EtRawMediumEM3", m_EtRawMediumEM3); + declareMonitoredVariable("EtRawMediumHad0", m_EtRawMediumHad0); + declareMonitoredVariable("EtRawMediumHad1", m_EtRawMediumHad1); + declareMonitoredVariable("EtRawMediumHad2", m_EtRawMediumHad2); + + + //EtNarrow/EtWide ratio + declareMonitoredVariable("CoreFraction", m_CoreFraction); + + declareMonitoredVariable("EtaL1", m_EtaL1); + declareMonitoredVariable("PhiL1", m_PhiL1); + declareMonitoredVariable("Eta", m_Eta); + declareMonitoredVariable("Phi", m_Phi); + declareMonitoredVariable("dEtaL2Tau_RoI", m_dEtaL2Tau_RoI); + declareMonitoredVariable("dPhiL2Tau_RoI", m_dPhiL2Tau_RoI); + + declareMonitoredVariable("ConversionErrors", m_conversionError); + declareMonitoredVariable("AlgorithmErrors", m_algorithmError); + + declareMonitoredStdContainer("Quality", m_quality); + + m_Container = 0; + +} + +T2CaloTau::~T2CaloTau() +{ +} + +HLT::ErrorCode T2CaloTau::hltInitialize() +{ + // MsgStream log(msgSvc(), name()); + + // IToolSvc* toolSvc; + // service("ToolSvc",toolSvc); + + ToolHandleArray<IAlgToolCalo>::iterator it = m_emAlgTools.begin(); + for(; it != m_emAlgTools.end(); ++it) + { + StatusCode sc = it->retrieve(); + if(sc.isFailure()) + { + msg() << MSG::ERROR << "Unable to initialize tool " << *it << endmsg; + return HLT::BAD_ALGO_CONFIG ; + } + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "REGTEST: Created " << *it << " AlgTool" << endmsg; + } + (*it)->setCellContainerPointer(&m_Container); + } + + if(msgLvl() <= MSG::DEBUG) + { + if(m_updateRoiDescriptor) + { + msg() << MSG::DEBUG << "REGTEST: TrigRoiDescriptor will be updated " << endmsg; + } + else + { + msg() << MSG::DEBUG << "REGTEST: TrigRoiDescriptor will NOT be updated " << endmsg; + } + } + + if(m_storeCells && msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "REGTEST: will store cells in output " << endmsg; + } + + return HLT::OK; +} + +HLT::ErrorCode T2CaloTau::hltFinalize() +{ + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << " hltFinalize is done" << endmsg; + } + return HLT::OK; +} + +HLT::ErrorCode T2CaloTau::hltExecute(const HLT::TriggerElement* inputTE, HLT::TriggerElement* outputTE) +{ + // Time total T2Calo execution time. + if(timerSvc()) m_timer[0]->start(); + + m_conversionError = 0; + m_algorithmError = 0; + // reset quality vector for monitoring + m_quality.clear(); + + m_EMRadius = -99.0; + m_EMRadius3S = -99.0; + m_CaloRadius = -99.0; + m_HadRad = -99.0; + + m_IsoFrac = -99.0; + m_StripWidth = -99.0; + + m_EMFraction = -99.0; + + m_EtRawWide = -99.0; + + m_EMEnMedium = -99.0; + m_HADEnMedium = -99.0; + + m_EMEnNarrow = -99.0; + m_HADEnNarrow = -99.0; + + m_EtRawMedium = -99.0; + m_EtRawMediumEM0 = -99.0; + m_EtRawMediumEM1 = -99.0; + m_EtRawMediumEM2 = -99.0; + m_EtRawMediumEM3 = -99.0; + m_EtRawMediumHad0 = -99.0; + m_EtRawMediumHad1 = -99.0; + m_EtRawMediumHad2 = -99.0; + + m_CoreFraction = -99.0; + + m_EtaL1 = -99.0; + m_PhiL1 = -99.0; + m_Eta = -99.0; + m_Phi = -99.0; + m_dEtaL2Tau_RoI = -99.0; + m_dPhiL2Tau_RoI = -99.0; + + +#ifndef NDEBUG + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::INFO << "in execute()" << endmsg; + } +#endif + + // Some debug output: +#ifndef NDEBUG + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "output TE ID: " << outputTE->getId() << endmsg; + } +#endif + + // Some debug output: +#ifndef NDEBUG + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "input TE ID: " << inputTE->getId() << endmsg; + } +#endif + const TrigRoiDescriptor* roiDescriptor = 0; + HLT::ErrorCode st = getFeature(inputTE, roiDescriptor); + + if(st == HLT::OK && roiDescriptor) + { +#ifndef NDEBUG // Will not be executed in optimised build + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << " RoI id " << roiDescriptor->roiId() + << " LVL1 id " << roiDescriptor->l1Id() + << *roiDescriptor << endmsg; + // << " located at phi = " << roiDescriptor->phi0() + // << ", eta = " << roiDescriptor->eta0() << endmsg; + } +#endif + } + else + { + msg() << MSG::WARNING << " Failed to find RoiDescriptor " << endmsg; + return HLT::ERROR; + } + + // Some debug output: + + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "Message to count events. LVL1 phi=" + << roiDescriptor->phi() + << " & LVL1 eta=" + << roiDescriptor->eta() << " " << roiDescriptor + << endmsg; + } + + + // End LVL1 part + // double RoIeta = roiDescriptor->eta(); + // double RoIphi = roiDescriptor->phi(); + + const TrigTauClusterDetails * pDetails= new TrigTauClusterDetails(); + + std::string key = ""; + HLT::ErrorCode hltstatusD = recordAndAttachFeature(outputTE, pDetails, key, "TrigT2CaloTauDetails"); + if(hltstatusD != HLT::OK) + { + if (msgLvl() <= MSG::DEBUG) + { + msg() << MSG::ERROR << "Write of TrigTauClusterDetails into outputTE failed" << endmsg; + } + return hltstatusD; + } + + // retrieve TrigTauClusterDetails from the TE + ElementLink< TrigTauClusterDetailsContainer > ELDetails; + HLT::ErrorCode stat = getFeatureLink< TrigTauClusterDetailsContainer, TrigTauClusterDetails >( outputTE, ELDetails ); + + if(stat == HLT::OK && ELDetails.isValid()) + { + if(msgLvl() <= MSG::DEBUG) + { + (*ELDetails)->print(msg()); + } + } + else + { + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "Failed to get TrigTauClusterDetails" << endmsg; + } + return HLT::MISSING_FEATURE; + } + + TrigTauCluster* ptrigTauCluster = new TrigTauCluster(ELDetails.getStorableObjectPointer(), ELDetails.index(), 0.0, -10.0, -10.0, 0); + // Energies, EMRadius and other variables are initialized at the + // TrigTauCluster creation time. + + // Add RoI word to TrigTauCluster + ptrigTauCluster->setRoIword(roiDescriptor->roiWord()); + + // zeros the container per RoI + m_Container = 0; + + HLT::ErrorCode ToolStat = HLT::OK; // define flag to monitor problems with tools without stopping the sequence. + + + /// generate the new roiDescriptor with the correct sizes + + const TrigRoiDescriptor* roitmp = roiDescriptor; + + TrigRoiDescriptor roi( roitmp->eta(), roitmp->eta()-m_etaWidth, roitmp->eta()+m_etaWidth, + roitmp->phi(), HLT::wrap_phi(roitmp->phi()-m_phiWidth), HLT::wrap_phi(roitmp->phi()+m_phiWidth) ); + + /// this isn't needed + // TrigRoiDescriptor* roiEM = new TrigRoiDescriptor( roitmp->eta(), roitmp->eta()-m_etaWidthEM, roitmp->eta()+m_etaWidthE<, + // roitmp->phi(), HLT::wrap_phi(roitmp->phi()-m_phiWidthEM), HLT::wrap_phi(roitmp->phi()+m_phiWidthEM) ); + + msg() << MSG::DEBUG << "Using RoIs " << roi << endmsg; + + ToolHandleArray<IAlgToolCalo>::iterator it = m_emAlgTools.begin(); + if(timerSvc()) m_timer[1]->start(); + uint32_t error = 0; + for(; it < m_emAlgTools.end(); it++) + { + // HLT::ErrorCode stat = (*it)->execute(*ptrigTauCluster, m_phiWidth, m_etaWidth, m_phiWidthEM, m_etaWidthEM, RoIeta, RoIphi); + // HLT::ErrorCode stat = (*it)->execute(*ptrigTauCluster, *roi, *roiEM ); + HLT::ErrorCode stat = (*it)->execute(*ptrigTauCluster, roi, caloDDENull ); + if(stat.reason() == NEG_ENERGY_CLUSTER) + { + msg() << MSG::DEBUG << (*it)->name() << " Found a cluster with E~<=0. CONTINUE execution. " << endmsg; + // do not forget to delete trigTauCluster of attach it to storegate if return + // return stat; // uncomment to avaid running on the remaining tools. + ToolStat = stat; + } + if(stat.reason() == NULL_ENERGY_SAMPLING) + { + msg() << MSG::DEBUG << (*it)->name() << " Found E==0 in this sampling. CONTINUE execution. " << endmsg; + // do not forget to delete trigTauCluster of attach it to storegate if return + // return stat; // uncomment to avaid running on the remaining tools. + ToolStat = stat; + // since userdefined errors are not monitored (reason=continue) + // fill our own variable with T2CaloTau related errors + } + if(stat == HLT::TOOL_FAILURE) + { + msg() << MSG::WARNING << "T2CaloTau AlgTool " << (*it)->name() << " returned Failure" << endmsg; + // if tool has returned this failure, then loadingCollection has failed and it + // does not make sense to keep this TrigTauCluster - we would not learn anything from it + delete ptrigTauCluster; + delete pDetails; + return stat; + } + uint32_t in_error = (*it)->report_error(); + if(0x0FFF00FF & in_error) m_conversionError++; + if(0xF0000000 & in_error) m_algorithmError++; + + error |= in_error; + } + + // convert bits into fixed-size vector variable for error monitoring + TAUCLUSTMON::FillErrorMonitoring(error, &m_quality); + // Fill ALLCLUST bin for all clusters, so we can know the relative importance of each error with this normalization. + m_quality.push_back(TAUCLUSTMON::ALLCLUST); + // Fill GOODCLUST for clusters without errors + if(!error) m_quality.push_back(TAUCLUSTMON::GOODCLUST); + + // OI Now, ensure that phi is [-pi,pi] indepedent on what tools do... + while(ptrigTauCluster->phi() < -M_PI) ptrigTauCluster->setPhi(ptrigTauCluster->phi() + 2.0 * M_PI); + while(ptrigTauCluster->phi() > M_PI) ptrigTauCluster->setPhi(ptrigTauCluster->phi() - 2.0 * M_PI); + + // + // Get L1 RoiDescriptor + const TrigRoiDescriptor* roiL1Descriptor = 0; + HLT::ErrorCode tmpStatus = getFeature( inputTE, roiL1Descriptor, "initialRoI" ); + + if(tmpStatus == HLT::OK && roiDescriptor){ + if(msgLvl() <= MSG::DEBUG) { + msg() << MSG::DEBUG << " RoI id " << roiL1Descriptor->roiId() + << " LVL1 id " << roiL1Descriptor->l1Id() + << *roiL1Descriptor << endmsg; + } + } else { + msg() << MSG::WARNING << " Failed to find RoiDescriptor " << endmsg; + return HLT::ERROR; + } + + + //Fill monitored variables + const TrigTauClusterDetails* clusterDetails = ptrigTauCluster->clusterDetails(); + const double coshEta = cosh(ptrigTauCluster->eta()); + const double inv_coshEta = 1. / coshEta; + + m_EMRadius = clusterDetails->EMRadius(2); + m_EMRadius3S = ptrigTauCluster->EMRadius3S(); + m_CaloRadius = ptrigTauCluster->CaloRadius(); + m_HadRad = ptrigTauCluster->HadRadius(); + m_IsoFrac = ptrigTauCluster->IsoFrac(); + m_StripWidth = ptrigTauCluster->stripWidth(); + m_EMFraction = ptrigTauCluster->EMFrac(); + + //wide: cone 0.3 -> wide at TrigTauClusterDetails + m_EtRawWide = (clusterDetails->EMenergyWide(0) + + clusterDetails->EMenergyWide(1) + + clusterDetails->EMenergyWide(2) + + clusterDetails->EMenergyWide(3) + + clusterDetails->HADenergyWide(0) + + clusterDetails->HADenergyWide(1) + + clusterDetails->HADenergyWide(2)) * inv_coshEta; + + //medium: cone 0.2 -> medium at TrigTauClusterDetails. In previus version of the code, Wide instead of Medium + m_EMEnMedium = clusterDetails->EMenergyMedium(0) + + clusterDetails->EMenergyMedium(1) + + clusterDetails->EMenergyMedium(2) + + clusterDetails->EMenergyMedium(3); + m_HADEnMedium = clusterDetails->HADenergyMedium(0) + + clusterDetails->HADenergyMedium(1) + + clusterDetails->HADenergyMedium(2); + + //narrow: cone 0.1 -> narrow at TrigTauClusterDetails + m_EMEnNarrow = clusterDetails->EMenergyNarrow(0) + + clusterDetails->EMenergyNarrow(1) + + clusterDetails->EMenergyNarrow(2) + + clusterDetails->EMenergyNarrow(3); + m_HADEnNarrow = clusterDetails->HADenergyNarrow(0) + + clusterDetails->HADenergyNarrow(1) + + clusterDetails->HADenergyNarrow(2); + + m_EtRawMediumEM0 = clusterDetails->EMenergyMedium(0) * inv_coshEta; + m_EtRawMediumEM1 = clusterDetails->EMenergyMedium(1) * inv_coshEta; + m_EtRawMediumEM2 = clusterDetails->EMenergyMedium(2) * inv_coshEta; + m_EtRawMediumEM3 = clusterDetails->EMenergyMedium(3) * inv_coshEta; + m_EtRawMediumHad0 = clusterDetails->HADenergyMedium(0) * inv_coshEta; + m_EtRawMediumHad1 = clusterDetails->HADenergyMedium(1) * inv_coshEta; + m_EtRawMediumHad2 = clusterDetails->HADenergyMedium(2) * inv_coshEta; + + m_EtRawMedium = m_EtRawMediumEM0 + m_EtRawMediumEM1 + m_EtRawMediumEM2 + m_EtRawMediumEM3 + m_EtRawMediumHad0 + m_EtRawMediumHad1 + m_EtRawMediumHad2; + + m_CoreFraction = ptrigTauCluster->CoreFrac(); + + m_Eta = ptrigTauCluster->eta(); + m_Phi = ptrigTauCluster->phi(); + if(roiL1Descriptor) + { + m_EtaL1 = roiL1Descriptor->eta(); + m_PhiL1 = roiL1Descriptor->phi(); + } + + m_dEtaL2Tau_RoI = m_Eta - m_EtaL1; + m_dPhiL2Tau_RoI = m_Phi - m_PhiL1; + // m_dEtaL2Tau_RoI = ptrigTauCluster->eta() - roiL1Descriptor->eta0(); + // m_dPhiL2Tau_RoI = ptrigTauCluster->phi() - roiL1Descriptor->phi0(); + + if(m_dPhiL2Tau_RoI > M_PI) m_dPhiL2Tau_RoI -= 2 * M_PI; + if(m_dPhiL2Tau_RoI < -M_PI) m_dPhiL2Tau_RoI += 2 * M_PI; + + + if(m_EtRawWide > 495000.) m_EtRawWide = 499000.; + + if(m_EMEnMedium > 495000.) m_EMEnMedium = 499000.; + if(m_HADEnMedium > 495000.) m_HADEnMedium = 499000.; + + if(m_EMEnNarrow > 495000.) m_EMEnNarrow = 499000.; + if(m_HADEnNarrow > 495000.) m_HADEnNarrow = 499000.; + + if(m_EtRawMedium > 495000.) m_EtRawMedium = 499000.; + if(m_EtRawMediumEM0 > 495000.) m_EtRawMediumEM0 = 499000.; + if(m_EtRawMediumEM1 > 495000.) m_EtRawMediumEM1 = 499000.; + if(m_EtRawMediumEM2 > 495000.) m_EtRawMediumEM2 = 499000.; + if(m_EtRawMediumEM3 > 495000.) m_EtRawMediumEM3 = 499000.; + if(m_EtRawMediumHad0 > 495000.) m_EtRawMediumHad0 = 499000.; + if(m_EtRawMediumHad1 > 495000.) m_EtRawMediumHad1 = 499000.; + if(m_EtRawMediumHad2 > 495000.) m_EtRawMediumHad2 = 499000.; + + // Cluster quality is a collection of possible errors + // No error => quality=0 + ptrigTauCluster->setquality(error); + + if(timerSvc()) m_timer[1]->stop(); + + + if(msgLvl() <= MSG::DEBUG) + { + // Print out Cluster produced + // msg() << MSG::DEBUG << "TEST-TEST-TEST-TEST" << endmsg; + msg() << MSG::DEBUG << " REGTEST: eta/phi = "<< m_Eta << "/" << m_Phi << endmsg; + //msg() << MSG::DEBUG << " REGTEST: etaL1/phiL1 = "<< m_EtaL1 << "/" << m_PhiL1 << endmsg; + msg() << MSG::DEBUG << " REGTEST: EMenergy0Narrow/Medium/Wide = "<< (*ptrigTauCluster).clusterDetails()->EMenergyNarrow(0) + << "/" << (*ptrigTauCluster).clusterDetails()->EMenergyMedium(0) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWide(0) << endmsg; + msg() << MSG::DEBUG << " REGTEST: EMenergy1Narrow/Medium/Wide = " + << (*ptrigTauCluster).clusterDetails()->EMenergyNarrow(1) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyMedium(1) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWide(1) << endmsg; + msg() << MSG::DEBUG << " REGTEST: EMenergy2Narrow/Medium/Wide = " + << (*ptrigTauCluster).clusterDetails()->EMenergyNarrow(2) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyMedium(2) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWide(2) << endmsg; + msg() << MSG::DEBUG << " REGTEST: EMenergy3Narrow/Medium/Wide = " + << (*ptrigTauCluster).clusterDetails()->EMenergyNarrow(3) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyMedium(3) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWide(3) << endmsg; + msg() << MSG::DEBUG << " REGTEST: HADenergy0Narrow/Medium/Wide = " + << (*ptrigTauCluster).clusterDetails()->HADenergyNarrow(0) << "/" + << (*ptrigTauCluster).clusterDetails()->HADenergyMedium(0) << "/" + << (*ptrigTauCluster).clusterDetails()->HADenergyWide(0) << endmsg; + msg() << MSG::DEBUG << " REGTEST: HADenergy1Narrow/Medium/Wide = " + << (*ptrigTauCluster).clusterDetails()->HADenergyNarrow(1) << "/" + << (*ptrigTauCluster).clusterDetails()->HADenergyMedium(1) << "/" + << (*ptrigTauCluster).clusterDetails()->HADenergyWide(1) << endmsg; + msg() << MSG::DEBUG << " REGTEST: HADenergy2Narrow/Medium/Wide = " + << (*ptrigTauCluster).clusterDetails()->HADenergyNarrow(2) << "/" + << (*ptrigTauCluster).clusterDetails()->HADenergyMedium(2) << "/" + << (*ptrigTauCluster).clusterDetails()->HADenergyWide(2) << endmsg; + + msg() << MSG::DEBUG << " REGTEST: EMRadius0/1/2/3 = " + << (*ptrigTauCluster).clusterDetails()->EMRadius(0) << "/" + << (*ptrigTauCluster).clusterDetails()->EMRadius(1) << "/" + << (*ptrigTauCluster).clusterDetails()->EMRadius(2) << "/" + << (*ptrigTauCluster).clusterDetails()->EMRadius(3) << endmsg; + + msg() << MSG::DEBUG << " REGTEST: HADRadius0/1/2 = " + << (*ptrigTauCluster).clusterDetails()->HADRadius(0) << "/" + << (*ptrigTauCluster).clusterDetails()->HADRadius(1) << "/" + << (*ptrigTauCluster).clusterDetails()->HADRadius(2) << endmsg; + + msg() << MSG::DEBUG << " REGTEST: EMenergyWidth0/1/2/3 = " + << (*ptrigTauCluster).clusterDetails()->EMenergyWidth(0) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWidth(1) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWidth(2) << "/" + << (*ptrigTauCluster).clusterDetails()->EMenergyWidth(3) << endmsg; + + msg() << MSG::DEBUG << " REGTEST: EMenergy/Hadenergy = " + << (*ptrigTauCluster).EMenergy() << "/" + << (*ptrigTauCluster).HADenergy() << "/" + << endmsg; + msg() << MSG::DEBUG << " REGTEST: numStripCells/stripWidth/IsoFrac = " + << (*ptrigTauCluster).numStripCells() << "/" + << (*ptrigTauCluster).stripWidth() << "/" + << m_IsoFrac << endmsg; + msg() << MSG::DEBUG << " REGTEST: RoIWord = " + << (*ptrigTauCluster).RoIword() << endmsg; + } + + //// From egamma. This is already done inside the tools for tau! but maybe would like to change at some point... + // if ( error ) { + // // Clustering failed. Transmit ahead L1 + // ptrigTauCluster->setEta(etaL1); + // ptrigTauCluster->setPhi(phiL1); + // ptrigTauCluster->setEnergy(0.0); + // } + + key = ""; + HLT::ErrorCode hltstatus = recordAndAttachFeature(outputTE, ptrigTauCluster, key, "TrigT2CaloTau"); + if(hltstatus != HLT::OK) + { + if (msgLvl() <= MSG::DEBUG) + { + msg() << MSG::ERROR << "Write of TrigTauCluster into outputTE failed" << endmsg; + } + return hltstatus; + } + + if(m_storeCells) + { + if(m_Container != 0) + { + HLT::ErrorCode hltstatus = recordAndAttachFeature(outputTE, m_Container, key, "TrigT2CaloTauCells"); + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << " recorded " << m_Container->size() << " cells "<< endmsg; + } + if(hltstatus != HLT::OK) + { +#ifndef NDEBUG + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::ERROR << "Write of TrigTauClusterCells into outputTE failed" << endmsg; + } +#endif + if(m_timersvc) m_timer[0]->stop(); + return hltstatus; + } + } // End of if to check whether there is a container + } // End of if to check the option is ok + + // Create a new RoiDescriptor with updated eta and phi. + // Note that the steering will propagate l1Id and roiId automatically + // so no need to set them. + + if(m_updateRoiDescriptor) + { + + /// what size should we create this roi with ??? + /// use some new parameters + + double eta = ptrigTauCluster->eta(); + double phi = ptrigTauCluster->phi(); + + TrigRoiDescriptor* newRoiDescriptor = new TrigRoiDescriptor( roiDescriptor->roiWord(), + roiDescriptor->l1Id(), + roiDescriptor->roiId(), + eta, eta-m_etaWidthForID, eta+m_etaWidthForID, + phi, HLT::wrap_phi(phi-m_phiWidthForID), HLT::wrap_phi(phi+m_phiWidthForID) ); + + /// obsolete constructor + // TrigRoiDescriptor* newRoiDescriptor = new TrigRoiDescriptor(roiDescriptor->roiWord(), + // roiDescriptor->l1Id(), + // roiDescriptor->roiId(), + // ptrigTauCluster->eta(), + // ptrigTauCluster->phi()); + + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG << "Recorded an RoiDescriptor " + << " phi " << newRoiDescriptor->phi() + << " eta " << newRoiDescriptor->eta() << " " << *newRoiDescriptor << endmsg; + } + + hltstatus = attachFeature(outputTE, newRoiDescriptor, "TrigT2CaloTau"); + + if(hltstatus != HLT::OK) + { + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::ERROR << "Write of newRoiDescriptor into outputTE failed" << endmsg; + } + return hltstatus; + } + } + // Some debug output: +#ifndef NDEBUG + if(msgLvl() <= MSG::DEBUG) + { + msg() << MSG::DEBUG + << "We assume success, set TE with id " + << outputTE->getId() + << " active to signal positive result." + << endmsg; + } +#endif + + // Time total T2CaloT2Calo execution time. + if(timerSvc()) m_timer[0]->stop(); + + //return HLT::OK; + return ToolStat; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/src/TauAllCaloDRFex.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTau/src/TauAllCaloDRFex.cxx new file mode 100644 index 00000000000..460a3a0bb94 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/src/TauAllCaloDRFex.cxx @@ -0,0 +1,1186 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: TauAllCaloDRFex.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTau +// +// AUTHOR: Olga Igonkina (Nikhef), M. Pilar Casado (IFAE), Mogens Dam (NBI) +// based on TauEmEnFex.cxx +// +// CREATED: Jun-09 +// +// DESCRIPTION: Tool to compute LVL2 Calo tau variables at +// EM sampling 2 +// ******************************************************************** + +#include "CaloIdentifier/LArEM_ID.h" + +#include "CaloEvent/CaloCluster.h" +#include "TrigCaloEvent/TrigTauCluster.h" +#include "TrigCaloEvent/TrigTauClusterDetails.h" +#include "CaloGeoHelpers/CaloSampling.h" + +#include "TrigT2CaloTau/TauAllCaloDRFex.h" +#include "TrigT2CaloCommon/Calo_Def.h" +#include "TrigSteeringEvent/Enums.h" + +#define NEG_ENERGY_CLUSTER HLT::Reason::USERDEF_1 +#define NULL_ENERGY_SAMPLING HLT::Reason::USERDEF_2 + +TauAllCaloDRFex::TauAllCaloDRFex(const std::string& type, const std::string& name, const IInterface* parent) : IAlgToolCalo(type, name, parent) +{ + declareProperty("StripEthr", m_stripEthr); + declareProperty("dRSeed", m_dRSeed, "dR cut for reconstruction of the seed "); + declareProperty("CaloNoiseTool", m_noiseTool, "Tool Handle for noise tool"); + declareProperty("applyNoiseCut", m_applyNoiseCut, "swithch on/off noise suppression"); + declareProperty("noiseNSigmaCut", m_noiseNSigmaCut, "number of sigmas for 2 sided noise substraction"); + declareProperty("hecQualityCut", m_hecQualityCut, "Control for HEC Quality"); + declareProperty("defaultWidth", m_defaultWidth, "default width to be saved"); + declareProperty("dRConeNarrow", m_dRConeNarrow, "dR cut for full region (Narrow) "); + declareProperty("dRConeMedium", m_dRConeMedium, "dR cut for full region (Medium) "); + declareProperty("dRConeWide", m_dRConeWide, "dR cut for full region (Wide) "); + m_saveCells = false; +} + +TauAllCaloDRFex::~TauAllCaloDRFex() +{ +} + +StatusCode TauAllCaloDRFex::initialize() +{ + StatusCode sc = IAlgToolCalo::initialize(); + if( sc.isFailure() ) return sc; + msg() << MSG::INFO << "REGTEST initialized with:" << endmsg; + msg() << MSG::INFO << "REGTEST dRSeed=" << m_dRSeed << endmsg; + msg() << MSG::INFO << "REGTEST StripEthr=" << m_stripEthr << endmsg; + msg() << MSG::INFO << "REGTEST CaloNoiseTool=" << m_noiseTool << endmsg; + msg() << MSG::INFO << "REGTEST applyNoiseCut=" << m_applyNoiseCut << endmsg; + msg() << MSG::INFO << "REGTEST noiseNSigmaCut=" << m_noiseNSigmaCut << endmsg; + msg() << MSG::INFO << "REGTEST hecQualityCut=" << m_hecQualityCut << endmsg; + msg() << MSG::INFO << "REGTEST defaultWidth=" << m_defaultWidth << endmsg; + msg() << MSG::INFO << "REGTEST dRConeNarrow=" << m_dRConeNarrow << endmsg; + msg() << MSG::INFO << "REGTEST dRConeMedium=" << m_dRConeMedium << endmsg; + msg() << MSG::INFO << "REGTEST dRConeWide=" << m_dRConeWide << endmsg; + + if( m_saveCells && msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << "REGTEST: store cells with Et> " << m_cellkeepthr << endmsg; + + if ( !m_timersvc.empty() ) + { + m_timer[0] = m_timersvc->addItem("T2CaloTau.Tools.Total"); + m_timer[1] = m_timersvc->addItem("T2CaloTau.Tools.RegSel"); + m_timer[2] = m_timersvc->addItem("T2CaloTau.Tools.DataPrep"); + m_timer[3] = m_timersvc->addItem("T2CaloTau.Tools.Algorithmic"); + m_timer[4] = m_timersvc->addItem("T2CaloTau.Tools.Saving"); + } + + // noise suppression + if(m_applyNoiseCut!=0) + { + if(m_noiseTool.retrieve().isFailure()) + { + msg() << MSG::FATAL << "Unable to find CaloNoiseTool" << endmsg; + return StatusCode::FAILURE; + } + } + + return sc; +} + + +HLT::ErrorCode TauAllCaloDRFex::execute( TrigTauCluster &rtrigTauCluster, + const IRoiDescriptor& roi, + const CaloDetDescrElement*& /*caloDDE*/) +{ + + // Time total AlgTool time + if (!m_timersvc.empty()) m_timer[0]->start(); + // reset error + m_error = 0x0; + + //these aren't used: + // phiWidthEM = 0.; + // etaWidthEM = 0.; + + //samplings + const unsigned int NSamplings = 7; + int samplings[NSamplings] = {0,1,2,3,0,1,2}; + DETID detectorID[NSamplings] = {TTEM,TTEM,TTEM,TTEM,TTHEC,TTHEC,TTHEC}; + + + // Time to access RegionSelector + if (!m_timersvc.empty()) m_timer[1]->start(); + if (!m_timersvc.empty()) m_timer[1]->pause(); + // Time to access Collection (and ByteStreamCnv ROBs) + if (!m_timersvc.empty()) m_timer[2]->start(); + if (!m_timersvc.empty()) m_timer[2]->pause(); + + + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->start(); + double seedPhi = roi.phi(); + double seedEta = roi.eta(); + + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << " Seed position (L1) eta/phi=" << seedEta << "/" << seedPhi << endmsg; + + + double energyEta = 0.; + double energyPhi = 0.; + + // Variables to take care of phi wrap-around + double energyNegPhi = 0.; + double energyNegPhiConv = 0.; + double energyPosPhi = 0.; + + double EnergyMediumPosPhi = 0; + double EnergyMediumNegPhi = 0; + + // double etamin = std::max(-2.5,RoIeta - etaWidth); + // double etamax = std::min( 2.5,RoIeta + etaWidth); + + // double phimin = RoIphi - phiWidth; + // double phimax = RoIphi + phiWidth; + + // while (phimin < 0) phimin += 2. * M_PI; + // while (phimax > 2*M_PI) phimax -= 2. * M_PI; + + + //------------------ step 1 : clusterization ----------------------------------- + // loop over all samplings + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << " Start clusterization "<< endmsg; + + for(unsigned int is=0; is<NSamplings;++is) + { + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << "LAr sampling "<< samplings[is]<< endmsg; + + if (!m_timersvc.empty()) { m_timer[3]->pause(); m_timer[1]->resume();} + // m_data->RegionSelector(samplings[is], etamin, etamax, phimin, phimax, detectorID[is]); + m_data->RegionSelector(samplings[is], roi, detectorID[is]); + if (!m_timersvc.empty()) {m_timer[1]->pause(); m_timer[2]->resume(); } + if ( m_data->LoadCollections(m_iBegin,m_iEnd).isFailure() ){ + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << " can not LoadCollections " << *m_iBegin << " " << *m_iEnd << endmsg; + return HLT::TOOL_FAILURE; + } + m_error|=m_data->report_error(); + if (!m_timersvc.empty()){ m_timer[2]->pause(); m_timer[3]->resume(); } + + for(m_it = m_iBegin;m_it != m_iEnd; ++m_it) + { + const LArCell* cell = *m_it; + double etaCell = cell->eta(); + double phiCell = cell->phi(); + double dR; + if( ! getdR(seedPhi, seedEta, etaCell, phiCell, m_dRSeed, dR) ) + continue; + + float energyCell = cell->energy(); + if (m_applyNoiseCut) { + double rms = m_noiseTool->getNoise(cell, ICalorimeterNoiseTool::TOTALNOISE); + if ( fabs(energyCell) < m_noiseNSigmaCut * rms) + continue; + } + + if (detectorID[is]==TTHEC) { + if (energyCell < -5e3) continue; + if ((m_hecQualityCut!=0) && (((cell->quality())&0xffff) > m_hecQualityCut) ) continue; + } + energyEta += energyCell * etaCell ; + + if (phiCell > 0.){ + EnergyMediumPosPhi += energyCell; + energyPosPhi += energyCell * phiCell; + } else { + energyNegPhi += energyCell * phiCell; + energyNegPhiConv += energyCell * (phiCell+2.0*M_PI); + EnergyMediumNegPhi += energyCell; + } + + } // end of loop over EM sampling + } // end loop over EM LAr + + // Region Selector, no sample needed + // Get detector offline ID's for Collections + + // m_data->RegionSelector(0,etamin,etamax,phimin,phimax,TILE); + m_data->RegionSelector( 0, roi, TILE ); + if (!m_timersvc.empty()) m_timer[1]->pause(); + + for (unsigned int iR=0;iR< m_data->TileContSize();iR++) + { + if (!m_timersvc.empty()) m_timer[2]->resume(); + // For the first sample you will create the containers + // For the others no + if ( m_data->LoadCollections(m_itBegin,m_itEnd,iR,!iR).isFailure() ){ + return HLT::TOOL_FAILURE; + } + m_error|=m_data->report_error(); + // Finished to access Collection + if (!m_timersvc.empty()) { m_timer[2]->pause(); m_timer[3]->resume(); } + + + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) + { + const CaloCell* cell = (*m_itt); + + double etaCell = cell->eta(); + double phiCell = cell->phi(); + double dR; + if (! getdR(seedPhi, seedEta, etaCell, phiCell, m_dRSeed, dR) ) + continue; + + float energyCell = cell->energy(); + + if (m_applyNoiseCut) { + if (! m_noiseTool->isEOverNSigma( cell, m_noiseNSigmaCut, + ICalorimeterNoiseTool::MAXSYMMETRYHANDLING, + ICalorimeterNoiseTool::TOTALNOISE) ) + continue; + } + + energyEta += energyCell * etaCell ; + + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << "take cell E="<<energyCell << " Eta/Phi="<<etaCell << "/"<<phiCell<< endmsg; + + if (phiCell > 0.){ + EnergyMediumPosPhi += energyCell; + energyPosPhi +=energyCell * phiCell; + } else { + energyNegPhi +=energyCell * phiCell; + energyNegPhiConv += energyCell * ( phiCell+2.0*M_PI); + EnergyMediumNegPhi += energyCell; + } + + } // end of loop over Tile cells + } // end loop over Tile samplings + + + + + + // End options for cluster position + //---------------- step 2 calculation of variables + + HLT::ErrorCode StatError = HLT::OK; // define flag for cluster with negative energy or sampling with 0 energy. + + // Phi wrap-around + if ( (EnergyMediumNegPhi + EnergyMediumPosPhi) > 0. ){ // dont divide by zero + energyEta /= (EnergyMediumNegPhi + EnergyMediumPosPhi) ; + energyPhi = calcEnergyPhi(energyNegPhi, energyPosPhi, EnergyMediumNegPhi, EnergyMediumPosPhi, energyNegPhiConv); + } else { + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG <<"REGTEST problems finding seed: negative energy = "<< EnergyMediumNegPhi + EnergyMediumPosPhi + <<" eta/phi = "<< energyEta<<" / "<<energyPhi <<" . Seed set to L1 direction: eta/phi = " + <<roi.eta()<<" / "<<roi.phi()<< endmsg; + energyEta = roi.eta() ; // if Cluster energy is null or negative, set L1 position + energyPhi = roi.phi() ; + SetClusterError(TAUCLUSTERROR::FAILSEED); + + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NEG_ENERGY_CLUSTER); + } + + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG <<"REGTEST Pre-seed eta/phi " << seedEta<<"/"<<seedPhi << " => Cluster eta/phi = "<< energyEta << "/"<< energyPhi << endmsg; + + while (energyPhi < -M_PI) energyPhi= energyPhi + 2. * M_PI; + while (energyPhi > M_PI) energyPhi= energyPhi - 2. * M_PI; + + float dPhiL1 = fabs(energyPhi - seedPhi); + if( dPhiL1 > M_PI ) dPhiL1 = 2*M_PI - dPhiL1; + + // If seed is too far from pre seed, means that something has happened, probably too small energy deposition + if ( fabs(energyEta - seedEta)> m_dRSeed || fabs(dPhiL1)> m_dRSeed){ + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG <<"REGTEST problems finding seed: eta/phi = "<<energyEta<<" / "<<energyPhi + <<" too far from L1 eta/phi = "<< seedEta<<" / "<<seedPhi + <<" . Energy = "<< EnergyMediumNegPhi + EnergyMediumPosPhi<< endmsg; + energyEta=roi.eta(); + energyPhi=roi.phi(); + // this a similar case as above: energy is too small to calculate a good seed position. they should be monitored together. + SetClusterError(TAUCLUSTERROR::FAILSEED); + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NEG_ENERGY_CLUSTER); + } + + const TrigTauClusterDetails* pDetailsConst = rtrigTauCluster.clusterDetails(); + TrigTauClusterDetails* pDetails = const_cast<TrigTauClusterDetails*> (pDetailsConst); // why do not we have function for that, if needed? + + if (!m_timersvc.empty()) m_timer[3]->pause(); + // Time to store cluster quantities + if (!m_timersvc.empty()) m_timer[4]->start(); + rtrigTauCluster.setEta(energyEta); + rtrigTauCluster.setPhi(energyPhi); + if (!m_timersvc.empty()) m_timer[4]->pause(); + if (!m_timersvc.empty()) m_timer[3]->resume(); + + ClearClusterError(TAUCLUSTERROR::EMS0E0); // this bit might at some point be set by the common data access + ClearClusterError(TAUCLUSTERROR::EMS1E0); // this bit might at some point be set by the common data access + ClearClusterError(TAUCLUSTERROR::EMS2E0); // this bit might at some point be set by the common data access + ClearClusterError(TAUCLUSTERROR::EMS3E0); // this bit might at some point be set by the common data access + + ClearClusterError(TAUCLUSTERROR::HADS1E0); + ClearClusterError(TAUCLUSTERROR::HADS2E0); + ClearClusterError(TAUCLUSTERROR::HADS3E0); + + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << " Start shape calculation "<< endmsg; + + + int numStripCell = 0; + int numTotalCells = 0; + + int nEmCellsNarrow = 0; + int nEmCellsMed = 0; + int nEmCellsWide = 0; + + int nHadCellsNarrow[3] = {0,0,0}; + int nHadCellsMed[3] = {0,0,0}; + int nHadCellsWide [3] = {0,0,0}; + + + double emRadiusNarrow = 0; + double emRadiusMed = 0; + double emRadiusWide = 0; + + double hadRadiusNarrow[3] = {0.0,0.0,0.0}; + double hadRadiusMed[3] = {0.0,0.0,0.0}; + double hadRadiusWide[3] = {0.0,0.0,0.0}; + + + double emEnergyNarrow = 0; + double emEnergyMed = 0; + double emEnergyWide = 0; + + double hadEnergyNarrow[3] = {0.0,0.0,0.0}; + double hadEnergyMed[3] = {0.0,0.0,0.0}; + double hadEnergyWide[3] = {0.0,0.0,0.0}; + + + double emWeightEtaNarrow = 0.0; + double emWeightEtaMed = 0.0; + double emWeightEtaWide = 0.0; + + double hadWeightEtaNarrow[3] = {0.0,0.0,0.0}; + double hadWeightEtaMed[3] = {0.0,0.0,0.0}; + double hadWeightEtaWide[3] = {0.0,0.0,0.0}; + + + double emWeightEta2Narrow = 0.0; + double emWeightEta2Med = 0.0; + double emWeightEta2Wide = 0.0; + + double hadWeightEta2Narrow[3] = {0.0,0.0,0.0}; + double hadWeightEta2Med[3] = {0.0,0.0,0.0}; + double hadWeightEta2Wide[3] = {0.0,0.0,0.0}; + + + + + + + + //loop over LAr samplings + for(unsigned int is=0; is<NSamplings;++is){ + + emRadiusNarrow = 0.; + emRadiusMed = 0.; + emRadiusWide = 0.; + + nEmCellsNarrow = 0; + nEmCellsMed = 0; + nEmCellsWide = 0; + + emRadiusNarrow = 0.; + emRadiusMed = 0.; + emRadiusWide = 0.; + + emEnergyNarrow = 0.; + emEnergyMed = 0.; + emEnergyWide = 0.; + + emWeightEtaNarrow = 0.; + emWeightEtaMed = 0.; + emWeightEtaWide = 0.; + + emWeightEta2Narrow = 0.; + emWeightEta2Med = 0.; + emWeightEta2Wide = 0.; + + + //get data + if (!m_timersvc.empty()){ m_timer[3]->pause(); m_timer[1]->resume(); } + + // m_data->RegionSelector(samplings[is],etamin,etamax,phimin,phimax,detectorID[is]); + m_data->RegionSelector( samplings[is], roi, detectorID[is] ); + + if (!m_timersvc.empty()) { m_timer[1]->pause(); m_timer[2]->resume(); } + + if ( m_data->LoadCollections(m_iBegin,m_iEnd).isFailure() ){ + if (msg().level()<=MSG::DEBUG) + msg() << MSG::DEBUG << " can not LoadCollections " << *m_iBegin << " " << *m_iEnd << endmsg; + return HLT::TOOL_FAILURE; + } + m_error|=m_data->report_error(); + if (!m_timersvc.empty()){ m_timer[2]->pause(); m_timer[3]->resume(); } + + if ( m_saveCells ){ + m_data->storeCells(m_iBegin,m_iEnd,*m_CaloCellContPoint,m_cellkeepthr,100000); + } + + + //loop over cells per sampling + for(m_it = m_iBegin;m_it != m_iEnd; ++m_it) { + const LArCell* cell = *m_it; + double etaCell = cell->eta(); + double phiCell = cell->phi(); + double dR = 0.0; + //effectively applying the dR<m_dRConeWide cut + if ( !getdR(energyPhi, energyEta, etaCell, phiCell,m_dRConeWide , dR) ) continue; + + float energyCell = cell->energy(); + + + // Count cells + if ( is < 4 ) { + nEmCellsWide += 1; + if( dR < m_dRConeMedium ) { + nEmCellsMed += 1; + if( dR < m_dRConeNarrow ) + nEmCellsNarrow += 1; + } + } else { + nHadCellsWide[samplings[is]] += 1; + if( dR < m_dRConeMedium ) { + nHadCellsMed[samplings[is]] += 1; + if( dR < m_dRConeNarrow ) + nHadCellsNarrow[samplings[is]] += 1; + } + } + + //count n cells + numTotalCells = rtrigTauCluster.numTotCells(); + numTotalCells = numTotalCells + 1; + rtrigTauCluster.setNumTotCells(numTotalCells); + + //Noise subtraction + if (m_applyNoiseCut) { + double rms = m_noiseTool->getNoise(cell, ICalorimeterNoiseTool::TOTALNOISE); + if ( fabs(energyCell) < m_noiseNSigmaCut * rms) + continue; + } + + if (detectorID[is]==TTHEC) { + if (energyCell < -5e3) continue; + if ((m_hecQualityCut!=0) && (((cell->quality())&0xffff) > m_hecQualityCut) ) continue; + } + + if ( is < 4 ) { + emRadiusWide += energyCell * dR; + emEnergyWide += energyCell; + emWeightEta2Wide += energyCell * etaCell * etaCell; + emWeightEtaWide += energyCell * etaCell; + + } else { + hadRadiusWide[samplings[is]] += energyCell * dR; + hadEnergyWide[samplings[is]] += energyCell; + hadWeightEta2Wide[samplings[is]] += energyCell * etaCell * etaCell; + hadWeightEtaWide[samplings[is]] += energyCell * etaCell; + } + + if ( (is==1) && (energyCell > m_stripEthr ) ) numStripCell += 1; + + + if( dR < m_dRConeMedium ) { + if( is < 4 ) { + emRadiusMed += energyCell * dR; + emEnergyMed += energyCell; + emWeightEta2Med += energyCell * etaCell * etaCell; + emWeightEtaMed += energyCell * etaCell; + } else { + hadRadiusMed[samplings[is]] += energyCell * dR; + hadEnergyMed[samplings[is]] += energyCell; + hadWeightEta2Med[samplings[is]] += energyCell * etaCell * etaCell; + hadWeightEtaMed[samplings[is]] += energyCell * etaCell; + } + + if( dR < m_dRConeNarrow ) { + if( is < 4 ) { + emRadiusNarrow += energyCell * dR; + emEnergyNarrow += energyCell; + emWeightEta2Narrow += energyCell * etaCell * etaCell; + emWeightEtaNarrow += energyCell * etaCell; + } else { + hadRadiusNarrow[samplings[is]] += energyCell * dR; + hadEnergyNarrow[samplings[is]] += energyCell; + hadWeightEta2Narrow[samplings[is]] += energyCell * etaCell * etaCell; + hadWeightEtaNarrow[samplings[is]] += energyCell * etaCell; + } + } + } + } // end of loop over cells + + + //Set clusterWidth and emRadius for EM Samplings + if ( is < 4 ) { + + double clusterWidthWide; + double clusterWidthMed; + double clusterWidthNarrow; + + //Wide + if ( (emEnergyWide > 0.) && (nEmCellsWide > 0) ) { + clusterWidthWide = + (emWeightEta2Wide/emEnergyWide) - + (emWeightEtaWide/emEnergyWide)* + (emWeightEtaWide/emEnergyWide); + + clusterWidthWide > 0.? clusterWidthWide = + sqrt(clusterWidthWide) : -99.; + + emRadiusWide = emRadiusWide / emEnergyWide ; + } else { + if(nEmCellsWide == 0) { + clusterWidthWide = 0.; + emRadiusWide = 0. ; + + /// What is this code for?? why is it hardcoded with values like eta=1.8 ??? + + // if E==0 in a dR<0.3 region, probably means problems with unpacking. + if ((is < 4) && + (samplings[is]==0) && + ((fabs(energyEta) - m_dRConeWide) < (1.8 - (0.025/2) - 0.05) ) && + ((fabs(roi.etaMinus())<(1.8-1e-7)) || (fabs(roi.etaPlus())<(1.8-1e-7)) ) + ) { + SetClusterError(TAUCLUSTERROR::EMS0E0); + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NULL_ENERGY_SAMPLING); + } + if ((is < 4) && (samplings[is]==1)) { + SetClusterError(TAUCLUSTERROR::EMS1E0); + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NULL_ENERGY_SAMPLING); + } + if ((is < 4) && (samplings[is]==2)) { + SetClusterError(TAUCLUSTERROR::EMS2E0); + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NULL_ENERGY_SAMPLING); + } + if ((is < 4) && (samplings[is]==3)) { + SetClusterError(TAUCLUSTERROR::EMS3E0); + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NULL_ENERGY_SAMPLING); + } + } + else { + clusterWidthWide = -99.; + emRadiusWide = -99.; + } + } + + //Medium + if ( (emEnergyMed > 0.) && (nEmCellsMed > 0) ) { + clusterWidthMed = + (emWeightEta2Med/emEnergyMed) - + (emWeightEtaMed/emEnergyMed)* + (emWeightEtaMed/emEnergyMed); + + clusterWidthMed > 0.? clusterWidthMed = + sqrt(clusterWidthMed) : -99.; + + emRadiusMed = emRadiusMed / emEnergyMed ; + } else { + if( nEmCellsMed == 0 ) { + clusterWidthMed = 0.; + emRadiusMed = 0. ; + } else { + clusterWidthMed = -99.; + emRadiusMed = -99.; + } + } + + + //Narrow + if ( (emEnergyNarrow > 0.) && (nEmCellsNarrow > 0) ) { + clusterWidthNarrow = + (emWeightEta2Narrow/emEnergyNarrow) - + (emWeightEtaNarrow /emEnergyNarrow)* + (emWeightEtaNarrow /emEnergyNarrow); + + clusterWidthNarrow > 0.? clusterWidthNarrow = + sqrt(clusterWidthNarrow) : -99.; + + emRadiusNarrow = emRadiusNarrow / emEnergyNarrow ; + } else { + if( nEmCellsNarrow == 0 ) { + clusterWidthNarrow = 0.; + emRadiusNarrow = 0. ; + } else { + clusterWidthNarrow = -99.; + emRadiusNarrow = -99.; + } + } + + if (!m_timersvc.empty()){ m_timer[3]->pause(); m_timer[4]->resume(); } + + float emRad = -1.0; + float clusWidth = -1.0; + switch (m_defaultWidth) { + case 0: + emRad = emRadiusNarrow; + clusWidth = clusterWidthNarrow; + break; + case 1: + emRad = emRadiusMed; + clusWidth = clusterWidthMed; + break; + case 2: + emRad = emRadiusWide; + clusWidth = clusterWidthWide; + break; + } + + pDetails->setEMRadius (samplings[is],emRad); + pDetails->setEMenergyWidth (samplings[is],clusWidth); + + pDetails->setEMenergyNarrow(samplings[is],emEnergyNarrow); + pDetails->setEMenergyMedium(samplings[is],emEnergyMed); + pDetails->setEMenergyWide (samplings[is],emEnergyWide); + + //if samplings==2 in the first 4 samples + if (samplings[is]==2) { + if(emEnergyMed != 0) rtrigTauCluster.setIsoFrac( (emEnergyMed - emEnergyNarrow) / emEnergyMed ); + else rtrigTauCluster.setIsoFrac(-99. ); + } + } + if (!m_timersvc.empty()){ m_timer[4]->pause(); m_timer[3]->resume(); } + } + + if (!m_timersvc.empty()) m_timer[3]->pause(); + + if (!m_timersvc.empty()) m_timer[4]->resume(); + rtrigTauCluster.setNumStripCells (numStripCell); + rtrigTauCluster.setStripWidthOffline(rtrigTauCluster.EMenergyWidth(1)); + rtrigTauCluster.setStripWidth (rtrigTauCluster.EMenergyWidth(2)); + rtrigTauCluster.setEMRadius2 (rtrigTauCluster.EMRadius(2)); + rtrigTauCluster.setEMenergy (getEMEnergy(pDetails, m_defaultWidth) ); + + if (!m_timersvc.empty()){ m_timer[4]->pause(); m_timer[3]->resume(); } + if (!m_timersvc.empty()) { m_timer[3]->pause(); m_timer[1]->resume();} + + // m_data->RegionSelector(0,etamin,etamax,phimin,phimax,TILE); + m_data->RegionSelector( 0, roi, TILE ); + if (!m_timersvc.empty()) m_timer[1]->pause(); + + + + // Tile energy + for (unsigned int iR=0; iR<m_data->TileContSize(); iR++) { + + if (!m_timersvc.empty()) m_timer[2]->resume(); + if ( m_data->LoadCollections(m_itBegin,m_itEnd,iR,!iR).isFailure() ){ + return HLT::TOOL_FAILURE; + } + m_error|=m_data->report_error(); + if ( m_saveCells ){ + m_data->storeCells(m_itBegin,m_itEnd,*m_CaloCellContPoint,m_cellkeepthr,100000); + } + if (!m_timersvc.empty()) { m_timer[2]->pause(); m_timer[3]->resume();} + + //loop over tile cells + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) { + const CaloCell* cell = (*m_itt); + double etaCell = cell->eta(); + double phiCell = cell->phi(); + double dR = 0.0; + if (!getdR(energyPhi, energyEta, etaCell, phiCell, m_dRConeWide, dR) ) + continue; + + float energyCell = cell->energy(); + + + //samp = CaloSampling::getSampling(*cell); + //CaloSampling::CaloSample samp = CaloSampling::getSampling(*(*m_itt)); + CaloSampling::CaloSample samp = (*m_itt)->caloDDE()->getSampling(); + + int idxsamp = -99; + if (CaloSampling::TileBar0 == samp || + CaloSampling::TileExt0 == samp) { + idxsamp = 0; + } else if (CaloSampling::TileBar1 == samp || + CaloSampling::TileExt1 == samp) { + idxsamp = 1; + } else if (CaloSampling::TileBar2 == samp || + CaloSampling::TileExt2 == samp) { + idxsamp = 2; + }else continue; + + // Count this cell + numTotalCells=rtrigTauCluster.numTotCells(); + rtrigTauCluster.setNumTotCells(numTotalCells++); + + // Count cells + nHadCellsWide[idxsamp] += 1; + if( dR < m_dRConeMedium ) { + nHadCellsMed[idxsamp] += 1; + if( dR < m_dRConeNarrow ) + nHadCellsNarrow[idxsamp] += 1; + } + + if (m_applyNoiseCut) { + if (! m_noiseTool->isEOverNSigma( cell, m_noiseNSigmaCut, + ICalorimeterNoiseTool::MAXSYMMETRYHANDLING, + ICalorimeterNoiseTool::TOTALNOISE) ) + continue; + } + + hadRadiusWide[idxsamp] += energyCell * dR; + hadEnergyWide[idxsamp] += energyCell; + hadWeightEta2Wide[idxsamp] += energyCell * etaCell * etaCell; + hadWeightEtaWide[idxsamp] += energyCell * etaCell; + + if( dR < m_dRConeMedium ) { + hadRadiusMed[idxsamp] += energyCell * dR; + hadEnergyMed[idxsamp] += energyCell; + hadWeightEta2Med[idxsamp] += energyCell * etaCell * etaCell; + hadWeightEtaMed[idxsamp] += energyCell * etaCell; + + if( dR < m_dRConeNarrow ) { + hadRadiusNarrow[idxsamp] += energyCell * dR; + hadEnergyNarrow[idxsamp] += energyCell; + hadWeightEta2Narrow[idxsamp] += energyCell * etaCell * etaCell; + hadWeightEtaNarrow[idxsamp] += energyCell * etaCell; + } + } + } // end loop over cells + } // end loop over collections + + + //Fix had variables + for(int sampling=0; sampling<3;++sampling){ + // calculate cluster width in a region (Eta/Phi)StripsEM2Nor from jobO + // ??? ClearClusterError(TAUCLUSTERROR::EMS2E0); // this bit might at some point be set by the common data access + + double clusterWidthWide; + double clusterWidthMed; + double clusterWidthNarrow; + + //HadWide + if ( hadEnergyWide[sampling] > 0. && nHadCellsWide[sampling] > 0 ) { + clusterWidthWide = + (hadWeightEta2Wide[sampling]/hadEnergyWide[sampling]) - + (hadWeightEtaWide[sampling]/hadEnergyWide[sampling])* + (hadWeightEtaWide[sampling]/hadEnergyWide[sampling]); + + clusterWidthWide > 0.? clusterWidthWide = + sqrt(clusterWidthWide) : -99.; + + hadRadiusWide[sampling] = hadRadiusWide[sampling] / hadEnergyWide[sampling] ; + } else { + if(nHadCellsWide[sampling] == 0) { + clusterWidthWide = 0.; + hadRadiusWide[sampling] = 0. ; + + // if E==0 in a dR<0.3 region, probably means problems with unpacking. + if ( sampling==0) SetClusterError(TAUCLUSTERROR::HADS1E0); + if ( sampling==1) SetClusterError(TAUCLUSTERROR::HADS2E0); + if ( sampling==2) SetClusterError(TAUCLUSTERROR::HADS3E0); + StatError = HLT::ErrorCode(HLT::Action::CONTINUE, NULL_ENERGY_SAMPLING); + } else { + clusterWidthWide = -99.; + hadRadiusWide[sampling] = -99.; + } + } + + //HadMed + if ( hadEnergyMed[sampling] > 0. && nHadCellsMed[sampling] > 0 ) { + clusterWidthMed = + (hadWeightEta2Med[sampling]/hadEnergyMed[sampling]) - + (hadWeightEtaMed[sampling]/hadEnergyMed[sampling])* + (hadWeightEtaMed[sampling]/hadEnergyMed[sampling]); + + clusterWidthMed > 0.? clusterWidthMed = + sqrt(clusterWidthMed) : -99.; + + hadRadiusMed[sampling] = hadRadiusMed[sampling] / hadEnergyMed[sampling] ; + } else { + if(nHadCellsMed[sampling] == 0) { + clusterWidthMed = 0.; + hadRadiusMed[sampling] = 0. ; + } else { + clusterWidthMed = -99.; + hadRadiusMed[sampling] = -99.; + } + } + + + //HadNarrow + if ( hadEnergyNarrow[sampling] > 0. && nHadCellsNarrow[sampling] > 0 ) { + clusterWidthNarrow = + (hadWeightEta2Narrow[sampling]/hadEnergyNarrow[sampling]) - + (hadWeightEtaNarrow[sampling]/hadEnergyNarrow[sampling])* + (hadWeightEtaNarrow[sampling]/hadEnergyNarrow[sampling]); + + clusterWidthNarrow > 0.? clusterWidthNarrow = + sqrt(clusterWidthNarrow) : -99.; + + hadRadiusNarrow[sampling] = hadRadiusNarrow[sampling] / hadEnergyNarrow[sampling] ; + } else { + if(nHadCellsNarrow[sampling] == 0) { + clusterWidthNarrow = 0.; + hadRadiusNarrow[sampling] = 0. ; + } else { + clusterWidthNarrow = -99.; + hadRadiusNarrow[sampling] = -99.; + } + } + + if (!m_timersvc.empty()) {m_timer[3]->pause(); m_timer[4]->resume(); } + + //set values + float hadRad = -1.0; + float clusWidth = -1.0; + switch (m_defaultWidth) { + case 0: + hadRad = hadRadiusNarrow[sampling]; + clusWidth = clusterWidthNarrow; + break; + case 1: + hadRad = hadRadiusMed[sampling]; + clusWidth = clusterWidthMed; + break; + case 2: + hadRad = hadRadiusWide[sampling]; + clusWidth = clusterWidthWide; + break; + } + + pDetails->setHADRadius (sampling,hadRad); + pDetails->setHADenergyWidth (sampling,clusWidth); + + pDetails->setHADenergyNarrow(sampling,hadEnergyNarrow[sampling]); + pDetails->setHADenergyMedium(sampling,hadEnergyMed[sampling]); + pDetails->setHADenergyWide (sampling,hadEnergyWide[sampling]); + + if (!m_timersvc.empty()){ m_timer[4]->pause(); m_timer[3]->resume(); } + } + + if (!m_timersvc.empty()){ m_timer[3]->pause(); m_timer[4]->resume();} + + + //set Raw and Had energy + rtrigTauCluster.setHADenergy( getHADEnergy(pDetails, m_defaultWidth) ); + rtrigTauCluster.setRawEnergy( rtrigTauCluster.rawEnergy() + rtrigTauCluster.EMenergy() + rtrigTauCluster.HADenergy() ); + + if ( msg().level() <= MSG::DEBUG) + msg()<<MSG::DEBUG + << "REGTEST Record energy RawE" << rtrigTauCluster.rawEnergy() + << "Had " << rtrigTauCluster.HADenergy() << endmsg; + + if (!m_timersvc.empty()){ m_timer[4]->pause(); m_timer[3]->resume();} + + + //set Radius + float caloRad = caloRadius(pDetails); + float emRadius3S = emRadiusAllSampl(pDetails, 3); + float coreFrac = coreFraction(pDetails); + float emFrac = emFraction(&rtrigTauCluster); + float hadRad = hadRadius(pDetails); + + if (!m_timersvc.empty()){ m_timer[3]->pause(); m_timer[4]->resume();} + + rtrigTauCluster.setCaloRadius(caloRad); + rtrigTauCluster.setEMRadius3S(emRadius3S); + rtrigTauCluster.setCoreFrac(coreFrac); + rtrigTauCluster.setEMFrac(emFrac); + rtrigTauCluster.setHadRadius(hadRad); + + if (!m_timersvc.empty()) { + m_timer[1]->stop(); + m_timer[2]->stop(); + m_timer[3]->stop(); + m_timer[4]->stop(); + m_timer[0]->stop(); + } + + // return HLT::OK; + return StatError; + +} + +double TauAllCaloDRFex::emRadiusAllSampl(const TrigTauClusterDetails* clusterDetails, int maxEmSamp) +{ + double emRadAll = 0.0; + double totEn = 0.0; + + double emEnergy[4] = {0.0, 0.0, 0.0, 0.0}; + + for (int iS=0; iS<4 && iS < maxEmSamp; iS++) { + switch (m_defaultWidth) { + case 0: + emEnergy[iS] = clusterDetails->EMenergyNarrow(iS); + break; + case 1: + emEnergy[iS] = clusterDetails->EMenergyMedium(iS); + break; + case 2: + emEnergy[iS] = clusterDetails->EMenergyWide(iS); + break; + } + } + + for(int emSamp = 0; emSamp <= 3 && emSamp < maxEmSamp; emSamp++) { + if( emEnergy[emSamp] > 0.0 && fabs(clusterDetails->EMRadius(emSamp)) < 90.0) { + emRadAll += emEnergy[emSamp] * clusterDetails->EMRadius(emSamp); + totEn += emEnergy[emSamp]; + } + } + + if (totEn > 0.0) { + return emRadAll / totEn; + } + return -99.0; +} + +double TauAllCaloDRFex::caloRadius(const TrigTauClusterDetails* clusterDetails) +{ + double caloRad = 0.0; + double totEn = 0.0; + + double emEnergy[4] = {0.0, 0.0, 0.0, 0.0}; + double hadEnergy[3] = {0.0, 0.0, 0.0}; + + for (int iS=0; iS<4; iS++) { + switch (m_defaultWidth) { + case 0: + emEnergy[iS] = clusterDetails->EMenergyNarrow(iS); + if (iS<3) + hadEnergy[iS] = clusterDetails->HADenergyNarrow(iS); + break; + case 1: + emEnergy[iS] = clusterDetails->EMenergyMedium(iS); + if (iS<3) + hadEnergy[iS] = clusterDetails->HADenergyMedium(iS); + break; + case 2: + emEnergy[iS] = clusterDetails->EMenergyWide(iS); + if (iS<3) + hadEnergy[iS] = clusterDetails->HADenergyWide(iS); + break; + } + } + + + for(int emSamp = 0; emSamp <= 3; emSamp++) { + if( emEnergy[emSamp] > 0.0 && fabs(clusterDetails->EMRadius(emSamp)) < 90.0) { + caloRad += emEnergy[emSamp] * clusterDetails->EMRadius(emSamp); + totEn += emEnergy[emSamp]; + } + } + for(int hadSamp = 0; hadSamp <= 2; hadSamp++) { + if( hadEnergy[hadSamp] > 0.0 && fabs(clusterDetails->HADRadius(hadSamp)) < 90.0) { + caloRad += hadEnergy[hadSamp] * clusterDetails->HADRadius(hadSamp); + totEn += hadEnergy[hadSamp]; + } + } + if(totEn > 0.0) { + return caloRad / totEn; + } + return -99.0; +} + +double TauAllCaloDRFex::hadRadius(const TrigTauClusterDetails* clusterDetails) +{ + double hadRad = 0.0; + double totEn = 0.0; + + double hadEnergy[3] = {0.0, 0.0, 0.0}; + + for (int iS=0; iS<3; iS++) { + switch (m_defaultWidth) { + case 0: + hadEnergy[iS] = clusterDetails->HADenergyNarrow(iS); + break; + case 1: + hadEnergy[iS] = clusterDetails->HADenergyMedium(iS); + break; + case 2: + hadEnergy[iS] = clusterDetails->HADenergyWide(iS); + break; + } + } + + + for(int hadSamp = 0; hadSamp <= 2; hadSamp++) { + if(hadEnergy[hadSamp] > 0.0 && fabs(clusterDetails->HADRadius(hadSamp)) < 90.0) { + hadRad += hadEnergy[hadSamp] * clusterDetails->HADRadius(hadSamp); + totEn += hadEnergy[hadSamp]; + } + } + + if(totEn > 0.0) { + return hadRad / totEn; + } + return -99.0; +} + + + +double TauAllCaloDRFex::coreFraction(const TrigTauClusterDetails* clusterDetails) +{ + double ERawNarrow = (clusterDetails->EMenergyNarrow(0) + + clusterDetails->EMenergyNarrow(1) + + clusterDetails->EMenergyNarrow(2) + + clusterDetails->EMenergyNarrow(3) + + clusterDetails->HADenergyNarrow(0) + + clusterDetails->HADenergyNarrow(1) + + clusterDetails->HADenergyNarrow(2)); + + double ERawMedium = (clusterDetails->EMenergyMedium(0) + + clusterDetails->EMenergyMedium(1) + + clusterDetails->EMenergyMedium(2) + + clusterDetails->EMenergyMedium(3) + + clusterDetails->HADenergyMedium(0) + + clusterDetails->HADenergyMedium(1) + + clusterDetails->HADenergyMedium(2)); + + if(ERawMedium > 0.0) { + return ERawNarrow / ERawMedium; + } + return -99.0; +} + +double TauAllCaloDRFex::emFraction(const TrigTauCluster* ptrigTauCluster) +{ + float totEn = ptrigTauCluster->EMenergy() + ptrigTauCluster->HADenergy(); + if(totEn != 0.0) { + return ptrigTauCluster->EMenergy() / totEn; + } + + return -99.0; +} + +double TauAllCaloDRFex::calcEnergyPhi(double energyNegPhi, double energyPosPhi, double EnergyMediumNegPhi, double EnergyMediumPosPhi, double energyNegPhiConv) +{ + double AvgNegPhi = 0.; + double AvgPosPhi = 0.; + double energyPhi = 0.; + + if (EnergyMediumNegPhi > 0. ){ + AvgNegPhi = energyNegPhi / EnergyMediumNegPhi; + } else { + AvgNegPhi = -999.0; + } + + if (EnergyMediumPosPhi > 0. ){ + AvgPosPhi = energyPosPhi / EnergyMediumPosPhi; + } else { + AvgPosPhi = -999.0; + } + + if (AvgPosPhi==-999.0) { + if (AvgNegPhi != -999.0) { + energyPhi = AvgNegPhi; + } + } + + if (AvgNegPhi==-999.0) { + if (AvgPosPhi != -999.0) { + energyPhi = AvgPosPhi; + } + } + + if (AvgNegPhi != -999.0 && AvgPosPhi != -999.0) { + if ( (AvgNegPhi > (-M_PI/2.0)) && (AvgPosPhi < (M_PI/2.0)) ) { + energyPhi = (energyNegPhi + energyPosPhi)/ + (EnergyMediumNegPhi + EnergyMediumPosPhi); + } else { + if ((AvgNegPhi < (-M_PI/2.0)) && (AvgPosPhi > (M_PI/2.0))) { + energyPhi = (energyNegPhiConv + energyPosPhi)/ + (EnergyMediumNegPhi + EnergyMediumPosPhi); + if (energyPhi > M_PI) { + energyPhi = energyPhi - 2*M_PI; + } + } + } + } + return energyPhi; +} + +bool TauAllCaloDRFex::getdR(double compPhi, double compEta, double etaCell, double phiCell, double dRCut, double& dR) +{ + + float dEta = fabs(etaCell - compEta); + if( dEta > dRCut ) return false; + float dPhi = fabs(phiCell - compPhi); + if( dPhi > M_PI ) dPhi = 2*M_PI - dPhi; + if( dPhi > dRCut ) return false; + dR = std::sqrt(dEta*dEta + dPhi*dPhi); + if( dR > dRCut ) return false; + return true; + +} + +double TauAllCaloDRFex::getEMEnergy(const TrigTauClusterDetails* clusterDetails, int widthChoice) +{ + double EMEnergy; + switch (widthChoice) + { + case 0: + EMEnergy = (clusterDetails->EMenergyNarrow(0)+ + clusterDetails->EMenergyNarrow(1)+ + clusterDetails->EMenergyNarrow(2)+ + clusterDetails->EMenergyNarrow(3)); + break; + case 1: + EMEnergy = (clusterDetails->EMenergyMedium(0)+ + clusterDetails->EMenergyMedium(1)+ + clusterDetails->EMenergyMedium(2)+ + clusterDetails->EMenergyMedium(3)); + break; + case 2: + EMEnergy = (clusterDetails->EMenergyWide(0)+ + clusterDetails->EMenergyWide(1)+ + clusterDetails->EMenergyWide(2)+ + clusterDetails->EMenergyWide(3)); + break; + default: + EMEnergy = (clusterDetails->EMenergyNarrow(0)+ + clusterDetails->EMenergyNarrow(1)+ + clusterDetails->EMenergyNarrow(2)+ + clusterDetails->EMenergyNarrow(3)); + + } + return EMEnergy; +} + +double TauAllCaloDRFex::getHADEnergy(const TrigTauClusterDetails* clusterDetails, int widthChoice) +{ + double HADEnergy; + switch (widthChoice) + { + case 0: + HADEnergy = (clusterDetails->HADenergyNarrow(0)+ + clusterDetails->HADenergyNarrow(1)+ + clusterDetails->HADenergyNarrow(2)); + break; + case 1: + HADEnergy = (clusterDetails->HADenergyMedium(0)+ + clusterDetails->HADenergyMedium(1)+ + clusterDetails->HADenergyMedium(2)); + break; + case 2: + HADEnergy = (clusterDetails->HADenergyWide(0)+ + clusterDetails->HADenergyWide(1)+ + clusterDetails->HADenergyWide(2)); + break; + default: + HADEnergy = (clusterDetails->HADenergyNarrow(0)+ + clusterDetails->HADenergyNarrow(1)+ + clusterDetails->HADenergyNarrow(2)); + + } + + return HADEnergy; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTau/src/components/TrigT2CaloTau_entries.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTau/src/components/TrigT2CaloTau_entries.cxx new file mode 100644 index 00000000000..4f403a0aa6a --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTau/src/components/TrigT2CaloTau_entries.cxx @@ -0,0 +1,7 @@ +#include "TrigT2CaloTau/T2CaloTau.h" +#include "TrigT2CaloTau/TauAllCaloDRFex.h" + +DECLARE_COMPONENT( T2CaloTau ) + +DECLARE_COMPONENT( TauAllCaloDRFex ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/CMakeLists.txt b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/CMakeLists.txt new file mode 100644 index 00000000000..ccf23c25f80 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/CMakeLists.txt @@ -0,0 +1,36 @@ +################################################################################ +# Package: TrigT2CaloTileMon +################################################################################ + +# Declare the package name: +atlas_subdir( TrigT2CaloTileMon ) + +# Declare the package's dependencies: +atlas_depends_on_subdirs( PUBLIC + GaudiKernel + Trigger/TrigAlgorithms/TrigT2CaloCommon + Trigger/TrigEvent/TrigCaloEvent + Trigger/TrigEvent/TrigSteeringEvent + PRIVATE + Calorimeter/CaloGeoHelpers + Trigger/TrigT1/TrigT1Interfaces ) + +# External dependencies: +find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread ) + +# Component(s) in the package: +atlas_add_library( TrigT2CaloTileMonLib + src/*.cxx + PUBLIC_HEADERS TrigT2CaloTileMon + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel TrigCaloEvent TrigSteeringEvent TrigT2CaloCommonLib + PRIVATE_LINK_LIBRARIES CaloGeoHelpers TrigT1Interfaces ) + +atlas_add_component( TrigT2CaloTileMon + src/components/*.cxx + INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} + LINK_LIBRARIES ${ROOT_LIBRARIES} GaudiKernel TrigT2CaloCommonLib TrigCaloEvent TrigSteeringEvent CaloGeoHelpers TrigT1Interfaces TrigT2CaloTileMonLib ) + +# Install files from the package: +atlas_install_python_modules( python/*.py ) + diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/T2CaloTileMon.h b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/T2CaloTileMon.h new file mode 100755 index 00000000000..35564527824 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/T2CaloTileMon.h @@ -0,0 +1,76 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: T2CaloTileMon.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon + + AUTHOR: D.O. Damazion Jens Damaske + + PURPOSE: Based on T2CaloBase works as main driver for the LVL2 + Calorimeter TileMon Algorithm. Receives and decodes LVL1 + information (RoI position) and just makes some monitoring + *******************************************************************/ + +#ifndef TRIGT2CALOTILEMON_T2CALOTILEMON_H +#define TRIGT2CALOTILEMON_T2CALOTILEMON_H + +#include <string> +#include "TrigT2CaloCommon/T2CaloBase.h" +#include "GaudiKernel/ToolHandle.h" + +class IAlgToolCalo; +class T2CaloEgammaMon; +class MsgStream; +class TrigEMCluster; +class TrigT2TileJet; +class TrigT2Tower; + +/** Main LVL2 Algorithm. Processes LVL1 information, call FEX + IAlgToolCalos and produces the TrigEMCluster output. */ +class T2CaloTileMon: public T2CaloBase { + + public: + /** Constructor */ + T2CaloTileMon(const std::string & name, ISvcLocator* pSvcLocator); + /** Destructor */ + ~T2CaloTileMon(); + + /** hltExecute will call FEX IAlgToolCalo::execute() to process RoI. + called by the Steering per EMRoI. */ + HLT::ErrorCode hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* outputTE); + /** hltInitialize. Called by the Steering. */ + HLT::ErrorCode hltInitialize(); + /** hltFinalize. Called by the Steering. */ + HLT::ErrorCode hltFinalize(); + + private: + /** To support new monitoring. Values must be copied to + this monitored Cluster for each RoI. */ + //const TrigEMCluster* m_monitoredCluster; + /** To monitor rCore */ + //float m_rCore; + /** To monitor eRatio */ + //float m_eRatio; + /** Forced LVL1 eta */ + float m_l1eta; + /** Forced LVL1 phi */ + float m_l1phi; + + //int m_index; + + // Properties: + std::string m_trigEmClusterKey; + /** Will monitoring be used or not */ + //bool m_mon; + /** Coordinates to be used by the tools (in order by tool) */ + std::vector<float> m_etamin; + std::vector<float> m_etamax; + std::vector<float> m_phimin; + std::vector<float> m_phimax; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TileMonHadEnFex.h b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TileMonHadEnFex.h new file mode 100755 index 00000000000..86b74bca0f6 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TileMonHadEnFex.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: TileMonHadEnFex.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon + + AUTHOR: D.O.Damazio + + PURPOSE: Based on Cluster position defined in the second + EM Calorimeter layer, calculates total Had cluster + energy. + *******************************************************************/ + +#ifndef TRIGT2CALOTILEMON_TILEMONHADENFEX_H +#define TRIGT2CALOTILEMON_TILEMONHADENFEX_H + +#include "TrigT2CaloCommon/IAlgToolCalo.h" +#include "GaudiKernel/AlgTool.h" +#include "GaudiKernel/ServiceHandle.h" +#include "GaudiKernel/ITHistSvc.h" +#include "GaudiKernel/IIncidentSvc.h" +#include "GaudiKernel/IIncidentListener.h" +#include "TH1.h" +#include "TH2.h" + + +/** Feature extraction Tool for LVL2 Calo. Hadronic EndCaps + and Tile Calorimeter. All Samples */ +class TileMonHadEnFex: public IAlgToolCalo, virtual public IIncidentListener +{ + public: + TileMonHadEnFex(const std::string & type, const std::string & name, + const IInterface* parent); + virtual ~TileMonHadEnFex(); + using IAlgToolCalo::execute; + /** @brief execute feature extraction for the EM Calorimeter + * second layer + * @param[out] rtrigEmCluster is the output cluster. + * @param[in] eta/phi-min/max = RoI definition. + */ + StatusCode execute(TrigEMCluster &rtrigEmCluster,double etamin, + double etamax, double phimin, double phimax); + StatusCode initialize(); + StatusCode finalize(); + TH1*** hists(){ return m_hists; } + /** handle to init a new event */ + void handle (const Incident& ); + double logEnergy(double energy); +// void BinLogY(TH2* h); + + private: + ServiceHandle<ITHistSvc> m_thistSvc; + float m_THR_1; + float m_THR_2; + float m_end_detec_eta; + float m_end_detec_phi; + float m_eta_division; + float m_phi_division; + float m_energyCell_Thr; + + //Monitoring + TH1*** m_hists; + //TH1*** m_hist_TB0; //TileBar0 + //TH1*** m_hist_TB1; //TileBar1 + //TH1*** m_hist_TB2; //TileBar2 + TH2F** m_2dhists; + TH2F** m_2dhists_TB0; //TileBar0 + TH2F** m_2dhists_TB1; //TileBar1 + TH2F** m_2dhists_TB2; //TileBar2 + //TH2* m_mainHist; + std::string m_histPath; + bool m_configured; + +}; + + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2TileJet.h b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2TileJet.h new file mode 100755 index 00000000000..f2c2b311da4 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2TileJet.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: TrigT2TileJet.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon + + AUTHOR: Jens Damaske + + *******************************************************************/ + +#ifndef TRIGT2CALOTILEMON_TRIGTT2TILEJET_H +#define TRIGT2CALOTILEMON_TRIGTT2TILEJET_H + +// #include "TrigCaloEvent/TrigEMCluster.h" +#include "TrigCaloEvent/Trig3Momentum.h" +/// #include "Trig3Momentum.h" + +#include "TrigT2CaloTileMon/TrigT2Tower.h" +/// #include "TrigT2Tower.h" + +#include "GaudiKernel/MsgStream.h" + +#include <vector> +#include <iostream> + +/** LVL2 Trigger TileJet Class */ +class TrigT2TileJet /* : public TrigEMCluster */ +{ + + public: + // Default ctor/dtor. + + void insertCell(const Trig3Momentum& newCell, MsgStream& log); + void searchTowerAndInsert( const Trig3Momentum& cell, MsgStream& log, double etaShift = 0.0 ); + + /** find hottest Tower */ + bool findHottestTower(TrigT2Tower &tower) const; + + /** debugging */ + void print(MsgStream& log) const; + + private: + /** vector of TrigT2Tower elements that compose Jet */ + std::vector<TrigT2Tower> m_towercollection; +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2Tower.h b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2Tower.h new file mode 100644 index 00000000000..45a087ad918 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/TrigT2CaloTileMon/TrigT2Tower.h @@ -0,0 +1,80 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: TrigT2Tower.h + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon + + AUTHOR: Jens Damaske + PURPOSE: Compines 3 Trig3Momentum Objects to a Tower + + *******************************************************************/ + +#ifndef TRIGT2CALOTILEMON_TRIGTT2TOWER_H +#define TRIGT2CALOTILEMON_TRIGTT2TOWER_H + +#include "TrigCaloEvent/Trig3Momentum.h" +/// #include "Trig3Momentum.h" + +#include "GaudiKernel/MsgStream.h" + +#include <sstream> +#include <iostream> +#include <cmath> + +/** + 3 cells of type Trig3Momentum per tower + "cell.inCone is used as cell.inTower" +*/ +class TrigT2Tower{ + + public: + /** Default Constructor */ + TrigT2Tower(); + TrigT2Tower(const Trig3Momentum& newCell, MsgStream& log, double etaShift=0.0); + + // Get methods + /** Get the energy */ + double e() const {return m_e; } + /** Get the eta position */ + double eta() const {return m_eta; } + /** Get the phi position */ + double phi() const {return m_phi; } + /** Return if tower consists of 3 cells */ + bool isComplete() const {return m_full; } + /** Check if newCell belongs to this tower */ + bool isMember(const Trig3Momentum& newCell, MsgStream& log, double etaShift=0.0) const; + Trig3Momentum cell(int i) const {return m_cells[i]; } + + // Set methods + /** Set energy */ + void setE(double e) {m_e = e; } + /** Set eta */ + void setEta(double eta) {m_eta = eta; } + /** Set phi */ + void setPhi(double phi) {m_phi = phi; } + /** Flag if tower is full */ + void setComplete(bool isComplete) {m_full = isComplete;} + /** Insert cell */ + bool insertCell(const Trig3Momentum& newCell, MsgStream& log); + + // debugging + void print(MsgStream& log, MSG::Level level) const; + + private: + /** Energy */ + double m_e; + /** Eta */ + double m_eta; + /** Phi */ + double m_phi; + /** is full tower */ + bool m_full; + /** tower cells one for each layer */ + Trig3Momentum m_cells[3]; + +}; + +#endif diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/python/TrigT2CaloTileMonConfig.py b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/python/TrigT2CaloTileMonConfig.py new file mode 100755 index 00000000000..6b30ec851ce --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/python/TrigT2CaloTileMonConfig.py @@ -0,0 +1,36 @@ +# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + + +from TrigT2CaloTileMon.TrigT2CaloTileMonConf import TileMonHadEnFex +from TrigT2CaloTileMon.TrigT2CaloTileMonConf import T2CaloTileMon + +#from TrigMonitorBase.TrigGenericMonitoringToolConfig import defineHistogram +#from TrigMonitorBase.TrigGenericMonitoringToolConfig import TrigGenericMonitoringToolConfig + +#from AthenaCommon.Constants import VERBOSE,DEBUG + +class TileMonHadEnFex(TileMonHadEnFex): + __slots__ = [] + def __init__ (self, name="TileMonHadEnFex"): + super(TileMonHadEnFex,self).__init__(name) + self.THR_1=100 + self.HistogramsPath="/EXPERT/TileMonHadEnFex" + + +class T2CaloCosmic_Cosmic (T2CaloTileMon): + __slots__ = [] + def __init__ (self, name="T2CaloCosmic_Cosmic"): + super(T2CaloTileMon, self).__init__(name) + # here put your customizations + self.IAlgToolList= [TileMonHadEnFex() ] + self.IAlgToolList[0].HistogramsPath= "/EXPERT/" + self.IAlgToolList[0].HistogramsPath+=name + self.doTiming=True + +class T2CaloTileMon_TileMon (T2CaloTileMon): + __slots__ = [] + def __init__ (self, name="T2CaloTileMon_TileMon"): + super(T2CaloTileMon, self).__init__(name) + # here put your customizations + self.IAlgToolList= [TileMonHadEnFex() ] + self.doTiming=True diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/T2CaloTileMon.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/T2CaloTileMon.cxx new file mode 100755 index 00000000000..dcf3165a410 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/T2CaloTileMon.cxx @@ -0,0 +1,156 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: T2CaloTileMon.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon +// +// AUTHOR: D.O. Damazio, Jens Damaske +// +// - Add variables for job option controlled region limits, set defaults +// to most likely values. +// - Add function EtaPhiRange to return the maximum and minimum eta or phi +// values to use when calculating energy sums over a region - R. Soluk +// ******************************************************************** + +#include "GaudiKernel/MsgStream.h" +#include "GaudiKernel/IToolSvc.h" +#include "GaudiKernel/StatusCode.h" + +#include "TrigT1Interfaces/RecEmTauRoI.h" +#include "TrigSteeringEvent/TrigRoiDescriptor.h" +#include "TrigSteeringEvent/PhiHelper.h" + +#include "TrigCaloEvent/TrigEMClusterContainer.h" +#include "TrigT2CaloTileMon/TrigT2TileJet.h" +#include "TrigT2CaloTileMon/TrigT2Tower.h" + +#include "TrigT2CaloTileMon/T2CaloTileMon.h" +#include "TrigT2CaloCommon/IAlgToolCalo.h" + +class ISvcLocator; + +T2CaloTileMon::T2CaloTileMon(const std::string & name, ISvcLocator* pSvcLocator) : + T2CaloBase(name, pSvcLocator) +{ + declareProperty("TrigEMClusterKey",m_trigEmClusterKey = "T2CaloTrigEMCluster"); + declareProperty("L1ForceEta",m_l1eta = -10.0); + declareProperty("L1ForcePhi",m_l1phi = -10.0); + declareProperty("EtaMin",m_etamin); + declareProperty("EtaMax",m_etamax); + declareProperty("PhiMin",m_phimin); + declareProperty("PhiMax",m_phimax); + +} + +T2CaloTileMon::~T2CaloTileMon() +{ +} + + +HLT::ErrorCode T2CaloTileMon::hltInitialize() +{ + return HLT::OK; +} + + +HLT::ErrorCode T2CaloTileMon::hltExecute(const HLT::TriggerElement* inputTE, + HLT::TriggerElement* /*outputTE*/) +{ + // Time total T2CaloTileMon execution time. + if ( m_timersvc ) m_timer[0]->start(); + +#ifndef NDEBUG + ATH_MSG_INFO( "in execute()" ); +#endif + + const TrigRoiDescriptor* roiDescriptor = 0; + HLT::ErrorCode hltStatus = getFeature(inputTE, roiDescriptor); + + if ( hltStatus == HLT::OK ) { +#ifndef NDEBUG + ATH_MSG_DEBUG( *roiDescriptor ); +#endif + } + else + { + ATH_MSG_WARNING( " Failed to find RoiDescriptor " ); + return hltStatus; + } + + // End LVL1 part + double etamin, etamax, phimin, phimax; + if ( (m_l1eta<-9.9)&&(m_l1phi<-9.9)){ + etamin = std::max(-2.5,roiDescriptor->eta() - m_etaWidth); + etamax = std::min( 2.5,roiDescriptor->eta() + m_etaWidth); + phimin = HLT::wrapPhi(roiDescriptor->phi() - m_phiWidth); + phimax = HLT::wrapPhi(roiDescriptor->phi() + m_phiWidth); + } else { + etamin = std::max(-2.5,m_l1eta - m_etaWidth); + etamax = std::min( 2.5,m_l1eta + m_etaWidth); + phimin = HLT::wrapPhi(m_l1phi - m_phiWidth); + phimax = HLT::wrapPhi(m_l1phi + m_phiWidth); + } + +#ifndef NDEBUG + ATH_MSG_DEBUG( " etamin = "<< etamin ); + ATH_MSG_DEBUG( " etamax = "<< etamax ); + ATH_MSG_DEBUG( " phimin = "<< phimin ); + ATH_MSG_DEBUG( " phimax = "<< phimax ); +#endif + + /// TrigRoiDescriptor* newroi = new TrigRoiDescriptor( roiDescriptor->eta(), etamin, etamax, + /// roiDescriptor->phi(), phimin, phimax ); + + /// attachFeature( outputTE, newroi, "T2CaloTimeMon"); + /// Tile RS shoudl map to it's own requirements niw - we can + ///still use d-pi .. pi wrapping + + const TrigRoiDescriptor newroi( roiDescriptor->eta(), etamin, etamax, + roiDescriptor->phi(), phimin, phimax ); + + +#ifndef NDEBUG + ATH_MSG_DEBUG( " Making TrigEMCluster " ); +#endif + + + //std::vector<xAOD::TrigEMCluster*> vec_clus; + // Ok, ignoring LVL1 and forcing a position + + ToolHandleArray<IAlgToolCalo>::iterator it = m_emAlgTools.begin(); + if ( m_timersvc ) m_timer[1]->start(); + + //TrigEMCluster* ptrigEmCluster = new TrigT2TileJet(); + xAOD::TrigEMCluster* ptrigEmCluster = new xAOD::TrigEMCluster(); + for (; it < m_emAlgTools.end(); it++) + { + + // if ((*it)->execute(*ptrigEmCluster,etamin,etamax,phimin,phimax).isFailure() ) + if ((*it)->execute(*ptrigEmCluster,newroi, caloDDENull).isFailure() ) + { + ATH_MSG_WARNING( "T2Calo AlgToolTileMon returned Failure" ); + return HLT::TOOL_FAILURE; + } + } + delete ptrigEmCluster; // in for loop will be destroyed automatically + + if ( m_timersvc ) m_timer[1]->stop(); + + // Time total T2CaloTileMon execution time. + if ( m_timersvc ) m_timer[0]->stop(); + + return HLT::OK; +} + + +HLT::ErrorCode T2CaloTileMon::hltFinalize(){ + +#ifndef NDEBUG + ATH_MSG_INFO( "in finalize()" ); +#endif + + return HLT::OK; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TileMonHadEnFex.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TileMonHadEnFex.cxx new file mode 100755 index 00000000000..ec5551a799c --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TileMonHadEnFex.cxx @@ -0,0 +1,424 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +// ******************************************************************** +// +// NAME: TileMonHadEnFex.cxx +// PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon +// +// AUTHOR: Jens Damaske +// +// ******************************************************************** + +#include "TrigCaloEvent/TrigEMCluster.h" +#include "TrigT2CaloTileMon/TrigT2TileJet.h" +#include "TrigT2CaloTileMon/TrigT2Tower.h" +#include "TrigCaloEvent/Trig3Momentum.h" +#include "CaloGeoHelpers/CaloSampling.h" + +#include "TrigT2CaloTileMon/TileMonHadEnFex.h" +#include "TrigT2CaloCommon/Calo_Def.h" + +#include <math.h> +#include <TMath.h> +#include <string> + + +TileMonHadEnFex::TileMonHadEnFex(const std::string & type, const std::string & name, + const IInterface* parent) : + IAlgToolCalo(type, name, parent), + m_thistSvc("THistSvc/THistSvc","TileMonHadEnFex"), + m_THR_1(400), + m_THR_2(100), + m_hists(NULL), + //m_hist_TB0(NULL), + //m_hist_TB1(NULL), + //m_hist_TB2(NULL), + m_2dhists(NULL), + m_2dhists_TB0(NULL), + m_2dhists_TB1(NULL), + m_2dhists_TB2(NULL) + //m_mainHist(NULL) +{ + declareProperty("THistSvc",m_thistSvc,"THistSvc output"); + declareProperty("HistogramsPath",m_histPath="/EXPERT/T2CaloTileMon"); + declareProperty("THR_1",m_THR_1); + declareProperty("THR_2",m_THR_2); + m_end_detec_eta = 1.6; + m_end_detec_phi = M_PI; + m_eta_division = 0.1; + m_phi_division = M_PI/32.; + m_energyCell_Thr = 0.01; //Threshold in Gev + m_configured=false; +} + +TileMonHadEnFex::~TileMonHadEnFex(){ +} + +StatusCode TileMonHadEnFex::initialize(){ + if ( IAlgToolCalo::initialize().isFailure() ) + return StatusCode::FAILURE; + if ( m_thistSvc.retrieve().isFailure() ) + return StatusCode::FAILURE; + IIncidentSvc* p_incSvc; + if ( service("IncidentSvc",p_incSvc, true).isFailure() ) { + return StatusCode::FAILURE; + } + else + { + p_incSvc->addListener(this, "BeginRun",100); + } + + return StatusCode::SUCCESS; +} + + +double TileMonHadEnFex::logEnergy(double energy) +{ + energy = energy/1.e3; // energy in GeV + energy = TMath::Log(energy); + return energy; +} + +/** +* @brief changes the Y-axis binning of a given histogram to a logarithmic scale +* +* NOT SUPPORTED BY ONLINE HISTO GATHERER +* +* For a given histogram the Y-axis binning is changed form a linear to a logarithmic scale +* Take care, that the axis minimum is > 0 +* +* @param[in] h pointer to the histogram +*/ +// void TileMonHadEnFex::BinLogY(TH2* h) +// { +// TAxis *axis = h->GetYaxis(); +// int bins = axis->GetNbins(); +// Axis_t min = axis->GetXmin(); +// Axis_t max = axis->GetXmax(); +// Axis_t width = (max - min) / bins; +// Axis_t *new_bins = new Axis_t[bins + 1]; +// +// double logWidth = ( TMath::Log(max)-TMath::Log(min) ) / bins; +// +// // cout << "min:" << min << " max:" << max << " bins:" << bins << " logWidth:" << logWidth << endl; +// +// for (int i = 0; i <= bins; i++) { +// // cout << min + i * width << "\t"; +// new_bins[i] = min*TMath::Exp(i * logWidth); +// // cout << new_bins[i] << endl; +// } +// axis->Set(bins, new_bins); +// delete new_bins; +// } + +void TileMonHadEnFex::handle( const Incident& ) +{ + m_configured=false; + + m_2dhists = new TH2F* [(int)floorf((2*m_end_detec_eta)/m_eta_division)]; //2D histo Et vs phi + m_2dhists_TB0 = new TH2F* [(int)floorf((2*m_end_detec_eta)/m_eta_division)]; //2D histo Et vs phi for TileBar0 and TileExt0 + m_2dhists_TB1 = new TH2F* [(int)floorf((2*m_end_detec_eta)/m_eta_division)]; //2D histo Et vs phi for TileBar1 and TileExt1 + m_2dhists_TB2 = new TH2F* [(int)floorf((2*m_end_detec_eta)/m_eta_division)]; //2D histo Et vs phi for TileBar2 and TileExt2 + + for(float eta=-m_end_detec_eta;eta<m_end_detec_eta;eta+=m_eta_division) + { + int hist_grid_eta=(int)floorf(((eta)+m_end_detec_eta)/m_eta_division); + char name_2dhist[60]; + char name_2dhist_TB0[60]; + char name_2dhist_TB1[60]; + char name_2dhist_TB2[60]; + char name_2dhist_toreg[100]; + char name_2dhist_toreg_TB0[100]; + char name_2dhist_toreg_TB1[100]; + char name_2dhist_toreg_TB2[100]; + + float etaN = eta; + float epsilon = 0.00001; + + sprintf(name_2dhist,"TowerMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); //Tower + if (etaN <= (-1.1 + epsilon) || etaN >= (1.0 - epsilon) ) //Extended Barrel - Cell + { + sprintf(name_2dhist_TB0,"TE0_CellMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); + sprintf(name_2dhist_TB1,"TE1_CellMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); + sprintf(name_2dhist_TB2,"TE2_CellMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); + } + else if( etaN > (-1.1 + epsilon) && etaN < (1.0 - epsilon) ) //Central Barrel - Cell + { + sprintf(name_2dhist_TB0,"TB0_CellMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); + sprintf(name_2dhist_TB1,"TB1_CellMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); + sprintf(name_2dhist_TB2,"TB2_CellMonitor_eta=%-2.1f_%-2.1f",etaN,etaN+m_eta_division); + } + + sprintf(name_2dhist_toreg,"%s/TowerMonitor_n=%-2.1f",m_histPath.c_str(),etaN); //Tower + if (etaN <= (-1.1 + epsilon) || etaN >= (1.0 - epsilon) ) //Extended Barrel - Cell + { + sprintf(name_2dhist_toreg_TB0,"%s/TileExt0/TE0_CellMonitor_n=%-2.1f",m_histPath.c_str(),etaN); + sprintf(name_2dhist_toreg_TB1,"%s/TileExt1/TE1_CellMonitor_n=%-2.1f",m_histPath.c_str(),etaN); + sprintf(name_2dhist_toreg_TB2,"%s/TileExt2/TE2_CellMonitor_n=%-2.1f",m_histPath.c_str(),etaN); + } + else if( etaN > (-1.1 + epsilon) && etaN < (1.0 - epsilon) ) //Central Barrel - Cell + { + sprintf(name_2dhist_toreg_TB0,"%s/TileBar0/TB0_CellMonitor_n=%-2.1f",m_histPath.c_str(),etaN); + sprintf(name_2dhist_toreg_TB1,"%s/TileBar1/TB1_CellMonitor_n=%-2.1f",m_histPath.c_str(),etaN); + sprintf(name_2dhist_toreg_TB2,"%s/TileBar2/TB2_CellMonitor_n=%-2.1f",m_histPath.c_str(),etaN); + } + + std::string str1 =name_2dhist; + std::string str2=name_2dhist_TB0; + std::string str3=name_2dhist_TB1; + std::string str4=name_2dhist_TB2; + std::string str5=name_2dhist_toreg; + std::string str6=name_2dhist_toreg_TB0; + std::string str7=name_2dhist_toreg_TB1; + std::string str8=name_2dhist_toreg_TB2; + + std::string dot("."); + + if ( str1.find(".") != std::string::npos ) str1.replace(str1.find("."),dot.length(),"_"); + if ( str1.find(".") != std::string::npos ) str1.replace(str1.find("."),dot.length(),"_"); + + if ( str2.find(".") != std::string::npos ) str2.replace(str2.find("."),dot.length(),"_"); + if ( str2.find(".") != std::string::npos ) str2.replace(str2.find("."),dot.length(),"_"); + + if ( str3.find(".") != std::string::npos ) str3.replace(str3.find("."),dot.length(),"_"); + if ( str3.find(".") != std::string::npos ) str3.replace(str3.find("."),dot.length(),"_"); + + if ( str4.find(".") != std::string::npos ) str4.replace(str4.find("."),dot.length(),"_"); + if ( str4.find(".") != std::string::npos ) str4.replace(str4.find("."),dot.length(),"_"); + + if ( str5.find(".") != std::string::npos ) str5.replace(str5.find("."),dot.length(),"_"); + + if ( str6.find(".") != std::string::npos ) str6.replace(str6.find("."),dot.length(),"_"); + + if ( str7.find(".") != std::string::npos ) str7.replace(str7.find("."),dot.length(),"_"); + + if ( str8.find(".") != std::string::npos ) str8.replace(str8.find("."),dot.length(),"_"); + + strcpy(name_2dhist,str1.c_str()); + strcpy(name_2dhist_TB0,str2.c_str()); + strcpy(name_2dhist_TB1,str3.c_str()); + strcpy(name_2dhist_TB2,str4.c_str()); + strcpy(name_2dhist_toreg,str5.c_str()); + strcpy(name_2dhist_toreg_TB0,str6.c_str()); + strcpy(name_2dhist_toreg_TB1,str7.c_str()); + strcpy(name_2dhist_toreg_TB2,str8.c_str()); + + + /** + * Energy range should be from 0.02GeV - 50GeV with a precision of 1% + * we insert tower energy as ln(energy), so we need an energy axis from -4 to 4 with 800 bins + */ + m_2dhists[hist_grid_eta] = new TH2F(name_2dhist,name_2dhist,(int)floorf(2*m_end_detec_phi/m_phi_division),-m_end_detec_phi,m_end_detec_phi,800,-4.,4.); + m_2dhists[hist_grid_eta]->SetXTitle("#phi[#circ]"); + m_2dhists[hist_grid_eta]->SetYTitle("ln(E_{T}) [GeV]"); + + m_2dhists_TB0[hist_grid_eta] = new TH2F(name_2dhist_TB0,name_2dhist_TB0,(int)floorf(2*m_end_detec_phi/m_phi_division),-m_end_detec_phi,m_end_detec_phi,800,-4.,4.); + m_2dhists_TB0[hist_grid_eta]->SetXTitle("#phi[#circ]"); + m_2dhists_TB0[hist_grid_eta]->SetYTitle("ln(E_{T}) [GeV]"); + + m_2dhists_TB1[hist_grid_eta] = new TH2F(name_2dhist_TB1,name_2dhist_TB1,(int)floorf(2*m_end_detec_phi/m_phi_division),-m_end_detec_phi,m_end_detec_phi,800,-4.,4.); + m_2dhists_TB1[hist_grid_eta]->SetXTitle("#phi[#circ]"); + m_2dhists_TB1[hist_grid_eta]->SetYTitle("ln(E_{T}) [GeV]"); + + m_2dhists_TB2[hist_grid_eta] = new TH2F(name_2dhist_TB2,name_2dhist_TB2,(int)floorf(2*m_end_detec_phi/m_phi_division),-m_end_detec_phi,m_end_detec_phi,800,-4.,4.); + m_2dhists_TB2[hist_grid_eta]->SetXTitle("#phi[#circ]"); + m_2dhists_TB2[hist_grid_eta]->SetYTitle("ln(E_{T}) [GeV]"); + + if ( m_thistSvc->regHist(name_2dhist_toreg,m_2dhists[hist_grid_eta]).isFailure() ) msg() << MSG::ERROR << "Did not register hists" << endmsg; //return StatusCode::FAILURE; + if ( m_thistSvc->regHist(name_2dhist_toreg_TB0,m_2dhists_TB0[hist_grid_eta]).isFailure() ) msg() << MSG::ERROR << "Did not register hists" << endmsg; //return StatusCode::FAILURE; + if ( m_thistSvc->regHist(name_2dhist_toreg_TB1,m_2dhists_TB1[hist_grid_eta]).isFailure() ) msg() << MSG::ERROR << "Did not register hists" << endmsg; //return StatusCode::FAILURE; + if ( m_thistSvc->regHist(name_2dhist_toreg_TB2,m_2dhists_TB2[hist_grid_eta]).isFailure() ) msg() << MSG::ERROR << "Did not register hists" << endmsg; //return StatusCode::FAILURE; + } + + // m_mainHist = new + // TH2F("TT","TT",(int)floorf(2.*m_end_detec_eta/m_eta_division),-m_end_detec_eta,m_end_detec_eta,(int)floorf(2.*m_end_detec_phi/m_phi_division),-m_end_detec_phi,m_end_detec_phi); + // if ( m_thistSvc->regHist("/NT/TT",m_mainHist).isFailure() ) { + // return StatusCode::FAILURE; + // } + + + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << "Histograms correctly allocated" << endmsg; // + m_configured=true; + //return StatusCode::SUCCESS; +} + +StatusCode TileMonHadEnFex::finalize(){ +// Don't delete histograms. ROOT takes care of this. + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: HadEnFex: call finalize()" << endmsg; +// for(float eta=-m_end_detec_eta;eta<m_end_detec_eta;eta+=m_eta_division){ +// int hist_grid_eta=(int)floorf(((eta)+m_end_detec_eta)/m_eta_division); +// for(float phi=-m_end_detec_phi;phi<m_end_detec_phi;phi+=m_phi_division){ +// int hist_grid_phi=(int)floorf(((phi)+m_end_detec_phi)/m_phi_division); +// if ( m_hists[hist_grid_eta][hist_grid_phi]->GetMean() != 0 ) +// std::cout << "eta : " << eta << " phi : " << phi << " " << +// hist_grid_eta << " " << hist_grid_phi << " " << +// m_hists[hist_grid_eta][hist_grid_phi]->GetMean() << std::endl; +// m_mainHist->SetBinContent(hist_grid_eta,hist_grid_phi, +// m_hists[hist_grid_eta][hist_grid_phi]->GetMean() ); +// } +// } + + return StatusCode::SUCCESS; +} + +StatusCode TileMonHadEnFex::execute(TrigEMCluster &/*rtrigEmCluster*/,double etamin, + double etamax, double phimin, double phimax) +{ + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: HadEnFex: call execute()" << endmsg; + + // If there was a problem in configuration, stop now + if ( !m_configured ) return StatusCode::SUCCESS; + m_tiledecoded=false; + // Time total AlgTool time + if (!m_timersvc.empty()) m_timer[0]->start(); + + // MsgStream log(msgSvc(), name()); +#ifndef NDEBUG + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << "in execute(TrigEMCluster &)" << endmsg; +#endif + + CaloSampling::CaloSample samp; + + if (!m_timersvc.empty()) { + m_timer[1]->start(); + m_timer[1]->pause(); + m_timer[2]->start(); + m_timer[2]->pause(); + m_timer[3]->start(); + m_timer[3]->pause(); + m_timer[4]->start(); + m_timer[4]->pause(); + } + + + // TILECAL Assuming no knowledge about first sample + + // Time to access RegionSelector + if (!m_timersvc.empty()) m_timer[1]->resume(); + + /** + ToolHandle<ITrigDataAccess> m_data is an object that provides data access in a Region of Interest. + is inherited from "/Trigger/TrigAlgorithms/TrigT2CaloCommon/IAlgToolCalo.h"! See TrigT2CaloCommon/ITrigDataAccess.h for more details. + Region Selector, no sample needed + Get detector offline ID's for Collections + */ + m_data->RegionSelector(0,etamin,etamax,phimin,phimax,TILE); + + if (!m_timersvc.empty()) m_timer[1]->pause(); + +#ifndef NDEBUG + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: TILE: TileContSize()" << m_data->TileContSize() << endmsg; +#endif + + TrigT2TileJet jet; + + for (unsigned int iR=0;iR<m_data->TileContSize();iR++) { //loop over TileCal drawers + // Time to access Collection (and ByteStreamCnv ROBs) + if (!m_timersvc.empty()) m_timer[2]->resume(); + // For the first sample you will create the containers + // For the others no + if ( m_data->LoadCollections(m_itBegin,m_itEnd,iR,!iR).isFailure() ) { + return StatusCode::FAILURE; + } + // Finished to access Collection + if (!m_timersvc.empty()) m_timer[2]->pause(); + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->resume(); + + // Each cell must contribute to only one histogram + for(m_itt = m_itBegin;m_itt != m_itEnd; ++m_itt) { //loop over cells + + +// CaloSampling::CaloSample samp; +// samp = CaloSampling::getSampling(*(*m_itt)); +// double cellE = (*m_itt)->e(); + + + const TileCell* tilecell = (*m_itt); + double etaCell = tilecell->eta(); + double phiCell = tilecell->phi(); + double energyCell = tilecell->energy(); + //samp = CaloSampling::getSampling(*tilecell); + samp = tilecell->caloDDE()->getSampling(); + + // BAD CELLS +// if ( tilecell->badcell() ) std::cout << "JENSONBUTTON: e:" << energyCell/1.e3 << ", eta:" << etaCell << ", phi:" << phiCell << ", samp:" << samp << " bad:" << tilecell->badcell() << std::endl; + + // possibly do some tower building + // Energy Eta Phi Layer + Trig3Momentum tile_cell(energyCell,etaCell,phiCell,samp); + jet.insertCell(tile_cell, msg()); + + } // end of loop over cells + + // Algorithmic time + if (!m_timersvc.empty()) m_timer[3]->pause(); + + } // End of loop over TileCal drawers + + + if ( msg().level()<MSG::DEBUG ) + jet.print(msg()); + TrigT2Tower hottest_tower; + jet.findHottestTower(hottest_tower); + + // FILL HISTOS if at least one cell is set. if not RoI is not in Tile Barrel or Ext, Barrel and in consequence Hottest_tower would be emtpy + // Will get bias because of check for > 0.0 but can't be avoided because we take log(e) + if ( (hottest_tower.cell(0).inCone() || hottest_tower.cell(1).inCone() || hottest_tower.cell(2).inCone()) && hottest_tower.e() > 0.0 ) + { + + if ( msg().level() <= MSG::DEBUG ){ + msg() << MSG::DEBUG << " REGTEST: HOTTEST_TOWER: print:" << endmsg; + hottest_tower.print(msg(),MSG::DEBUG); + } + + // TOWER + int hist_grid_eta = (int) floorf( ((hottest_tower.eta()) + m_end_detec_eta)/m_eta_division); + m_2dhists[hist_grid_eta]->Fill((float)hottest_tower.phi(), logEnergy(hottest_tower.e()) ); + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: HOTTEST_TOWER: fill in histo: eta:" << hottest_tower.eta() << " phi:"<< (float)hottest_tower.phi() << " log(e):" << logEnergy(hottest_tower.e()) << endmsg; + + // CELLS + if ( hottest_tower.cell(0).inCone() && hottest_tower.cell(0).e() > 0.0 ) + { + m_2dhists_TB0[hist_grid_eta]->Fill((float)hottest_tower.cell(0).phi(), logEnergy(hottest_tower.cell(0).e()) ); + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: HOTTEST_CELL_0: fill in histo: eta:" << hottest_tower.cell(0).eta() << " phi:"<< (float)hottest_tower.cell(0).phi() << " log(e):" << logEnergy(hottest_tower.cell(0).e()) << endmsg; + } + + if ( hottest_tower.cell(1).inCone() && hottest_tower.cell(1).e() > 0.0 ) + { + m_2dhists_TB1[hist_grid_eta]->Fill((float)hottest_tower.cell(1).phi(), logEnergy(hottest_tower.cell(1).e()) ); + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: HOTTEST_CELL_1: fill in histo: eta:" << hottest_tower.cell(1).eta() << " phi:"<< (float)hottest_tower.cell(1).phi() << " log(e):" << logEnergy(hottest_tower.cell(1).e()) << endmsg; + } + + if ( hottest_tower.cell(2).inCone() && hottest_tower.cell(2).e() > 0.0 ) + { + // eta is different for layer 2 + hist_grid_eta=(int)floorf( ((hottest_tower.cell(2).eta()) + m_end_detec_eta)/m_eta_division); + m_2dhists_TB2[hist_grid_eta]->Fill((float)hottest_tower.cell(2).phi(), logEnergy(hottest_tower.cell(2).e()) ); + if ( msg().level() <= MSG::DEBUG ) + msg() << MSG::DEBUG << " REGTEST: HOTTEST_CELL_2: fill in histo: eta:" << hottest_tower.cell(2).eta() << " phi:"<< (float)hottest_tower.cell(2).phi() << " log(e):" << logEnergy(hottest_tower.cell(2).e()) << endmsg; + } + } + + + // Stop all timers + if (!m_timersvc.empty()){ + m_timer[4]->stop(); + m_timer[3]->stop(); + m_timer[2]->stop(); + m_timer[1]->stop(); + m_timer[0]->stop(); + } + + return StatusCode::SUCCESS; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2TileJet.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2TileJet.cxx new file mode 100755 index 00000000000..c173ee3da9c --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2TileJet.cxx @@ -0,0 +1,97 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +#include "TrigT2CaloTileMon/TrigT2TileJet.h" +/// #include "TrigT2TileJet.h" +#include "TrigCaloEvent/Trig3Momentum.h" +/// #include "Trig3Momentum.h" + +void TrigT2TileJet::insertCell(const Trig3Momentum& newCell, MsgStream& log) +{ + if ( log.level() <= MSG::DEBUG ){ + log << MSG::DEBUG << " REGTEST: CELL: initial cell info: eta:" << newCell.eta() << " phi:" << newCell.phi() + << " e:" << newCell.e() << " layer:" << newCell.caloSample() << endmsg; + } + + // ONLY TILE BARREL AND EXTEND BARREL ALLOWED TO PASS HERE + if ( + newCell.caloSample() == CaloSampling::TileBar0 || + newCell.caloSample() == CaloSampling::TileBar1 || + newCell.caloSample() == CaloSampling::TileBar2 || + newCell.caloSample() == CaloSampling::TileExt0 || + newCell.caloSample() == CaloSampling::TileExt1 || + newCell.caloSample() == CaloSampling::TileExt2 + ) + { + // if cell in layer 2, cell size is 0.2 x 0.1 + // make a copy of this cell and assign both two a tower + if ( + newCell.caloSample() == CaloSampling::TileBar2 || + newCell.caloSample() == CaloSampling::TileExt2 + ) + { + searchTowerAndInsert( newCell, log, -0.05 ); + searchTowerAndInsert( newCell, log, +0.05 ); + } + else + { + searchTowerAndInsert(newCell, log); + } + + } +} + +void TrigT2TileJet::searchTowerAndInsert( const Trig3Momentum& cell, MsgStream& log, double etaShift ) +{ + bool flag = 0; + + // walk through tower collection and look for an appropriate tower + for (TrigT2Tower& tt : m_towercollection) + { + if( tt.isMember(cell, log, etaShift) ) + { + if( tt.insertCell(cell, log) ) + { + // insert new Cell and end loop immediately + flag = 1; + break; // stop loop + } + else + { + log << MSG::WARNING << " REGTEST: CELL: tried to insert Cell twice in a tower!" << endmsg; + flag=1; // do not insert in new tower + break; + } + } + } + // tower not in collection yet, so create one + if ( !flag ) + { + if ( log.level() <= MSG::DEBUG ) + log << MSG::DEBUG << " REGTEST: CELL: insert in NEW tower" << endmsg; + m_towercollection.emplace_back( cell, log, etaShift ); + + } + +} + +void TrigT2TileJet::print(MsgStream& log) const +{ + log << MSG::DEBUG << " REGTEST: JET: print jet:" << endmsg; + for (const TrigT2Tower& tt : m_towercollection) + { + tt.print(log,MSG::DEBUG); + } +} + +bool TrigT2TileJet::findHottestTower(TrigT2Tower &tower) const +{ + tower.setE(0.); + for (const TrigT2Tower& tt : m_towercollection) + { + if ( tt.e() > tower.e() ) tower = tt; + } + if ( tower.e() > 0.0) return true; + else return false; +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2Tower.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2Tower.cxx new file mode 100644 index 00000000000..fb9fa8129f4 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/TrigT2Tower.cxx @@ -0,0 +1,131 @@ +/* + Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +*/ + +/******************************************************************** + + NAME: TrigT2Tower.cxx + PACKAGE: Trigger/TrigAlgorithms/TrigT2CaloTileMon + + AUTHOR: Jens Damaske + PURPOSE: Combines 3 Trig3Momentum Objects to a Tower + + *******************************************************************/ + +#include "TrigT2CaloTileMon/TrigT2Tower.h" +/// #include "TrigT2Tower.h" + + +TrigT2Tower::TrigT2Tower(): m_eta(0.0), m_phi(0.0) +{ + // flush tower + setComplete( 0 ); + setE( 0. ); + + // flush all 3 cells + for( int i=0; i<3; i++ ) + { + m_cells[i] = Trig3Momentum( 0., 0., 0., CaloSampling::Unknown); + m_cells[i].setInCone(0); + } +} + +/** insert first Cell everytime new tower is build */ +TrigT2Tower::TrigT2Tower(const Trig3Momentum& newCell, MsgStream& log, double etaShift): m_eta(0.0), m_phi(0.0) +{ + // flush tower + setComplete( 0 ); + setE( 0. ); + + // flush all 3 cells + for( int i=0; i<3; i++ ) + { + m_cells[i] = Trig3Momentum( 0., 0., 0., CaloSampling::Unknown); + m_cells[i].setInCone(0); + } + + // set tower position to first cell position + setEta( newCell.eta() + etaShift ); + setPhi( newCell.phi() ); + + insertCell( newCell, log); +} + +bool TrigT2Tower::insertCell(const Trig3Momentum& cell, MsgStream& log) +{ + if ( cell.caloSample() == CaloSampling::TileBar0 || cell.caloSample() == CaloSampling::TileExt0 ) + { + if ( !m_cells[0].inCone() ) + { + m_cells[0] = cell; + setE( e() + cell.e() ); + m_cells[0].setInCone(1); + } + else return 0; + } + else if ( cell.caloSample() == CaloSampling::TileBar1 || cell.caloSample() == CaloSampling::TileExt1 ) + { + if ( !m_cells[1].inCone() ) + { + m_cells[1] = cell; + setE( e() + cell.e() ); + m_cells[1].setInCone(1); + } + else return 0; + } + else if ( cell.caloSample() == CaloSampling::TileBar2 || cell.caloSample() == CaloSampling::TileExt2 ) + { + if ( !m_cells[2].inCone() ) + { + m_cells[2] = cell; + setE( e() + cell.e()/2. ); + m_cells[2].setInCone(1); + } + else return 0; + } + else + { + log << MSG::WARNING << " REGTEST: CELL: is not in TILE. caloSample ID is: " << cell.caloSample() << endmsg; + return 0; + } + + // is tower full now ?? + int sum = 0; + for( int i=0; i<3; i++ ) + { + if ( m_cells[i].inCone() ) sum++; + } + if ( sum == 3 ) setComplete(1); + + return 1; +} + +// phi and eta is known up to 3 decimal +bool TrigT2Tower::isMember(const Trig3Momentum& cell, MsgStream& log, double etaShift) const +{ + double delta = 0.005; + if ( fabs(eta()-(cell.eta()+etaShift))<delta && fabs(phi()-cell.phi())<delta ) + { + if ( log.level()<MSG::DEBUG ) + log << MSG::DEBUG << " REGTEST: CELL: insert in EXISTING tower: eta" << eta() << " phi:" << phi() << endmsg; + return true; + } + + return false; +} + +void TrigT2Tower::print(MsgStream& log, MSG::Level level) const +{ + log << level << " REGTEST: TOWER: eta:" << eta() << " phi:" << phi() << " e:" << e() << endmsg; + + for( int i=0; i<3; i++ ) + { + if ( m_cells[i].inCone() ) + { + log << level << " REGTEST: CELL " << i << " : eta:" << m_cells[i].eta() << " phi:" << m_cells[i].phi() + << " e:" << m_cells[i].e() << endmsg; + } + else log << level << " REGTEST: CELL " << i << " : is NOT SET" << endmsg; + } + +} diff --git a/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/components/TrigT2CaloTileMon_entries.cxx b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/components/TrigT2CaloTileMon_entries.cxx new file mode 100644 index 00000000000..9157c8f71a3 --- /dev/null +++ b/Trigger/TrigAlgorithms/TrigT2CaloTileMon/src/components/TrigT2CaloTileMon_entries.cxx @@ -0,0 +1,6 @@ +#include "TrigT2CaloTileMon/T2CaloTileMon.h" +#include "TrigT2CaloTileMon/TileMonHadEnFex.h" + +DECLARE_COMPONENT( T2CaloTileMon ) +DECLARE_COMPONENT( TileMonHadEnFex ) + -- GitLab