ATLAS Offline Software
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 
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 
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 
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 
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)
70 
71  CaloPrefetch::nextDDE( m_cellIt, m_endCellItinConstit );
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
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
jet::JetCellAccessor::const_iterator::const_iterator
const_iterator(constit_iterator constIt, constit_iterator constItE, bool endIt=false)
Definition: JetCellAccessor.cxx:17
jet::JetCellAccessor::end
static const_iterator end(const xAOD::Jet *jet)
Definition: JetCellAccessor.cxx:81
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::setCellIteratorFromConstit
bool setCellIteratorFromConstit(const xAOD::IParticle *p)
Definition: JetCellAccessor.cxx:46
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:423
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
JetCellAccessor.h
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:59
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
CaloCluster.h
jet::JetCellAccessor::begin
static const_iterator begin(const xAOD::Jet *jet)
Definition: JetCellAccessor.cxx:76
jet::JetCellAccessor::const_iterator::nextConstituent
void nextConstituent()
Definition: JetCellAccessor.cxx:61
xAOD::CaloCluster_v1::begin
const_iterator begin() const
Definition: CaloCluster_v1.h:824
jet::JetCellAccessor::const_iterator::m_cellIt
cell_iterator m_cellIt
Definition: JetCellAccessor.h:75
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
CxxUtils::prefetchObj
void prefetchObj(const T *ptr)
Generic prefetch of the object of specific types (sizes).
Definition: prefetch.h:108
jet::JetCellAccessor::constit_iterator
std::vector< ElementLink< xAOD::IParticleContainer > >::const_iterator constit_iterator
Definition: JetCellAccessor.h:40
jet::JetCellAccessor::const_iterator::m_constitIt
constit_iterator m_constitIt
Definition: JetCellAccessor.h:77
CaloPrefetch::nextDDE
void nextDDE(Iter iter, Iter endIter)
Prefetch next CaloDDE.
Definition: CaloPrefetch.h:47