11using fastjet::PseudoJet;
22 struct ConstitPtComp {
24 return ptAcc(*j1) > ptAcc(*j2) ;
39 if (
j1->numConstituents() !=
j2->numConstituents() )
return 1;
40 if (
j1->numConstituents() == 0 )
return 2;
42 for(
size_t i=0;
i<
j1->numConstituents();
i++){
43 if(!hasConstituent(j2,
j1->rawConstituent(i)))
return 100+
i;
48 if (
j1->rawConstituent(0) ==
j2->rawConstituent(0))
return 0;
67 if ( !
m_hpjr.retrieve().isSuccess() ) {
69 return StatusCode::FAILURE;
71 return StatusCode::SUCCESS;
79 if ( !
m_hpjr.retrieve().isSuccess() ) {
91 if ( !
evtStore()->retrieve(ppjmap, pjmapname).isSuccess() ) {
104 std::list<const Jet*> sortedTarget(dstjets.
begin(), dstjets.
end());
105 sortedTarget.sort(ConstitPtComp());
106 std::list<const Jet*> sortedSource(srcjets.
begin(), srcjets.
end());
107 sortedSource.sort(ConstitPtComp());
109 size_t sourceIndex=0;
111 for (
auto sourceIt = sortedSource.begin(); sourceIt!=sortedSource.end(); ++sourceIt ) {
112 const Jet* pjetin = *sourceIt;
113 if ( pjetin ==
nullptr ) {
117 ATH_MSG_DEBUG(
" Checking jet " << sourceIndex <<
" pt=" << ptAcc(*pjetin) );
120 sortedTarget.remove_if([](
const Jet * pJetOut){
return pJetOut ==
nullptr;});
122 for (
auto targetIt=sortedTarget.begin(); targetIt!=sortedTarget.end(); ++targetIt ) {
123 const Jet* pjetout = *targetIt;
124 int jetdiff = differentJets(pjetin, pjetout);
125 bool isSame = jetdiff == 0;
126 ATH_MSG_DEBUG(
" vs pt="<<ptAcc(*pjetout) <<
" jetdiff= " << jetdiff );
128 ATH_MSG_DEBUG(
" -------> identical to pt="<< ptAcc(*pjetout));
129 const PseudoJet* ppj =
m_hpjr->pseudojet(*pjetin);
130 ATH_MSG_VERBOSE(
"Recording pseudojet " <<
long(ppj) <<
" for jet " <<
long(pjetout)
131 <<
" in map " << pjmapname);
132 pjmap[pjetout] = ppj;
134 sortedTarget.erase(targetIt);
137 ATH_MSG_VERBOSE(
"No match found for destination jet " <<
long(pjetout));
140 auto targetIt = sortedTarget.begin();
142 if ( targetIt == sortedTarget.end() )
break;
152copy(
const JetContainer& srcjets,
const std::string& dstname,
const std::string& pjmapname)
const {
154 if ( !
evtStore()->retrieve(pdstjets, dstname).isSuccess() ) {
158 return copy(srcjets, *pdstjets, pjmapname);
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ServiceHandle< StoreGateSvc > & evtStore()
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
int copy(const xAOD::JetContainer &srcjets, const xAOD::JetContainer &dstjets, const std::string &label="PseudojetMap") const
Copy pseudojets from srcjets to dstjets.
JetPseudojetCopier(const std::string &myname)
Ctor from tool name.
StatusCode initialize()
Intialization.
std::string m_dstname
Properties.
ToolHandle< IJetPseudojetRetriever > m_hpjr
int process(const xAOD::JetContainer &srcjets) const
Copy the pseudojets from srcjets to dstjets.
SG::Accessor< T, ALLOC > Accessor
Class providing the definition of the 4-vector interface.
size_t numConstituents() const
Number of constituents in this jets (this is valid even when reading a file where the constituents ha...
const IParticle * rawConstituent(size_t i) const
Direct access to constituents. WARNING expert use only.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
std::map< const xAOD::Jet *, const fastjet::PseudoJet * > PseudoJetMap
Jet_v1 Jet
Definition of the current "jet version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".