20 vector<fastjet::PseudoJet> & hardjetsOutput,
21 boost::shared_ptr<fastjet::ClusterSequence> & fjClusterSeq
24 if ( verbose_ )
cout <<
"Welcome to CATopSubJetAlgorithm::run" << endl;
31 for (
unsigned i = 0;
i < cell_particles.size(); ++
i) {
32 sumEt += cell_particles[
i].perp();
37 for (
unsigned int i = 0;
i < sumEtBins_.size(); ++
i ) {
38 if ( sumEt > sumEtBins_[
i] ) sumEtBinId =
i;
40 if ( verbose_ )
cout <<
"Using sumEt = " << sumEt <<
", bin = " << sumEtBinId << endl;
43 if ( sumEtBinId < 0 ) {
48 fastjet::PseudoJet blankJetA(0,0,0,0);
49 blankJetA.set_user_index(-1);
50 const fastjet::PseudoJet blankJet = blankJetA;
53 double deltarcut = deltarBins_[sumEtBinId];
54 double nCellMin = nCellBins_[sumEtBinId];
56 if ( verbose_ )
cout<<
"useAdjacency_ = "<<useAdjacency_<<endl;
57 if ( verbose_ && useAdjacency_==0)
cout<<
"No Adjacency"<<endl;
58 if ( verbose_ && useAdjacency_==1)
cout<<
"using deltar adjacency"<<endl;
59 if ( verbose_ && useAdjacency_==2)
cout<<
"using modified adjacency"<<endl;
60 if ( verbose_ && useAdjacency_==3)
cout<<
"using calorimeter nearest neighbor based adjacency"<<endl;
61 if ( verbose_ && useAdjacency_==1)
cout <<
"Using deltarcut = " << deltarcut << endl;
62 if ( verbose_ && useAdjacency_==3)
cout <<
"Using nCellMin = " << nCellMin << endl;
64 if ( verbose_ )
cout <<
"About to do jet clustering in CA" << endl;
78 if ( verbose_ )
cout <<
"Getting inclusive jets" << endl;
80 vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq->inclusive_jets(ptMin_);
82 if ( verbose_ )
cout <<
"Getting central jets" << endl;
84 vector<fastjet::PseudoJet> centralJets;
85 for (
unsigned int i = 0;
i < inclusiveJets.size();
i++) {
87 if (inclusiveJets[
i].
perp() > ptMin_ && fabs(inclusiveJets[
i].rapidity()) < centralEtaCut_) {
88 centralJets.push_back(inclusiveJets[
i]);
95 vector<math::XYZTLorentzVector> p4_hardJets;
99 vector<vector<int> > indices( centralJets.size() );
102 vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(),
103 centralJetsEnd = centralJets.end();
104 if ( verbose_ )
cout<<
"Loop over jets"<<endl;
106 for ( ; jetIt != centralJetsEnd; ++jetIt ) {
107 if ( verbose_ )
cout<<
"\nJet "<<i<<endl;
109 fastjet::PseudoJet localJet = *jetIt;
115 if ( verbose_ )
cout<<
"local jet pt = "<<localJet.perp()<<endl;
116 if ( verbose_ )
cout<<
"deltap = "<<ptFracBins_[sumEtBinId]<<endl;
118 double ptHard = ptFracBins_[sumEtBinId]*localJet.perp();
119 vector<fastjet::PseudoJet> leftoversAll;
122 if ( verbose_ )
cout <<
"Doing decomposition 1" << endl;
123 fastjet::PseudoJet ja, jb;
124 vector<fastjet::PseudoJet> leftovers1;
125 bool hardBreak1 = decomposeJet(localJet,*fjClusterSeq,cell_particles,ptHard,nCellMin,deltarcut,ja,jb,leftovers1);
126 leftoversAll.insert(leftoversAll.end(),leftovers1.begin(),leftovers1.end());
131 if ( verbose_ )
cout <<
"Doing decomposition 2. ja->jaa+jab?" << endl;
132 fastjet::PseudoJet jaa, jab;
133 vector<fastjet::PseudoJet> leftovers2a;
134 bool hardBreak2a =
false;
135 if (hardBreak1) hardBreak2a = decomposeJet(ja,*fjClusterSeq,cell_particles,ptHard,nCellMin,deltarcut,jaa,jab,leftovers2a);
136 leftoversAll.insert(leftoversAll.end(),leftovers2a.begin(),leftovers2a.end());
138 if ( verbose_ )
cout <<
"Doing decomposition 2. ja->jba+jbb?" << endl;
139 fastjet::PseudoJet jba, jbb;
140 vector<fastjet::PseudoJet> leftovers2b;
141 bool hardBreak2b =
false;
142 if (hardBreak1) hardBreak2b = decomposeJet(jb,*fjClusterSeq,cell_particles,ptHard,nCellMin,deltarcut,jba,jbb,leftovers2b);
143 leftoversAll.insert(leftoversAll.end(),leftovers2b.begin(),leftovers2b.end());
150 if ( verbose_ )
cout <<
"Done with decomposition" << endl;
152 if ( verbose_ )
cout<<
"hardBreak1 = "<<hardBreak1<<endl;
153 if ( verbose_ )
cout<<
"hardBreak2a = "<<hardBreak2a<<endl;
154 if ( verbose_ )
cout<<
"hardBreak2b = "<<hardBreak2b<<endl;
156 fastjet::PseudoJet hardA = blankJet, hardB = blankJet, hardC = blankJet, hardD = blankJet;
162 if(verbose_)
cout<<
"Hardbreak failed. Save subjet1=localJet"<<endl;
164 if (hardBreak1 && !hardBreak2a && !hardBreak2b) {
169 if(verbose_)
cout<<
"First decomposition succeeded, both second decompositions failed. Save subjet1=ja subjet2=jb"<<endl;
171 if (hardBreak1 && hardBreak2a && !hardBreak2b) {
176 if(verbose_)
cout<<
"First decomposition succeeded, ja split succesfully, jb did not split. Save subjet1=jaa subjet2=jab subjet3=jb"<<endl;
178 if (hardBreak1 && !hardBreak2a && hardBreak2b) {
183 if(verbose_)
cout<<
"First decomposition succeeded, jb split succesfully, ja did not split. Save subjet1=jba subjet2=jbb subjet3=ja"<<endl;
185 if (hardBreak1 && hardBreak2a && hardBreak2b) {
190 if(verbose_)
cout<<
"First decomposition and both secondary decompositions succeeded. Save subjet1=jaa subjet2=jab subjet3=jba subjet4=jbb"<<endl;
194 fastjet::PseudoJet subjet1 = blankJet;
195 fastjet::PseudoJet subjet2 = blankJet;
196 fastjet::PseudoJet subjet3 = blankJet;
197 fastjet::PseudoJet subjet4 = blankJet;
198 subjet1 = hardA; subjet2 = hardB; subjet3 = hardC; subjet4 = hardD;
201 vector<fastjet::PseudoJet> hardSubjets;
204 std::cout <<
"HardA : user_index = " << hardA.user_index() <<
", (Pt,Y,Phi,M) = (" 205 << hardA.pt() <<
", " << hardA.rapidity() <<
", " 206 << hardA.phi() <<
", " << hardA.m() <<
")" << std::endl;
208 std::cout <<
"HardB : user_index = " << hardB.user_index() <<
", (Pt,Y,Phi,M) = (" 209 << hardB.pt() <<
", " << hardB.rapidity() <<
", " 210 << hardB.phi() <<
", " << hardB.m() <<
")" << std::endl;
212 std::cout <<
"HardC : user_index = " << hardC.user_index() <<
", (Pt,Y,Phi,M) = (" 213 << hardC.pt() <<
", " << hardC.rapidity() <<
", " 214 << hardC.phi() <<
", " << hardC.m() <<
")" << std::endl;
216 std::cout <<
"HardD : user_index = " << hardD.user_index() <<
", (Pt,Y,Phi,M) = (" 217 << hardD.pt() <<
", " << hardD.rapidity() <<
", " 218 << hardD.phi() <<
", " << hardD.m() <<
")" << std::endl;
225 if ( subjet1.pt() > 0.0001 )
226 hardSubjets.push_back(subjet1);
227 if ( subjet2.pt() > 0.0001 )
228 hardSubjets.push_back(subjet2);
229 if ( subjet3.pt() > 0.0001 )
230 hardSubjets.push_back(subjet3);
231 if ( subjet4.pt() > 0.0001 )
232 hardSubjets.push_back(subjet4);
236 fastjet::PseudoJet candidate =
join(hardSubjets);
238 candidate.reset_momentum( jetIt->px(), jetIt->py(), jetIt->pz(), jetIt->e() );
241 std::cout <<
"Final top-jet candidate: (Pt,Y,Phi,M) = (" 242 << candidate.pt() <<
", " << candidate.rapidity() <<
", " 243 << candidate.phi() <<
", " << candidate.m() <<
")" << std::endl;
244 std::vector<fastjet::PseudoJet>
pieces = candidate.pieces();
245 std::cout <<
"Number of pieces = " << pieces.size() << std::endl;
246 for ( std::vector<fastjet::PseudoJet>::const_iterator ibegin = pieces.begin(), iend = pieces.end(), i = ibegin;
248 std::cout <<
" Piece : " << i - ibegin <<
", (Pt,Y,Phi,M) = (" 249 << i->pt() <<
", " << i->rapidity() <<
", " 250 << i->phi() <<
", " << i->m() <<
")" << std::endl;
254 hardjetsOutput.push_back( candidate );
268 const vector<fastjet::PseudoJet> & cell_particles,
269 const fastjet::ClusterSequence & theClusterSequence,
270 double nCellMin )
const {
273 double eta1 = jet1.rapidity();
274 double phi1 = jet1.phi();
275 double eta2 = jet2.rapidity();
276 double phi2 = jet2.phi();
278 double deta =
abs(eta2 - eta1) / 0.087;
281 return ( ( deta + dphi ) <= nCellMin );
290 const fastjet::ClusterSequence & theClusterSequence,
291 const vector<fastjet::PseudoJet> & cell_particles,
292 double ptHard,
double nCellMin,
double deltarcut,
293 fastjet::PseudoJet & ja, fastjet::PseudoJet & jb,
294 vector<fastjet::PseudoJet> & leftovers)
const {
297 fastjet::PseudoJet j = theJet;
298 double InputObjectPt = j.perp();
299 if ( verbose_ )
cout<<
"Input Object Pt = "<<InputObjectPt<<endl;
300 if ( verbose_ )
cout<<
"ptHard = "<<ptHard<<endl;
302 if ( verbose_ )
cout<<
"start while loop"<<endl;
305 goodBreak = theClusterSequence.has_parents(j,ja,jb);
307 if ( verbose_ )
cout<<
"bad break. this is one cell. can't decluster anymore."<<endl;
311 if ( verbose_ )
cout<<
"good break. ja Pt = "<<ja.perp()<<
" jb Pt = "<<jb.perp()<<endl;
316 double clusters_deltar=fabs(ja.eta()-jb.eta())+fabs(
deltaPhi(ja.phi(),jb.phi()));
318 if ( verbose_ && useAdjacency_ ==1)
cout<<
"clusters_deltar = "<<clusters_deltar<<endl;
319 if ( verbose_ && useAdjacency_ ==1)
cout<<
"deltar cut = "<<deltarcut<<endl;
321 if ( useAdjacency_==1 && clusters_deltar < deltarcut){
322 if ( verbose_ )
cout<<
"clusters too close. consant adj. break."<<endl;
327 double clusters_deltaR=
deltaR( ja.rapidity(), ja.phi(), jb.rapidity(), jb.phi() );
329 if ( verbose_ && useAdjacency_ ==2)
cout<<
"clusters_deltaR = "<<clusters_deltaR<<endl;
330 if ( verbose_ && useAdjacency_ ==2)
cout<<
"0.4-0.0004*InputObjectPt = "<<0.4-0.0004*InputObjectPt<<endl;
332 if ( useAdjacency_==2 && clusters_deltaR < 0.4-0.0004*InputObjectPt)
334 if ( verbose_ )
cout<<
"clusters too close. modified adj. break."<<endl;
339 if ( useAdjacency_==3 && adjacentCells(ja,jb,cell_particles,theClusterSequence,nCellMin) ){
340 if ( verbose_ )
cout<<
"clusters too close in the calorimeter. calorimeter adj. break."<<endl;
344 if ( verbose_ )
cout<<
"clusters pass distance cut"<<endl;
348 if ( verbose_ )
cout<<
"ptHard = "<<ptHard<<endl;
350 if (ja.perp() < ptHard && jb.perp() < ptHard){
351 if ( verbose_ )
cout<<
"two soft clusters. dead end"<<endl;
355 if (ja.perp() > ptHard && jb.perp() > ptHard){
356 if ( verbose_ )
cout<<
"two hard clusters. done"<<endl;
360 else if (ja.perp() > jb.perp()) {
361 if ( verbose_ )
cout<<
"ja hard jb soft. try to split hard. j = ja"<<endl;
363 vector<fastjet::PseudoJet>
particles = theClusterSequence.constituents(jb);
364 leftovers.insert(leftovers.end(),particles.begin(),particles.end());
367 if ( verbose_ )
cout<<
"ja hard jb soft. try to split hard. j = jb"<<endl;
369 vector<fastjet::PseudoJet>
particles = theClusterSequence.constituents(ja);
370 leftovers.insert(leftovers.end(),particles.begin(),particles.end());
374 if ( verbose_ )
cout<<
"did not decluster."<<endl;
constexpr double deltaPhi(double phi1, double phi2)
bool greaterByEtPseudoJet(fastjet::PseudoJet const &j1, fastjet::PseudoJet const &j2)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
bool adjacentCells(const fastjet::PseudoJet &jet1, const fastjet::PseudoJet &jet2, const std::vector< fastjet::PseudoJet > &cell_particles, const fastjet::ClusterSequence &theClusterSequence, double nCellMin) const
bool decomposeJet(const fastjet::PseudoJet &theJet, const fastjet::ClusterSequence &theClusterSequence, const std::vector< fastjet::PseudoJet > &cell_particles, double ptHard, double nCellMin, double deltarcut, fastjet::PseudoJet &ja, fastjet::PseudoJet &jb, std::vector< fastjet::PseudoJet > &leftovers) const
Abs< T >::type abs(const T &t)
static std::string join(char **cmd)
T perp() const
Magnitude of transverse component.
void run(const std::vector< fastjet::PseudoJet > &cell_particles, std::vector< fastjet::PseudoJet > &hardjetsOutput, boost::shared_ptr< fastjet::ClusterSequence > &fjClusterSeq)
Find the ProtoJets from the collection of input Candidates.