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 std::pair<xAOD::CaloClusterContainer*, xAOD::ShallowAuxContainer*> copyPair =
61 xAOD::shallowCopyContainer(*inputClusters);
62 // Show that we're taking ownership explicitly
63 std::unique_ptr<xAOD::CaloClusterContainer> clusters{copyPair.first};
64 std::unique_ptr<xAOD::ShallowAuxContainer> clustersAux{copyPair.second};
65 // And record
66 ATH_CHECK( outputClusters.record(std::move(clusters), std::move(clustersAux)));
67 // We also need to copy across the cell links information.
68 // To explain: the non-const cell iteration methods use an internal pointer,
69 // which is only finalized into an element link into the persistent
70 // container later. Therefore while we have a modifiable cluster, it has to
71 // have this local pointer present...
72 for (auto itrPair = std::make_pair(inputClusters->begin(), outputClusters->begin());
73 itrPair != std::make_pair(inputClusters->end(), outputClusters->end());
74 ++itrPair.first, ++itrPair.second) {
75 const CaloClusterCellLink* inputLinks = (**itrPair.first).getCellLinks();
76 if (!inputLinks) {
77 ATH_MSG_ERROR("Failed to read the cell links from the input clusters!");
78 return StatusCode::FAILURE;
79 }
80 (**itrPair.second).addCellLink(std::make_unique<CaloClusterCellLink>(*inputLinks));
81 }
82 }
83
84 time_corr.start();
85 for (const ToolHandle<CaloClusterProcessor>& clcorr : m_clusterCorrections) {
86 for (xAOD::CaloCluster* cl : *outputClusters) {
87 if (!m_isSW.value() ||
88 (std::abs(cl->eta0()) < 1.45 && clcorr->name().find("37") != std::string::npos) ||
89 (std::abs(cl->eta0()) >= 1.45 && clcorr->name().find("55") != std::string::npos) ) {
90 ATH_CHECK(clcorr->execute(ctx, cl));
91 ATH_MSG_VERBOSE("Executed correction tool " << clcorr->name());
92 }
93 }
94 }
95 time_corr.stop();
96
97 // Now we also have to make the cell links persistent
99 ATH_CHECK(CaloClusterStoreHelper::finalizeClusters(cellLinks, outputClusters.ptr()));
100 // After this is done, the non-const cell iteration functions will segfault!
101 // This means we really shouldn't let anyone retrieve this as a non-const
102 // container...
103 ATH_CHECK( outputClusters.setConst() );
104
105 // fill monitored containers
106 // Only monitor kinematic quantities which the calibrations may have changed
108 time_corr,
109 Monitored::Collection("Et", *outputClusters, &xAOD::CaloCluster::et),
110 Monitored::Collection("Phi", *outputClusters, &xAOD::CaloCluster::calPhi),
111 Monitored::Collection("Eta", *outputClusters, &xAOD::CaloCluster::calEta)).fill();
112
113 // Add REGTEST entries
114 if (!outputClusters->empty() ) {
115 ATH_MSG_DEBUG(" REGTEST: Last Cluster Et = " << outputClusters->back()->et());
116 ATH_MSG_DEBUG(" REGTEST: Last Cluster eta = " << outputClusters->back()->eta());
117 ATH_MSG_DEBUG(" REGTEST: Last Cluster phi = " << outputClusters->back()->phi());
118 }
119
120 return StatusCode::SUCCESS;
121}
#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.