1 #ifndef D0RunIIconeJets_CONESPLITMERGE
2 #define D0RunIIconeJets_CONESPLITMERGE
61 #include "ProtoJet.hpp"
65 #include <fastjet/internal/base.hh>
67 FASTJET_BEGIN_NAMESPACE
74 class ProtoJet_ET_seedET_order
77 bool operator()(
const ProtoJet<Item> & first,
const ProtoJet<Item> & second)
const
79 if ( first.pT() > second.pT() )
return true;
81 if ( first.pT() < second.pT() )
return false;
82 else return ( first.info().seedET() > second.info().seedET() );
88 class ConeSplitMerge {
92 typedef std::multimap<ProtoJet<Item>,float,ProtoJet_ET_seedET_order<Item> > PJMMAP;
95 ConeSplitMerge(
const std::vector<ProtoJet<Item> >& jvector);
96 ConeSplitMerge(
const std::list<ProtoJet<Item> >& jlist);
98 void split_merge(std::vector<ProtoJet<Item> >& ecv,
float s,
float pT_min_leading_protojet,
float pT_min_second_protojet,
int MergeMax,
float pT_min_noMergeMax);
105 ConeSplitMerge<Item>::ConeSplitMerge():_members() {;}
108 ConeSplitMerge<Item>::ConeSplitMerge(
const std::vector<ProtoJet<Item> >& jvector)
111 typename std::vector<ProtoJet<Item> >::const_iterator jt;
112 for(jt = jvector.begin(); jt != jvector.end(); ++jt)
115 ProtoJet<Item> jet(*jt);
117 _members.insert(std::make_pair(jet,jet.pT()));
122 ConeSplitMerge<Item>::ConeSplitMerge(
const std::list<ProtoJet<Item> >& jlist)
126 typename std::list<ProtoJet<Item> >::const_iterator jt;
127 for(jt = jlist.begin(); jt != jlist.end(); ++jt)
130 ProtoJet<Item> jet(*jt);
132 _members.insert(std::make_pair(jet,jet.pT()));
137 void ConeSplitMerge<Item>::split_merge(std::vector<ProtoJet<Item> >& jcv,
138 float shared_ET_fraction,
139 float pT_min_leading_protojet,
float pT_min_second_protojet,
140 int MergeMax,
float pT_min_noMergeMax)
142 while(!_members.empty())
159 typename PJMMAP::iterator itmax= _members.begin();
160 ProtoJet<Item> imax((*itmax).first);
161 const std::list<const Item*>& ilist(imax.LItems());
163 _members.erase(itmax);
167 float shared_ET = 0.;
168 typename PJMMAP::iterator jtmax;
169 typename PJMMAP::iterator jt;
170 for(jt = _members.begin(); jt != _members.end(); ++jt)
172 const std::list<const Item*>& jlist((*jt).first.LItems());
173 typename std::list<const Item*>::const_iterator tk;
175 for(tk = ilist.begin(), count = 0; tk != ilist.end();
178 typename std::list<const Item*>::const_iterator where=
179 find(jlist.begin(),jlist.end(),*tk);
180 if(where != jlist.end())
183 shared_ET += (*tk)->pT();
201 ProtoJet<Item> jmax((*jtmax).first);
204 _members.erase(jtmax);
210 if( shared_ET > (jmax.pT())*shared_ET_fraction
211 && (imax.pT() > pT_min_leading_protojet || jmax.pT() > pT_min_second_protojet)
212 && (imax.info().nbMerge() < MergeMax || imax.pT() > pT_min_noMergeMax))
215 const std::list<const Item*>& jlist(jmax.LItems());
216 typename std::list<const Item*>::const_iterator tk;
217 typename std::list<const Item*>::const_iterator iend= ilist.end();
219 for(tk = jlist.begin(); tk != jlist.end(); ++tk)
221 typename std::list<const Item*>::const_iterator where=
222 find(ilist.begin(),iend,*tk);
241 else if(shared_ET > (jmax.pT())*shared_ET_fraction)
244 std::list<const Item*> ilist(imax.LItems());
245 std::list<const Item*> jlist(jmax.LItems());
247 typename std::list<const Item*>::iterator tk;
248 for(tk = jlist.begin(); tk != jlist.end(); )
250 typename std::list<const Item*>::iterator where=
251 find(ilist.begin(),ilist.end(),*tk);
252 if(where != ilist.end()) {
253 tk = jlist.erase(tk);
260 for (
typename std::list<const Item*>::const_iterator it = jlist.begin();
261 it != jlist.end(); ++it) jmax.addItem(*it);
267 _members.insert(std::make_pair(jmax,jmax.pT()));
274 std::list<const Item*> ilist(imax.LItems());
275 std::list<const Item*> jlist(jmax.LItems());
277 typename std::list<const Item*>::iterator tk;
278 for(tk = jlist.begin(); tk != jlist.end(); )
280 typename std::list<const Item*>::iterator where=
281 find(ilist.begin(),ilist.end(),*tk);
282 if(where != ilist.end()) {
283 float yk = (*tk)->y();
284 float phik = (*tk)->phi();
285 float di= RD2(imax.y(),imax.phi(),yk,phik);
286 float dj= RD2(jmax.y(),jmax.phi(),yk,phik);
289 tk = jlist.erase(tk);
306 for (
typename std::list<const Item*>::const_iterator it = ilist.begin();
307 it != ilist.end(); ++it) imax.addItem(*it);
317 for (
typename std::list<const Item*>::const_iterator it = jlist.begin();
318 it != jlist.end(); ++it) jmax.addItem(*it);
324 _members.insert(std::make_pair(jmax,jmax.pT()));
326 _members.insert(std::make_pair(imax,imax.pT()));
334 FASTJET_END_NAMESPACE