ATLAS Offline Software
Loading...
Searching...
No Matches
Reconstruction
Jet
JetUtils
src
JetCellAccessor.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef XAOD_ANALYSIS
6
7
#include "
JetUtils/JetCellAccessor.h
"
8
#include "
xAODCaloEvent/CaloCluster.h
"
9
10
namespace
jet
{
11
12
namespace
{
13
using
linkAndWeightCollType = std::vector<std::pair<unsigned int, double>>;
// recopied from CaloClusterCellLink.h since it's private there
14
static
const
linkAndWeightCollType voidCont;
15
}
16
17
JetCellAccessor::const_iterator::const_iterator
(
constit_iterator
constIt,
constit_iterator
constItE,
bool
endIt) :
18
m_cellIt
( nullptr, voidCont.
begin
() ) ,
19
m_endCellItinConstit
( nullptr, voidCont.
end
()) ,
20
m_constitIt
(constIt),
21
m_constitItE
(constItE) {
22
23
if
( constItE == constIt )
return
;
24
25
if
( ! endIt ) {
26
// setup the iterator
27
--
m_constitIt
;
28
nextConstituent
();
29
//if (m_cellIt!=m_endCellItinConstit) std::cout << " ---> building begin cellIT" << (*m_cellIt)<<std::endl;
30
31
}
else
{
32
// Build an end iterator by finding a valid end cell iterator:
33
bool
foundCells =
false
;
34
// start from the last constituent, loop until one valid is found.
35
for
(--constItE ; constIt != constItE; --constItE) {
36
foundCells =
setCellIteratorFromConstit
(**constItE);
37
if
( foundCells)
break
;
38
}
39
if
( ! foundCells ) foundCells =
setCellIteratorFromConstit
(**constIt);
40
if
( foundCells)
m_cellIt
=
m_endCellItinConstit
;
41
// else no cell in this jet : cell iterators are already positionned to a void container.
42
}
43
44
}
45
46
bool
JetCellAccessor::const_iterator::setCellIteratorFromConstit
(
const
xAOD::IParticle
* part){
47
// return true if the cell iterator could be set from the current constituent
48
49
if
( part->type() ==
xAOD::Type::CaloCluster
){
50
const
auto
*cellLink =
static_cast<
const
xAOD::CaloCluster
*
>
(part)->getCellLinks();
51
if
( cellLink ==
nullptr
)
return
false
;
52
m_cellIt
= cellLink->begin();
53
m_endCellItinConstit
= cellLink->end();
54
55
return
true
;
56
}
57
58
return
false
;
59
}
60
61
void
JetCellAccessor::const_iterator::nextConstituent
(){
62
++
m_constitIt
;
63
if
(
m_constitIt
==
m_constitItE
)
return
;
64
if
(
setCellIteratorFromConstit
(**
m_constitIt
) ){
65
// if (m_cellIt!=m_endCellItinConstit) std::cout << " nextConstituent cell= " << (*m_cellIt)<<std::endl;
66
67
// Use prefetching technique to speed up the loop over cells.
68
for
(
auto
it=
m_cellIt
; it !=
m_endCellItinConstit
; ++it)
69
CxxUtils::prefetchObj
(*it);
70
71
CaloPrefetch::nextDDE
(
m_cellIt
,
m_endCellItinConstit
);
72
}
else
nextConstituent
();
73
}
74
75
76
JetCellAccessor::const_iterator
JetCellAccessor::begin
(
const
xAOD::Jet
*
jet
){
77
const
std::vector< ElementLink< xAOD::IParticleContainer > >&
vec
=
jet
->constituentLinks();
78
return
{
vec
.begin(),
vec
.end()};
79
}
80
81
JetCellAccessor::const_iterator
JetCellAccessor::end
(
const
xAOD::Jet
*
jet
){
82
const
std::vector< ElementLink< xAOD::IParticleContainer > >&
vec
=
jet
->constituentLinks();
83
return
{
vec
.begin(),
vec
.end(),
true
};
84
}
85
86
87
}
88
#endif
vec
std::vector< size_t > vec
Definition
CombinationsGeneratorTest.cxx:9
CaloCluster.h
JetCellAccessor.h
jet::JetCellAccessor::const_iterator
Definition
JetCellAccessor.h:43
jet::JetCellAccessor::const_iterator::m_endCellItinConstit
cell_iterator m_endCellItinConstit
Definition
JetCellAccessor.h:76
jet::JetCellAccessor::const_iterator::m_cellIt
cell_iterator m_cellIt
Definition
JetCellAccessor.h:75
jet::JetCellAccessor::const_iterator::setCellIteratorFromConstit
bool setCellIteratorFromConstit(const xAOD::IParticle *p)
Definition
JetCellAccessor.cxx:46
jet::JetCellAccessor::const_iterator::m_constitIt
constit_iterator m_constitIt
Definition
JetCellAccessor.h:77
jet::JetCellAccessor::const_iterator::const_iterator
const_iterator(constit_iterator constIt, constit_iterator constItE, bool endIt=false)
Definition
JetCellAccessor.cxx:17
jet::JetCellAccessor::const_iterator::m_constitItE
constit_iterator m_constitItE
Definition
JetCellAccessor.h:78
jet::JetCellAccessor::const_iterator::nextConstituent
void nextConstituent()
Definition
JetCellAccessor.cxx:61
jet::JetCellAccessor::begin
static const_iterator begin(const xAOD::Jet *jet)
Definition
JetCellAccessor.cxx:76
jet::JetCellAccessor::end
static const_iterator end(const xAOD::Jet *jet)
Definition
JetCellAccessor.cxx:81
jet::JetCellAccessor::constit_iterator
std::vector< ElementLink< xAOD::IParticleContainer > >::const_iterator constit_iterator
Definition
JetCellAccessor.h:40
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
CaloPrefetch::nextDDE
void nextDDE(Iter iter, Iter endIter)
Prefetch next CaloDDE.
Definition
CaloPrefetch.h:47
CxxUtils::prefetchObj
void prefetchObj(const T *ptr)
Generic prefetch of the object of specific types (sizes).
Definition
prefetch.h:108
jet
Definition
JetCalibTools_PlotJESFactors.cxx:23
xAODType::CaloCluster
@ CaloCluster
The object is a calorimeter cluster.
Definition
ObjectType.h:39
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition
Event/xAOD/xAODJet/xAODJet/Jet.h:17
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition
Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
Generated on
for ATLAS Offline Software by
1.14.0