13#include "fastjet/PseudoJet.hh"
23using PtMap = std::vector<double>;
34 enum ParType { UNDEF, IPART, MUSEG };
42 const fastjet::PseudoJet* ppj2) {
45 const fastjet::PseudoJet* ppseudojet =
nullptr;
48 if ( ppseudojet ==
nullptr ) {
51 if ( ppseudojet ==
nullptr )
return -1;
59 for ( PseudoJetVector::const_iterator icon=cons.begin(); icon!=cons.end(); ++icon ) {
63 if ( pli ==
nullptr ) {
65 if ( pli ==
nullptr )
return -2;
66 unsigned int maxli = pli->
size() + 1;
69 for (
unsigned int ili=0; ili<maxli; ++ili ) {
72 for ( ParType& partype : partypes ) partype = UNDEF;
73 for (
unsigned int idx=0; idx<maxli; ++idx ) {
74 std::string lab = pli->
label(idx);
76 partypes.push_back(UNDEF);
78 }
else if ( lab.find(
"MuonSegment") != std::string::npos ) {
79 partypes.push_back(MUSEG);
81 partypes.push_back(IPART);
85 if ( pli != cui.
labelMap() )
return -4;
89 unsigned int icui = cui.
index();
90 ParType partype = partypes[icui];
91 if ( ppar ==
nullptr ) {
93 if ( pmscui ==
nullptr )
return -5;
94 pms = pmscui->object();
95 if ( partype != MUSEG )
return -6;
97 if ( partype != IPART )
return -7;
106 jet.addConstituent(ppar);
110 if ( partype == MUSEG ) {
111 outms[icui].push_back(pms);
112 }
else if ( partype == IPART ) {
113 out[icui].push_back(ppar);
123 for (
size_t i=1; i<out.size(); ++i ) {
125 const NameList& ghostlabs = *pghostlabs;
126 if (
find(ghostlabs.begin(), ghostlabs.end(), pli->
label(i)) == ghostlabs.end() ) {
127 nbad += out[i].size();
131 ParType& partype = partypes[i];
132 std::string cname = pli->
label(i) +
"Count";
133 std::string ptname = pli->
label(i) +
"Pt";
139 if(!(*cacc_parent(
jet))->getAttribute(cname,count_test)) {
140 nbad += out[i].size();
145 if ( partype == MUSEG ) {
147 jet.setAssociatedObjects(pli->
label(i) , outms[i]);
148 jet.setAttribute<
int>(cname, outms[i].size());
149 }
else if ( partype == IPART ) {
151 jet.setAssociatedObjects(pli->
label(i), out[i]);
152 jet.setAttribute<
int>(cname, out[i].size());
153 jet.setAttribute<
float>(ptname, ptout[i]);
154 if ( ! outms[i].
empty() )
return -9;
172 const fastjet::PseudoJet* jet_pj =
nullptr;
177 if(jet_pj && !ignoreGhosts ){
178 constituents = jet_pj->constituents();
187 if(jet_pj && requireJetStructure){
191 constituents.reserve(
jet.numConstituents() );
192 for(
size_t i = 0; i < constituents_all.size(); i++){
193 for(
size_t j = 0; j < constituents_tmp.
size(); j++){
194 if(std::abs((constituents_all[i].px()-constituents_tmp[j].Px())/constituents_tmp[j].Px()) < 0.0001 &&
195 std::abs((constituents_all[i].py()-constituents_tmp[j].Py())/constituents_tmp[j].Py()) < 0.0001 &&
196 std::abs((constituents_all[i].pz()-constituents_tmp[j].Pz())/constituents_tmp[j].Pz()) < 0.0001){
197 constituents.push_back(constituents_all[i]);
205 constituents.reserve(
jet.numConstituents() );
206 for(
size_t i = 0; i < constituents_tmp.
size(); i++){
207 constituents.emplace_back( constituents_tmp[i].Px(), constituents_tmp[i].Py(), constituents_tmp[i].Pz(), constituents_tmp[i].E() );
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
IndexedConstituentUserInfo::Label Label
IndexedTConstituentUserInfo< MuonSegment > MuonSegmentCUI
std::vector< ParType > ParTypeVector
std::vector< const MuonSegment * > MuonSegmentVector
std::vector< ParticleVector > ParticleMap
std::vector< fastjet::PseudoJet > PseudoJetVector
std::vector< const IParticle * > ParticleVector
std::vector< double > PtMap
std::vector< MuonSegmentVector > MuonSegmentMap
static const Attributes_t empty
int extractConstituents(xAOD::Jet &jet, const NameList *pghostlabs, const fastjet::PseudoJet *ppj=0)
Build and fill constituents of jet from its PseudoJet (or from ppj) Returns the number of pseudojet c...
SG::ConstAccessor< T, ALLOC > ConstAccessor
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
virtual const LabelIndex * labelMap() const
virtual xAOD::JetConstitScale constitScale() const
Return the constituent scale used to build the PseudoJet.
virtual Label label() const =0
virtual bool isGhost() const
Returns true if this constituent is a ghost.
virtual const xAOD::IParticle * particle() const =0
virtual Index index() const
int extractConstituents(xAOD::Jet &jet, const NameList *pghostlabs, const fastjet::PseudoJet *ppj=0)
Build and fill constituents of jet from its PseudoJet (or from ppj) Returns the number of pseudojet c...
std::vector< std::string > NameList
static PseudoJetVector constituentPseudoJets(const xAOD::Jet &jet, bool ignoreGhosts=true, bool requireJetStructure=false)
Returns the jet's constituents as a vector of PseudoJet if ignoreGhosts==true, ghost constituents are...
Index size() const
Number of label stored in this map. WARNING the index starts at 1, so range is [1....
Label label(Index idx) const
Fetch the label for an index.
Class providing the definition of the 4-vector interface.
A vector of jet constituents at the scale used during jet finding.
size_t size() const
number of constituents
std::string find(const std::string &s)
return a remapped string
std::vector< fastjet::PseudoJet > PseudoJetVector
Jet_v1 Jet
Definition of the current "jet version".
MuonSegment_v1 MuonSegment
Reference the current persistent version: