ATLAS Offline Software
PseudoJetContainer.h
Go to the documentation of this file.
1 // this file is -*- C++ -*-
2 
3 
4 
5 #ifndef PseudoJetContainer_H
6 #define PseudoJetContainer_H
7 
8 /*
9  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
10 */
11 
12 
13 // PseudoJetContainer - maintains a list of Pseudovctors, and the the
14 // EDM objects used to create them. It is used to supply Pseudojets
15 // for clustering, and to identify the EDM objects with the Pseudojets
16 // in a Pseudojet cluster.
17 
18 // - maintains a list of pseudojets to be used for clustering by fastjet
19 // fastjet returns a clustered set of pseudojets in the form of a single
20 // pseudojet with components. The components are the pseudojets in the cluster
21 // Note: fastjet may also add its own pseudojets to the cluster.
22 //
23 // - has association objects (Extractors) which allow the
24 // identification of the EDM object for a given pseudojet.
25 // When PseudoJetContainer::extractConstituents() is passed a jet and a
26 // Pseudojet, it finds the components of the pseudojet (which are
27 // also held in the PseudoJetContainer pseudojet list), sorts them by
28 // type. For each type, it asks the appropriate Extractor to add
29 // the EDM objects to the jet.
30 //
31 // PseudoJetContainers can coelesce with other PseudoJetContainers via the
32 // append() method.
33 
34 // Johannes Elmsheuser, April 2016
35 // P Sherwood, December 2107
36 
37 #include "fastjet/PseudoJet.hh"
38 #include "xAODJet/Jet.h"
41 #include <vector>
42 #include <string>
43 #include <set>
44 #include <memory>
45 
46 typedef std::vector<fastjet::PseudoJet> PseudoJetVector;
47 
49 public:
50  typedef fastjet::PseudoJet PseudoJet;
51 
53 
54  // Constructor from a ConstituentExtractor and vector<PseudoJet>
55  // PseudoJet OWNS their ConstituentExtractors
56  PseudoJetContainer(std::unique_ptr<const IConstituentExtractor> c,
57  const std::vector<PseudoJet> & vecPJ,
58  bool debug=false);
59 
60  // fill xAOD jet with constit&ghosts extracted from final PSeudoJet
61  bool extractConstituents(xAOD::Jet&, const std::vector<PseudoJet>&) const;
62  bool extractConstituents(xAOD::Jet& jet, const PseudoJet &finalPJ) const;
63  // fill xAOD jet with correct by-vertex consituents and ghosts
64  bool extractByVertexConstituents(xAOD::Jet& jet, const PseudoJet& finalPJ, const xAOD::Vertex* vertex) const;
65  // returns the list of input constituents
66  // typically to give to a fastjet::ClusterSequence
67  const std::vector<PseudoJet>* casVectorPseudoJet() const;
68  std::vector<PseudoJet>* casVectorPseudoJet();
69 
70  // combine the contents of a PseudoJetContainer with the current container.
71  void append(const PseudoJetContainer*);
72 
73  // dump function with levels of detail. the second arg gives the
74  // level of detail for the contained extractors
75  std::string toString(int level, int extLevel=0) const;
76  std::size_t size() const;
77  std::string dumpPseudoJets() const;
78 
79  bool debug() const;
80  void debug(bool b);
81  friend std::ostream& operator<<(std::ostream&, const PseudoJetContainer&);
82 
83 private:
84 
85 
86  bool checkInvariants(const std::string&) const;
87  bool bad_invariants_exit(const std::ostringstream&) const;
88 
89  bool checkPseudoJetVector(const std::vector<PseudoJet>&,
90  const std::string&) const;
91 
92  bool checkInConstituents(const std::vector<PseudoJet>&,
93  const std::string&) const;
94 
95  // all pseudojets, used by fastjet
96  std::vector<PseudoJet> m_allConstituents;
97 
98 
99  // List of associated Extractors,
100  // which contains the EDM objects whose momentum
101  // is used to a pseudojet. Note that only some of the EDM objects
102  // give rise to pseudojets, an the pseudojet index range the are valid for.
103  // Mapping of pseudojet indices to Extractor
104 
105  struct ExtractorRange {
106  ExtractorRange(unsigned int lo,
107  unsigned int hi,
108  std::unique_ptr<const IConstituentExtractor> e):
109  m_lo(lo), m_hi(hi), m_e(std::move(e)){
110  }
111 
113  : m_lo(other.m_lo),
114  m_hi(other.m_hi),
115  m_e(other.m_e->clone()){
116  }
117 
119  using std::swap;
120 
121  swap(first.m_lo, second.m_lo);
122  swap(first.m_hi, second.m_hi);
123  swap(first.m_e, second.m_e);
124  }
125 
127  swap(*this, other);
128  return *this;
129  }
130 
131  ExtractorRange bump(int step) const {
132  return ExtractorRange(m_lo + step, m_hi + step, std::unique_ptr<const IConstituentExtractor>(m_e->clone()));
133  }
134 
135  int m_lo;
136  int m_hi;
137  std::unique_ptr<const IConstituentExtractor> m_e{};
138  };
139 
140  std::vector<ExtractorRange> m_extractorRanges;
141 
142  //Empty extractors are those with EDM objects for which no Pseudojet was
143  // created by the creating PseudoJetGetter. We need to keep track
144  // of the empty extractors to fill zero information (such as 0 counts)
145  // into the jets.
146  std::set<std::unique_ptr<const IConstituentExtractor>> m_emptyExtractors;
147 
148  bool m_debug{false};
149 };
150 
151 std::ostream& operator << (std::ostream&, const PseudoJetContainer&);
152 
153 #include "xAODCore/CLASS_DEF.h"
154 CLASS_DEF( PseudoJetContainer , 147270789 , 1 )
155 
156 #endif
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
PseudoJetContainer::ExtractorRange
Definition: PseudoJetContainer.h:105
PseudoJetContainer::bad_invariants_exit
bool bad_invariants_exit(const std::ostringstream &) const
Definition: PseudoJetContainer.cxx:428
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Jet.h
PseudoJetContainer::ExtractorRange::m_e
std::unique_ptr< const IConstituentExtractor > m_e
Definition: PseudoJetContainer.h:137
PseudoJetContainer::m_allConstituents
std::vector< PseudoJet > m_allConstituents
Definition: PseudoJetContainer.h:96
PseudoJetContainer::checkPseudoJetVector
bool checkPseudoJetVector(const std::vector< PseudoJet > &, const std::string &) const
Definition: PseudoJetContainer.cxx:305
PseudoJetContainer::m_debug
bool m_debug
Definition: PseudoJetContainer.h:148
IConstituentExtractor.h
PseudoJetContainer
Definition: PseudoJetContainer.h:48
PseudoJetContainer::operator<<
friend std::ostream & operator<<(std::ostream &, const PseudoJetContainer &)
Definition: PseudoJetContainer.cxx:446
PseudoJetContainer::checkInvariants
bool checkInvariants(const std::string &) const
Definition: PseudoJetContainer.cxx:211
python.Utilities.clone
clone
Definition: Utilities.py:134
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
PseudoJetContainer::ExtractorRange::swap
friend void swap(ExtractorRange &first, ExtractorRange &second)
Definition: PseudoJetContainer.h:118
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
PseudoJetContainer::PseudoJet
fastjet::PseudoJet PseudoJet
Definition: PseudoJetContainer.h:50
PseudoJetContainer::m_extractorRanges
std::vector< ExtractorRange > m_extractorRanges
Definition: PseudoJetContainer.h:140
PseudoJetContainer::ExtractorRange::m_hi
int m_hi
Definition: PseudoJetContainer.h:136
PseudoJetContainer::ExtractorRange::ExtractorRange
ExtractorRange(const ExtractorRange &other)
Definition: PseudoJetContainer.h:112
PseudoJetVector
std::vector< fastjet::PseudoJet > PseudoJetVector
Definition: PseudoJetContainer.h:46
PseudoJetContainer::toString
std::string toString(int level, int extLevel=0) const
Definition: PseudoJetContainer.cxx:172
PseudoJetContainer::extractConstituents
bool extractConstituents(xAOD::Jet &, const std::vector< PseudoJet > &) const
Definition: PseudoJetContainer.cxx:48
PseudoJetContainer::append
void append(const PseudoJetContainer *)
Definition: PseudoJetContainer.cxx:145
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
PseudoJetContainer::ExtractorRange::operator=
ExtractorRange & operator=(ExtractorRange other)
Definition: PseudoJetContainer.h:126
PseudoJetContainer::debug
bool debug() const
Definition: PseudoJetContainer.cxx:444
PseudoJetContainer::PseudoJetContainer
PseudoJetContainer()
Definition: PseudoJetContainer.cxx:21
PseudoJetContainer::m_emptyExtractors
std::set< std::unique_ptr< const IConstituentExtractor > > m_emptyExtractors
Definition: PseudoJetContainer.h:146
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
CLASS_DEF.h
File providing the different SG_BASE macros.
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
Trk::vertex
@ vertex
Definition: MeasurementType.h:21
VertexContainer.h
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
PseudoJetContainer::ExtractorRange::bump
ExtractorRange bump(int step) const
Definition: PseudoJetContainer.h:131
PseudoJetContainer::ExtractorRange::m_lo
int m_lo
Definition: PseudoJetContainer.h:135
PseudoJetContainer::size
std::size_t size() const
Definition: PseudoJetContainer.cxx:440
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
DeMoScan.first
bool first
Definition: DeMoScan.py:536
LArCellBinning.step
step
Definition: LArCellBinning.py:158
PseudoJetContainer::casVectorPseudoJet
const std::vector< PseudoJet > * casVectorPseudoJet() const
Definition: PseudoJetContainer.cxx:135
PseudoJetContainer::ExtractorRange::ExtractorRange
ExtractorRange(unsigned int lo, unsigned int hi, std::unique_ptr< const IConstituentExtractor > e)
Definition: PseudoJetContainer.h:106
PseudoJetContainer::dumpPseudoJets
std::string dumpPseudoJets() const
Definition: PseudoJetContainer.cxx:199
PseudoJetContainer::checkInConstituents
bool checkInConstituents(const std::vector< PseudoJet > &, const std::string &) const
Definition: PseudoJetContainer.cxx:360
python.compressB64.c
def c
Definition: compressB64.py:93
PseudoJetContainer::extractByVertexConstituents
bool extractByVertexConstituents(xAOD::Jet &jet, const PseudoJet &finalPJ, const xAOD::Vertex *vertex) const
Definition: PseudoJetContainer.cxx:114
operator<<
std::ostream & operator<<(std::ostream &, const PseudoJetContainer &)
Definition: PseudoJetContainer.cxx:446