ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigGepPerf
src
GepTowersAlg.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/*
6
This algorithm creates clusters from CaloCells, and writes them out
7
as Caloclusters. The clustering strategy is carried out by helper objects.
8
The strategy used is chosen accoeding to string set at configure time. *
9
*/
10
11
#include "
./GepTowersAlg.h
"
12
13
// concrete cluster maker classes:
14
#include "
./TCTowerMaker.h
"
15
#include "
./TopoTowerMaker.h
"
16
17
#include "
./Cluster.h
"
18
#include "GaudiKernel/EventContext.h"
19
20
#include "
CaloDetDescr/CaloDetDescrManager.h
"
21
#include "
xAODCaloEvent/CaloClusterAuxContainer.h
"
22
23
GepTowersAlg::GepTowersAlg
(
const
std::string& name, ISvcLocator* pSvcLocator ) :
24
AthReentrantAlgorithm
( name, pSvcLocator ){
25
}
26
27
28
StatusCode
GepTowersAlg::initialize
() {
29
ATH_MSG_INFO
(
"Initializing "
<< name() <<
"..."
);
30
ATH_MSG_INFO
(
"Tower alg "
<<
m_towerAlg
);
31
32
// Initialize read and write handles
33
CHECK
(
m_eventInfoKey
.initialize());
34
CHECK
(
m_caloCellsKey
.initialize());
35
CHECK
(
m_caloClustersKey
.initialize());
36
CHECK
(
m_outputCaloClustersKey
.initialize());
37
CHECK
(
m_gepCellsKey
.initialize());
38
39
return
StatusCode::SUCCESS;
40
}
41
42
43
StatusCode
GepTowersAlg::execute
(
const
EventContext& context)
const
{
44
// Feed the specified cell map to a cluster creation algorithm and writes
45
// them out
46
47
ATH_MSG_DEBUG
(
"Executing "
<< name() <<
"..."
);
48
49
auto
h_eventInfo =
SG::makeHandle
(
m_eventInfoKey
, context);
50
CHECK
(h_eventInfo.isValid());
51
ATH_MSG_DEBUG
(
"eventNumber="
<< h_eventInfo->eventNumber() );
52
53
// read in clusters
54
auto
h_caloClusters =
SG::makeHandle
(
m_caloClustersKey
, context);
55
CHECK
(h_caloClusters.isValid());
56
ATH_MSG_DEBUG
(
"Read in "
<< h_caloClusters->size() <<
" clusters"
);
57
58
auto
h_caloCells =
SG::makeHandle
(
m_caloCellsKey
, context);
59
CHECK
(h_caloCells.isValid());
60
61
// container for CaloCluster wrappers for Gep Clusters
62
SG::WriteHandle<xAOD::CaloClusterContainer>
h_outputCaloClusters =
63
SG::makeHandle
(
m_outputCaloClustersKey
, context);
64
CHECK
(h_outputCaloClusters.
record
(std::make_unique<xAOD::CaloClusterContainer>(),
65
std::make_unique<xAOD::CaloClusterAuxContainer>()));
66
67
// Run a cluster algorithm
68
std::unique_ptr<Gep::ITowerMaker> towerMaker{};
69
70
// Instantiate a cluster creater object
71
if
(
m_towerAlg
==
"TCTower"
){
72
towerMaker.reset(
new
Gep::TCTowerMaker
());
73
}
74
else
if
(
m_towerAlg
==
"TopoTower"
){
75
towerMaker.reset(
new
Gep::TopoTowerMaker
());
76
}
77
if
( !towerMaker ){
78
ATH_MSG_ERROR
(
"Unknown towerMaker"
+
m_towerAlg
);
79
return
StatusCode::FAILURE;
80
}
81
82
ATH_MSG_DEBUG
(
"Running "
<< towerMaker->getName() <<
" tower algorithm."
);
83
84
// pass them to the tower maker
85
const
xAOD::CaloClusterContainer
& clusters = *h_caloClusters;
86
const
CaloCellContainer
& cells = *h_caloCells;
87
std::vector<Gep::Cluster> customTowers = towerMaker->makeTowers(clusters,cells);
88
89
ATH_MSG_DEBUG
(
"Tower Maker Algorithm completed."
);
90
ATH_MSG_DEBUG
(
"No of towers: "
<< customTowers.size());
91
if
(!customTowers.empty()){
92
ATH_MSG_DEBUG
(
"Tower 0 Energy: "
<< (customTowers[0]).
vec
.E());
93
}
94
95
// Store the Gep clusters to a CaloClusters, and write out.
96
h_outputCaloClusters->reserve(customTowers.size());
97
98
for
(
const
auto
& gepclus: customTowers){
99
100
// make a unique_ptr, but keep hold of the bare pointer
101
auto
*ptr = h_outputCaloClusters->push_back(std::make_unique<xAOD::CaloCluster>());
102
103
// to update the calo cluster.
104
ptr->setE(gepclus.vec.E());
105
ptr->setEta(gepclus.vec.Eta());
106
ptr->setPhi(gepclus.vec.Phi());
107
ptr->setTime(gepclus.time);
108
}
109
110
return
StatusCode::SUCCESS;
111
}
112
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloClusterAuxContainer.h
CaloDetDescrManager.h
Definition of CaloDetDescrManager.
vec
std::vector< size_t > vec
Definition
CombinationsGeneratorTest.cxx:9
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
GepTowersAlg.h
TCTowerMaker.h
TopoTowerMaker.h
Cluster.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
CaloCellContainer
Container class for CaloCell.
Definition
CaloCellContainer.h:55
GepTowersAlg::m_gepCellsKey
SG::ReadHandleKey< Gep::GepCellMap > m_gepCellsKey
Definition
GepTowersAlg.h:43
GepTowersAlg::initialize
virtual StatusCode initialize() override
Definition
GepTowersAlg.cxx:28
GepTowersAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition
GepTowersAlg.h:30
GepTowersAlg::m_caloClustersKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_caloClustersKey
Definition
GepTowersAlg.h:36
GepTowersAlg::GepTowersAlg
GepTowersAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
GepTowersAlg.cxx:23
GepTowersAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition
GepTowersAlg.cxx:43
GepTowersAlg::m_towerAlg
Gaudi::Property< std::string > m_towerAlg
Definition
GepTowersAlg.h:27
GepTowersAlg::m_caloCellsKey
SG::ReadHandleKey< CaloCellContainer > m_caloCellsKey
Definition
GepTowersAlg.h:33
GepTowersAlg::m_outputCaloClustersKey
SG::WriteHandleKey< xAOD::CaloClusterContainer > m_outputCaloClustersKey
Definition
GepTowersAlg.h:39
Gep::TCTowerMaker
Definition
TCTowerMaker.h:18
Gep::TopoTowerMaker
Definition
TopoTowerMaker.h:23
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
xAOD::CaloClusterContainer
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloClusterContainer.h:17
Generated on
for ATLAS Offline Software by
1.17.0