ATLAS Offline Software
Loading...
Searching...
No Matches
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
46typedef std::vector<fastjet::PseudoJet> PseudoJetVector;
47
49public:
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
83private:
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
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
118 friend void swap(ExtractorRange& first, ExtractorRange& second){
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
151std::ostream& operator << (std::ostream&, const PseudoJetContainer&);
152
153#include "xAODCore/CLASS_DEF.h"
154CLASS_DEF( PseudoJetContainer , 147270789 , 1 )
155
156#endif
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
File providing the different SG_BASE macros.
std::vector< fastjet::PseudoJet > PseudoJetVector
std::ostream & operator<<(std::ostream &, const PseudoJetContainer &)
std::set< std::unique_ptr< const IConstituentExtractor > > m_emptyExtractors
bool extractByVertexConstituents(xAOD::Jet &jet, const PseudoJet &finalPJ, const xAOD::Vertex *vertex) const
std::vector< PseudoJet > m_allConstituents
bool checkInConstituents(const std::vector< PseudoJet > &, const std::string &) const
bool checkInvariants(const std::string &) const
friend std::ostream & operator<<(std::ostream &, const PseudoJetContainer &)
const std::vector< PseudoJet > * casVectorPseudoJet() const
std::vector< ExtractorRange > m_extractorRanges
std::size_t size() const
void append(const PseudoJetContainer *)
fastjet::PseudoJet PseudoJet
bool bad_invariants_exit(const std::ostringstream &) const
std::string dumpPseudoJets() const
std::string toString(int level, int extLevel=0) const
bool checkPseudoJetVector(const std::vector< PseudoJet > &, const std::string &) const
bool extractConstituents(xAOD::Jet &, const std::vector< PseudoJet > &) const
STL namespace.
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)
Jet_v1 Jet
Definition of the current "jet version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
friend void swap(ExtractorRange &first, ExtractorRange &second)
ExtractorRange bump(int step) const
ExtractorRange(const ExtractorRange &other)
ExtractorRange(unsigned int lo, unsigned int hi, std::unique_ptr< const IConstituentExtractor > e)
ExtractorRange & operator=(ExtractorRange other)
std::unique_ptr< const IConstituentExtractor > m_e