ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10namespace 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
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
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
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
63 if(m_constitIt == m_constitItE) return;
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)
70
72 } else nextConstituent();
73 }
74
75
77 const std::vector< ElementLink< xAOD::IParticleContainer > >& vec = jet->constituentLinks();
78 return {vec.begin(),vec.end()};
79 }
80
82 const std::vector< ElementLink< xAOD::IParticleContainer > >& vec = jet->constituentLinks();
83 return {vec.begin(),vec.end(), true};
84 }
85
86
87}
88#endif
std::vector< size_t > vec
bool setCellIteratorFromConstit(const xAOD::IParticle *p)
const_iterator(constit_iterator constIt, constit_iterator constItE, bool endIt=false)
static const_iterator begin(const xAOD::Jet *jet)
static const_iterator end(const xAOD::Jet *jet)
std::vector< ElementLink< xAOD::IParticleContainer > >::const_iterator constit_iterator
Class providing the definition of the 4-vector interface.
void nextDDE(Iter iter, Iter endIter)
Prefetch next CaloDDE.
void prefetchObj(const T *ptr)
Generic prefetch of the object of specific types (sizes).
Definition prefetch.h:108
@ CaloCluster
The object is a calorimeter cluster.
Definition ObjectType.h:39
Jet_v1 Jet
Definition of the current "jet version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.