ATLAS Offline Software
Loading...
Searching...
No Matches
CaloTopoClusterTowerMerger.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
7
9
12
14
15#define CL_RHMSG( NAME ) MsgStream& operator<<(MsgStream& mstr,const SG::ReadHandleKey< NAME >& ckey ) { mstr << ckey.key(); return mstr; }
16#define CL_WHMSG( NAME ) MsgStream& operator<<(MsgStream& mstr,const SG::WriteHandleKey< NAME >& ckey ) { mstr << ckey.key(); return mstr; }
17
18namespace {
20}
21
22// std::vector<xAOD::CaloCluster::MomentType> CaloTopoClusterTowerMerger::m_momentList = std::vector< CL_MNAME( MomentType ) >();
23// std::vector<std::tuple<xAOD::CaloCluster::MomentType,std::string> > CaloTopoClusterTowerMerger::m_momentMap {
24// CL_ENTRY( FIRST_PHI ),
25// CL_ENTRY( FIRST_ETA ),
26// CL_ENTRY( SECOND_R ),
27// CL_ENTRY( SECOND_LAMBDA ),
28// CL_ENTRY( DELTA_PHI ),
29// CL_ENTRY( DELTA_THETA ),
30// CL_ENTRY( DELTA_ALPHA ),
31// CL_ENTRY( CENTER_X ),
32// CL_ENTRY( CENTER_Y ),
33// CL_ENTRY( CENTER_Z ),
34// CL_ENTRY( CENTER_MAG ),
35// CL_ENTRY( CENTER_LAMBDA ),
36// CL_ENTRY( LATERAL ),
37// CL_ENTRY( LONGITUDINAL ),
38// CL_ENTRY( ENG_FRAC_EM ),
39// CL_ENTRY( ENG_FRAC_MAX ),
40// CL_ENTRY( ENG_FRAC_CORE ),
41// CL_ENTRY( FIRST_ENG_DENS ),
42// CL_ENTRY( SECOND_ENG_DENS ),
43// CL_ENTRY( ISOLATION ),
44// CL_ENTRY( ENG_BAD_CELLS ),
45// CL_ENTRY( N_BAD_CELLS ),
46// CL_ENTRY( N_BAD_CELLS_CORR ),
47// CL_ENTRY( BAD_CELLS_CORR_E ),
48// CL_ENTRY( BADLARQ_FRAC ),
49// CL_ENTRY( ENG_POS ),
50// CL_ENTRY( SIGNIFICANCE ),
51// CL_ENTRY( CELL_SIGNIFICANCE ),
52// CL_ENTRY( CELL_SIG_SAMPLING ),
53// CL_ENTRY( AVG_LAR_Q ),
54// CL_ENTRY( AVG_TILE_Q ),
55// CL_ENTRY( ENG_BAD_HV_CELLS ),
56// CL_ENTRY( N_BAD_HV_CELLS ),
57// CL_ENTRY( PTD ),
58// CL_ENTRY( EM_PROBABILITY ),
59// CL_ENTRY( HAD_WEIGHT ),
60// CL_ENTRY( OOC_WEIGHT ),
61// CL_ENTRY( DM_WEIGHT ),
62// CL_ENTRY( TILE_CONFIDENCE_LEVEL ),
63// CL_ENTRY( VERTEX_FRACTION ),
64// CL_ENTRY( NVERTEX_FRACTION ),
65// CL_ENTRY( ETACALOFRAME ),
66// CL_ENTRY( PHICALOFRAME ),
67// CL_ENTRY( ETA1CALOFRAME ),
68// CL_ENTRY( PHI1CALOFRAME ),
69// CL_ENTRY( ETA2CALOFRAME ),
70// CL_ENTRY( PHI2CALOFRAME ),
71// CL_ENTRY( ENG_CALIB_TOT ),
72// CL_ENTRY( ENG_CALIB_OUT_L ),
73// CL_ENTRY( ENG_CALIB_OUT_M ),
74// CL_ENTRY( ENG_CALIB_OUT_T ),
75// CL_ENTRY( ENG_CALIB_DEAD_L ),
76// CL_ENTRY( ENG_CALIB_DEAD_M ),
77// CL_ENTRY( ENG_CALIB_DEAD_T ),
78// CL_ENTRY( ENG_CALIB_EMB0 ),
79// CL_ENTRY( ENG_CALIB_EME0 ),
80// CL_ENTRY( ENG_CALIB_TILEG3 ),
81// CL_ENTRY( ENG_CALIB_DEAD_TOT ),
82// CL_ENTRY( ENG_CALIB_DEAD_EMB0 ),
83// CL_ENTRY( ENG_CALIB_DEAD_TILE0 ),
84// CL_ENTRY( ENG_CALIB_DEAD_TILEG3 ),
85// CL_ENTRY( ENG_CALIB_DEAD_EME0 ),
86// CL_ENTRY( ENG_CALIB_DEAD_HEC0 ),
87// CL_ENTRY( ENG_CALIB_DEAD_FCAL ),
88// // CL_ENTRY( ENG_CALIB_DEAD_LEAKAG ), // not in r21
89// // CL_ENTRY( ENG_CALIB_DEAD_UNCLAS ), // not in r21
90// CL_ENTRY( ENG_CALIB_FRAC_EM ),
91// CL_ENTRY( ENG_CALIB_FRAC_HAD ),
92// CL_ENTRY( ENG_CALIB_FRAC_REST )
93// };
94
95CaloTopoClusterTowerMerger::CaloTopoClusterTowerMerger(const std::string& name,ISvcLocator* pSvcLocator)
96 : AthReentrantAlgorithm(name,pSvcLocator)
97 , m_clusterContainerKey("CaloCalTopoCluster")
98 , m_towerContainerKey("CaloCalFwdTopoTower")
99 , m_topoSignalContainerKey("CaloCalTopoSignal")
101 , m_clusterRange(3.2)
102{
103 declareProperty("TopoClusterContainerKey",m_clusterContainerKey, "Topo-cluster container key" );
104 declareProperty("TopoTowerContainerKey", m_towerContainerKey, "Topo-tower container key" );
105 declareProperty("TopoSignalContainerKey", m_topoSignalContainerKey,"Topo-signal container key" );
106 declareProperty("TopoSignalCellLinksKey", m_cellLinkContainerKey, "Topo-signal cell links key" );
107 declareProperty("TopoClusterRange", m_clusterRange, "Rapidity range for using topo-clusters in combined signal mode");
108}
109
111= default;
112
114{
115 if ( m_clusterRange <= 0. ) {
116 ATH_MSG_ERROR( CaloRec::Helpers::fmtMsg("Invalid topo-cluster range |y| < %6.3f - algorithm non-functional",m_clusterRange) );
117 return StatusCode::FAILURE;
118 }
119
120 if ( m_cellLinkContainerKey.key().empty() ) { m_cellLinkContainerKey = m_topoSignalContainerKey.key() + std::string("_links"); }
121 ATH_CHECK( m_clusterContainerKey.initialize() ); // topo-cluster input key
122 ATH_CHECK( m_towerContainerKey.initialize() ); // topo-tower input key
123 ATH_CHECK( m_topoSignalContainerKey.initialize() ); // topo-signal (topo-cluster+topo-tower) output key
124 ATH_CHECK( m_cellLinkContainerKey.initialize() ); // cell link container key (ESD only)
125
126 ATH_MSG_INFO( CaloRec::Helpers::fmtMsg("Topo_cluster with |y| < %.2f will be merged with topo-towers with |y| > %.2f",m_clusterRange,m_clusterRange) );
127
128 return StatusCode::SUCCESS;
129}
130
131StatusCode CaloTopoClusterTowerMerger::execute(const EventContext& ctx) const
132{
133
134 // collect input
135 rhandle_t clusterHandle(m_clusterContainerKey,ctx);
136 if ( !clusterHandle.isValid() ) {
137 ATH_MSG_WARNING( "Topo-cluster container with key <" << m_clusterContainerKey << "> not found" );
138 return StatusCode::SUCCESS;
139 }
140 rhandle_t towerHandle(m_towerContainerKey,ctx);
141 if ( !towerHandle.isValid() ) {
142 ATH_MSG_WARNING( "Topo-tower container with key <" << m_towerContainerKey << "> not found" );
143 return StatusCode::SUCCESS;
144 }
145
146 // prepare output
147 whandle_t signalHandle(m_topoSignalContainerKey,ctx);
148 ATH_CHECK(this->addContainerWriteHandle(signalHandle));
149
150 // fill output from topo-clusters
151 for ( const auto *pClus : *clusterHandle ) { if ( clusterFilter(*pClus) ) { CaloTopoClusterTowerMerger::makeDeepCopy(*pClus,signalHandle.ptr()); } }
152 // fill output from topo-towers
153 for ( const auto *pTowr : *towerHandle ) { if ( towerFilter(*pTowr) ) { CaloTopoClusterTowerMerger::makeDeepCopy(*pTowr,signalHandle.ptr()); } }
154
155 // finalize the clusters/towers
156 lhandle_t linkHandle(m_cellLinkContainerKey,ctx);
157 ATH_CHECK(CaloClusterStoreHelper::finalizeClusters (linkHandle,signalHandle.ptr()));
158
159 return StatusCode::SUCCESS;
160}
161
162bool
165{
166 auto* copyClus = new xAOD::CaloCluster();
167 // pass ownership
168 pClusCont->push_back(copyClus);
169 // then assign to
170 (*copyClus) = rClus;
171 return true;
172}
173
176// // get a new signal handle
177// signalHandle = std::unique_ptr<xAOD::CaloClusterContainer>(new xAOD::CaloClusterContainer());
178// if ( !signalHandle.isValid() ) { return StatusCode::FAILURE; }
179// // get AUX container
180// xAOD::CaloClusterAuxContainer* auxData = new xAOD::CaloClusterAuxContainer();
181// std::string auxName(m_topoSignalContainerKey.key()+"Aux.");
182// if ( evtStore()->overwrite(auxData,auxName).isFailure() ) {
183// ATH_MSG_ERROR("Failed to record xAOD::CaloClusterAuxContainer with key <" << auxName << ">");
184// delete auxData;
185// return StatusCode::FAILURE;
186// }
187// // connect store with object container
188// signalHandle.ptr()->setStore(auxData);
189// return StatusCode::SUCCESS;
190// }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define CL_RHMSG(NAME)
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
An algorithm that can be simultaneously executed in multiple threads.
static StatusCode AddContainerWriteHandle(SG::WriteHandle< xAOD::CaloClusterContainer > &clusColl)
Creates a new xAOD::CaloClusterContainer in the given WriteHandle + CaloClusterAuxContainer and recor...
static StatusCode finalizeClusters(SG::WriteHandle< CaloClusterCellLinkContainer > &h, xAOD::CaloClusterContainer *pClusterColl)
Finalize clusters (move CaloClusterCellLink to a separate container).
bool clusterFilter(const xAOD::CaloCluster &rClus) const
Filter topo-cluster.
virtual ~CaloTopoClusterTowerMerger()
Baseclass destructor.
lhandlekey_t m_cellLinkContainerKey
Output cell links for merged container.
static bool makeDeepCopy(const xAOD::CaloCluster &rClus, xAOD::CaloClusterContainer *pClusCont)
Attaches a deep copy to container, returns true if successful.
SG::ReadHandle< xAOD::CaloClusterContainer > rhandle_t
Input data handle type.
double m_clusterRange
Rapidity range for topo-clusters.
virtual StatusCode initialize() override
Initialization sets up read and write handle keys.
CaloTopoClusterTowerMerger(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm constructor.
virtual StatusCode execute(const EventContext &ctx) const override
Execution merges the container contents.
whandlekey_t m_topoSignalContainerKey
Output merged container.
rhandlekey_t m_clusterContainerKey
Input topo-cluster container.
SG::WriteHandle< CaloClusterCellLinkContainer > lhandle_t
Cell link container output data handle.
static StatusCode addContainerWriteHandle(whandle_t &signalHandle)
Add a write handle for a container (in CaloClusterStoreHelper from r21.9)
rhandlekey_t m_towerContainerKey
Input topo-tower container.
SG::WriteHandle< xAOD::CaloClusterContainer > whandle_t
Output data handle type.
bool towerFilter(const xAOD::CaloCluster &rTowr) const
Filter topo-tower.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
std::string fmtMsg(const char *fmt,...)
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.