12 #include "fastjet/PseudoJet.hh"
19 using fastjet::PseudoJet;
26 const std::vector<PseudoJet> & vecPJ,
42 vecPJ.back().user_index(),
49 const std::vector<PseudoJet>& inConstits)
const
56 std::map<const IConstituentExtractor*, std::vector<int>>
sorter;
64 sorter.emplace(er.m_e.get(), std::vector<int>{});
69 sorter.emplace(
e.get(), std::vector<int>{});
75 for (
const auto& pj : inConstits){
77 int pj_ind = pj.user_index();
81 if (pj_ind == -1) {
continue;}
91 return pj_ind >= r.m_lo and pj_ind <= r.m_hi;});
95 sorter[(*e).m_e.get()].push_back(pj_ind - (*e).m_lo);
100 for(
const auto&
s :
sorter){
s.first -> addToJet(
jet,
s.second);}
109 std::vector<PseudoJet> inConstituents = finalPJ.constituents();
115 std::vector<PseudoJet> allInConstituents = finalPJ.constituents();
116 std::vector<PseudoJet> byVertexConstituents;
117 for (
PseudoJet& constituent: allInConstituents){
123 if (originVertex ==
vertex){
124 byVertexConstituents.emplace_back(constituent);
129 byVertexConstituents.emplace_back(constituent);
152 other->m_extractorRanges.end(),
161 other->m_allConstituents.end(),
163 [
offset](fastjet::PseudoJet pj){
164 pj.set_user_index(pj.user_index() + offset);return pj;}
173 std::ostringstream oss{
"PseudoJetContainer at: ", std::ios::ate};
175 <<
"\ndump levels: "<<
level <<
" " << extLevel <<
'\n'
178 oss <<
"(" << er.m_lo <<
"," <<er.m_hi <<
"), ";
185 oss <<
"\n Extractor dump: \n";
187 oss <<
"Extractor at [" ;
190 oss << er.m_e->toString(extLevel) <<
'\n';
200 std::ostringstream oss{
"PseudoJetContainer at: ", std::ios::ate};
201 oss <<
"\n PseudoJet energies\n";
203 oss <<
"pseudojet user ind " <<
p.user_index()
204 <<
" E " <<
p.e() <<
" " <<
p.eta() <<
'\n';
216 oss(
"PseudoJetContainer checkInvariants called from: ",
222 oss <<
"No extractors, but pseudojets present";
231 if (ex.m_lo < 0 or ex.m_lo > ex.m_hi){
232 oss <<
"bad extractor limits: " << ex.m_lo <<
" " << ex.m_hi;
241 oss <<
" Illegal extractor range limit " << uExtCount;
245 std::size_t uuExtCount = uExtCount;
253 if (npj > uuExtCount + 1){
254 oss <<
" Mismatch between pseudo jet count/upper Extractor limit "
255 << npj <<
"/" << uuExtCount;
263 oss <<
" first pseudojet does not have index 0 " << firstInd;
269 for (std::size_t
i = 0;
i < nent-1; ++
i){
272 if (
cur.m_hi !=
next.m_lo - 1){
273 oss <<
"Hi limit for extractor " <<
i
274 <<
" != low limit for extractor " <<
i+1;
287 oss <<
"PseudoJet.e() fails of PJ in m_allConstituents";
293 if (!((er.m_e)->checkIntegrity())){
294 oss <<
"IConstituentExtractor fails integrity test";
306 const std::string& from)
const{
316 oss(
"PseudoJetContainer checkPseudoJetVector called from: ",
321 oss <<
"Empty pseudojet vector " ;
325 oss <<
"PseudoJetVector energy dump:\n";
326 std::vector<float> energies;
327 energies.reserve(
v.size());
330 std::back_inserter(energies),
338 if (
v[0].user_index() < 0){
340 oss <<
"First pj has index < 0: " <<
v[0].user_index();
347 [](
const PseudoJet &
p){return p.user_index();});
350 oss <<
"Pseudojets out of order ";
354 if(ok){oss <<
v.size() <<
" checked ok";}
361 const std::string& from)
const {
366 oss(
"PseudoJetContainer checkInConstituents called from: ",
369 oss <<
v.size() <<
" entries\n";
371 std::vector<double> energies;
372 energies.reserve(
v.size());
375 std::back_inserter(energies),
382 for(
const auto& pj:
v){
383 if(pj.user_index() == -1){oss <<
"PJ index -1, E() " << pj.E() <<
'\n';}
391 [](
const PseudoJet &
p){return p.user_index();});
393 oss <<
"PseudoJet indices\n";
404 if (
ind == -1){
continue;}
412 oss <<
"Out of range values[counts]: ";
414 for(
auto ent:
counter){oss << ent.first <<
"/" << ent.second <<
'\n';}
415 oss <<
"Extractor ranges: \n";
417 oss << er.m_lo <<
" " << er.m_hi <<
'\n';
430 auto errMsg = oss.str();
433 std::cerr << errMsg <<
'\n';
434 throw std::runtime_error(errMsg);