ATLAS Offline Software
Loading...
Searching...
No Matches
TrigCaloClusterCalibrator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5/********************************************************************
6 *
7 * NAME: TrigCaloClusterCalibrator
8 * PACKAGE: Trigger/TrigAlgorithms/TrigCaloRec
9 *
10 * AUTHOR: Jon Burr
11 * CREATED: 2020/07/10
12 *
13 * Shallow copy an existing cluster container and apply cluster processors to
14 * it. Largely copied from the TrigCaloClusterMaker.
15 *********************************************************************/
16
24#include <tuple>
25
27 const std::string& name, ISvcLocator* pSvcLocator) :
28 AthReentrantAlgorithm(name, pSvcLocator)
29{
30}
31
33{
34 ATH_MSG_INFO("Initialise " << name() );
35
36 if (!m_monTool.empty() )
37 ATH_CHECK(m_monTool.retrieve() );
38 else
39 ATH_MSG_INFO("No monitoring tool configured");
40
41 ATH_CHECK( m_clusterCorrections.retrieve() );
42 ATH_CHECK( m_inputClustersKey.initialize() );
43 ATH_CHECK( m_outputClustersKey.initialize() );
44 ATH_CHECK( m_outputCellLinksKey.initialize() );
45
46 return StatusCode::SUCCESS;
47}
48
49StatusCode TrigCaloClusterCalibrator::execute(const EventContext& ctx) const
50{
51 ATH_MSG_DEBUG("Running " << name() );
52 auto time_corr = Monitored::Timer("TIME_ClustCorr");
53
54 // Do the shallow copying
56 {
57 // Make a temporary scope - this means that the unique pointers die at the
58 // end of the scope (so don't hang around after the move call)
60 auto [clusters, clustersAux] = xAOD::shallowCopyContainer(*inputClusters,ctx);
61 // And record
62 ATH_CHECK( outputClusters.record(std::move(clusters), std::move(clustersAux)));
63 // We also need to copy across the cell links information.
64 // To explain: the non-const cell iteration methods use an internal pointer,
65 // which is only finalized into an element link into the persistent
66 // container later. Therefore while we have a modifiable cluster, it has to
67 // have this local pointer present...
68 for (auto itrPair = std::make_pair(inputClusters->begin(), outputClusters->begin());
69 itrPair != std::make_pair(inputClusters->end(), outputClusters->end());
70 ++itrPair.first, ++itrPair.second) {
71 const CaloClusterCellLink* inputLinks = (**itrPair.first).getCellLinks();
72 if (!inputLinks) {
73 ATH_MSG_ERROR("Failed to read the cell links from the input clusters!");
74 return StatusCode::FAILURE;
75 }
76 (**itrPair.second).addCellLink(std::make_unique<CaloClusterCellLink>(*inputLinks));
77 }
78 }
79
80 time_corr.start();
81 for (const ToolHandle<CaloClusterProcessor>& clcorr : m_clusterCorrections) {
82 for (xAOD::CaloCluster* cl : *outputClusters) {
83 if (!m_isSW.value() ||
84 (std::abs(cl->eta0()) < 1.45 && clcorr->name().find("37") != std::string::npos) ||
85 (std::abs(cl->eta0()) >= 1.45 && clcorr->name().find("55") != std::string::npos) ) {
86 ATH_CHECK(clcorr->execute(ctx, cl));
87 ATH_MSG_VERBOSE("Executed correction tool " << clcorr->name());
88 }
89 }
90 }
91 time_corr.stop();
92
93 // Now we also have to make the cell links persistent
95 ATH_CHECK(CaloClusterStoreHelper::finalizeClusters(cellLinks, outputClusters.ptr()));
96 // After this is done, the non-const cell iteration functions will segfault!
97 // This means we really shouldn't let anyone retrieve this as a non-const
98 // container...
99 ATH_CHECK( outputClusters.setConst() );
100
101 // fill monitored containers
102 // Only monitor kinematic quantities which the calibrations may have changed
104 time_corr,
105 Monitored::Collection("Et", *outputClusters, &xAOD::CaloCluster::et),
106 Monitored::Collection("Phi", *outputClusters, &xAOD::CaloCluster::calPhi),
107 Monitored::Collection("Eta", *outputClusters, &xAOD::CaloCluster::calEta)).fill();
108
109 // Add REGTEST entries
110 if (!outputClusters->empty() ) {
111 ATH_MSG_DEBUG(" REGTEST: Last Cluster Et = " << outputClusters->back()->et());
112 ATH_MSG_DEBUG(" REGTEST: Last Cluster eta = " << outputClusters->back()->eta());
113 ATH_MSG_DEBUG(" REGTEST: Last Cluster phi = " << outputClusters->back()->phi());
114 }
115
116 return StatusCode::SUCCESS;
117}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
Header file to be included by clients of the Monitored infrastructure.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
Group of local monitoring quantities and retain correlation when filling histograms
void fill()
Explicitly fill the monitoring histograms and disable autoFill.
A monitored timer.
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
ToolHandle< GenericMonitoringTool > m_monTool
virtual StatusCode initialize() override
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputClustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClustersKey
SG::WriteHandleKey< CaloClusterCellLinkContainer > m_outputCellLinksKey
ToolHandleArray< CaloClusterProcessor > m_clusterCorrections
TrigCaloClusterCalibrator(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) const override
flt_t calPhi() const
Get in signal state CALIBRATED.
flt_t calEta() const
Get in signal state CALIBRATED.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
std::pair< std::unique_ptr< T >, std::unique_ptr< ShallowAuxContainer > > shallowCopyContainer(const T &cont, const EventContext &ctx)
Function making a shallow copy of a constant container.