19 vector<fastjet::PseudoJet>& hardjetsOutput,
20 std::shared_ptr<fastjet::ClusterSequence>& fjClusterSeq) {
22 cout <<
"Welcome to CATopSubJetAlgorithm::run" << endl;
29 for (
unsigned i = 0;
i < cell_particles.size(); ++
i) {
30 sumEt += cell_particles[
i].perp();
35 for (
unsigned int i = 0;
i < sumEtBins_.size(); ++
i) {
36 if (sumEt > sumEtBins_[
i])
40 cout <<
"Using sumEt = " << sumEt <<
", bin = " << sumEtBinId << endl;
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];
57 cout <<
"useAdjacency_ = " << useAdjacency_ << endl;
58 if (verbose_ && useAdjacency_ == 0)
59 cout <<
"No Adjacency" << endl;
60 if (verbose_ && useAdjacency_ == 1)
61 cout <<
"using deltar adjacency" << endl;
62 if (verbose_ && useAdjacency_ == 2)
63 cout <<
"using modified adjacency" << endl;
64 if (verbose_ && useAdjacency_ == 3)
65 cout <<
"using calorimeter nearest neighbor based adjacency" << endl;
66 if (verbose_ && useAdjacency_ == 1)
67 cout <<
"Using deltarcut = " << deltarcut << endl;
68 if (verbose_ && useAdjacency_ == 3)
69 cout <<
"Using nCellMin = " << nCellMin << endl;
72 cout <<
"About to do jet clustering in CA" << endl;
87 cout <<
"Getting inclusive jets" << endl;
89 vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq->inclusive_jets(
ptMin_);
92 cout <<
"Getting central jets" << endl;
94 vector<fastjet::PseudoJet> centralJets;
95 for (
unsigned int i = 0;
i < inclusiveJets.size();
i++) {
96 if (inclusiveJets[
i].
perp() >
ptMin_ && fabs(inclusiveJets[
i].rapidity()) < centralEtaCut_) {
97 centralJets.push_back(inclusiveJets[
i]);
104 vector<math::XYZTLorentzVector> p4_hardJets;
108 vector<vector<int> >
indices(centralJets.size());
111 vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(), centralJetsEnd = centralJets.end();
113 cout <<
"Loop over jets" << endl;
115 for (; jetIt != centralJetsEnd; ++jetIt) {
117 cout <<
"\nJet " << i << endl;
119 fastjet::PseudoJet localJet = *jetIt;
126 cout <<
"local jet pt = " << localJet.perp() << endl;
128 cout <<
"deltap = " << ptFracBins_[sumEtBinId] << endl;
130 double ptHard = ptFracBins_[sumEtBinId] * localJet.perp();
131 vector<fastjet::PseudoJet> leftoversAll;
135 cout <<
"Doing decomposition 1" << endl;
136 fastjet::PseudoJet ja, jb;
137 vector<fastjet::PseudoJet> leftovers1;
139 decomposeJet(localJet, *fjClusterSeq, cell_particles, ptHard, nCellMin, deltarcut, ja, jb, leftovers1);
140 leftoversAll.insert(leftoversAll.end(), leftovers1.begin(), leftovers1.end());
146 cout <<
"Doing decomposition 2. ja->jaa+jab?" << endl;
147 fastjet::PseudoJet jaa, jab;
148 vector<fastjet::PseudoJet> leftovers2a;
149 bool hardBreak2a =
false;
151 hardBreak2a = decomposeJet(ja, *fjClusterSeq, cell_particles, ptHard, nCellMin, deltarcut, jaa, jab, leftovers2a);
152 leftoversAll.insert(leftoversAll.end(), leftovers2a.begin(), leftovers2a.end());
155 cout <<
"Doing decomposition 2. ja->jba+jbb?" << endl;
156 fastjet::PseudoJet jba, jbb;
157 vector<fastjet::PseudoJet> leftovers2b;
158 bool hardBreak2b =
false;
160 hardBreak2b = decomposeJet(jb, *fjClusterSeq, cell_particles, ptHard, nCellMin, deltarcut, jba, jbb, leftovers2b);
161 leftoversAll.insert(leftoversAll.end(), leftovers2b.begin(), leftovers2b.end());
169 cout <<
"Done with decomposition" << endl;
172 cout <<
"hardBreak1 = " << hardBreak1 << endl;
174 cout <<
"hardBreak2a = " << hardBreak2a << endl;
176 cout <<
"hardBreak2b = " << hardBreak2b << endl;
178 fastjet::PseudoJet hardA = blankJet, hardB = blankJet, hardC = blankJet, hardD = blankJet;
185 cout <<
"Hardbreak failed. Save subjet1=localJet" << endl;
187 if (hardBreak1 && !hardBreak2a && !hardBreak2b) {
193 cout <<
"First decomposition succeeded, both second decompositions failed. Save subjet1=ja subjet2=jb" << endl;
195 if (hardBreak1 && hardBreak2a && !hardBreak2b) {
201 cout <<
"First decomposition succeeded, ja split succesfully, jb did not split. Save subjet1=jaa subjet2=jab "
205 if (hardBreak1 && !hardBreak2a && hardBreak2b) {
211 cout <<
"First decomposition succeeded, jb split succesfully, ja did not split. Save subjet1=jba subjet2=jbb "
215 if (hardBreak1 && hardBreak2a && hardBreak2b) {
221 cout <<
"First decomposition and both secondary decompositions succeeded. Save subjet1=jaa subjet2=jab "
222 "subjet3=jba subjet4=jbb"
227 fastjet::PseudoJet subjet1 = blankJet;
228 fastjet::PseudoJet subjet2 = blankJet;
229 fastjet::PseudoJet subjet3 = blankJet;
230 fastjet::PseudoJet subjet4 = blankJet;
237 vector<fastjet::PseudoJet> hardSubjets;
240 std::cout <<
"HardA : user_index = " << hardA.user_index() <<
", (Pt,Y,Phi,M) = (" << hardA.pt() <<
", "
241 << hardA.rapidity() <<
", " << hardA.phi() <<
", " << hardA.m() <<
")" << std::endl;
243 std::cout <<
"HardB : user_index = " << hardB.user_index() <<
", (Pt,Y,Phi,M) = (" << hardB.pt() <<
", "
244 << hardB.rapidity() <<
", " << hardB.phi() <<
", " << hardB.m() <<
")" << std::endl;
246 std::cout <<
"HardC : user_index = " << hardC.user_index() <<
", (Pt,Y,Phi,M) = (" << hardC.pt() <<
", "
247 << hardC.rapidity() <<
", " << hardC.phi() <<
", " << hardC.m() <<
")" << std::endl;
249 std::cout <<
"HardD : user_index = " << hardD.user_index() <<
", (Pt,Y,Phi,M) = (" << hardD.pt() <<
", "
250 << hardD.rapidity() <<
", " << hardD.phi() <<
", " << hardD.m() <<
")" << std::endl;
257 if (subjet1.pt() > 0.0001)
258 hardSubjets.push_back(subjet1);
259 if (subjet2.pt() > 0.0001)
260 hardSubjets.push_back(subjet2);
261 if (subjet3.pt() > 0.0001)
262 hardSubjets.push_back(subjet3);
263 if (subjet4.pt() > 0.0001)
264 hardSubjets.push_back(subjet4);
268 fastjet::PseudoJet candidate =
join(hardSubjets);
270 candidate.reset_momentum(jetIt->px(), jetIt->py(), jetIt->pz(), jetIt->e());
273 std::cout <<
"Final top-jet candidate: (Pt,Y,Phi,M) = (" << candidate.pt() <<
", " << candidate.rapidity() <<
", "
274 << candidate.phi() <<
", " << candidate.m() <<
")" << std::endl;
275 std::vector<fastjet::PseudoJet>
pieces = candidate.pieces();
276 std::cout <<
"Number of pieces = " << pieces.size() << std::endl;
277 for (std::vector<fastjet::PseudoJet>::const_iterator ibegin = pieces.begin(), iend = pieces.end(), i = ibegin;
280 std::cout <<
" Piece : " << i - ibegin <<
", (Pt,Y,Phi,M) = (" << i->pt() <<
", " << i->rapidity() <<
", "
281 << i->phi() <<
", " << i->m() <<
")" << std::endl;
285 hardjetsOutput.push_back(candidate);
296 const fastjet::PseudoJet& jet2,
297 const vector<fastjet::PseudoJet>& cell_particles,
298 const fastjet::ClusterSequence& theClusterSequence,
299 double nCellMin)
const {
300 double eta1 = jet1.rapidity();
301 double phi1 = jet1.phi();
302 double eta2 = jet2.rapidity();
303 double phi2 = jet2.phi();
305 double deta =
abs(eta2 - eta1) / 0.087;
308 return ((deta + dphi) <= nCellMin);
315 const fastjet::ClusterSequence& theClusterSequence,
316 const vector<fastjet::PseudoJet>& cell_particles,
320 fastjet::PseudoJet& ja,
321 fastjet::PseudoJet& jb,
322 vector<fastjet::PseudoJet>& leftovers)
const {
324 fastjet::PseudoJet
j = theJet;
325 double InputObjectPt = j.perp();
327 cout <<
"Input Object Pt = " << InputObjectPt << endl;
329 cout <<
"ptHard = " << ptHard << endl;
332 cout <<
"start while loop" << endl;
335 goodBreak = theClusterSequence.has_parents(j, ja, jb);
338 cout <<
"bad break. this is one cell. can't decluster anymore." << endl;
343 cout <<
"good break. ja Pt = " << ja.perp() <<
" jb Pt = " << jb.perp() << endl;
348 double clusters_deltar = fabs(ja.eta() - jb.eta()) + fabs(
deltaPhi(ja.phi(), jb.phi()));
350 if (verbose_ && useAdjacency_ == 1)
351 cout <<
"clusters_deltar = " << clusters_deltar << endl;
352 if (verbose_ && useAdjacency_ == 1)
353 cout <<
"deltar cut = " << deltarcut << endl;
355 if (useAdjacency_ == 1 && clusters_deltar < deltarcut) {
357 cout <<
"clusters too close. consant adj. break." << endl;
362 double clusters_deltaR =
deltaR(ja.rapidity(), ja.phi(), jb.rapidity(), jb.phi());
364 if (verbose_ && useAdjacency_ == 2)
365 cout <<
"clusters_deltaR = " << clusters_deltaR << endl;
366 if (verbose_ && useAdjacency_ == 2)
367 cout <<
"0.4-0.0004*InputObjectPt = " << 0.4 - 0.0004 * InputObjectPt << endl;
369 if (useAdjacency_ == 2 && clusters_deltaR < 0.4 - 0.0004 * InputObjectPt) {
371 cout <<
"clusters too close. modified adj. break." << endl;
376 if (useAdjacency_ == 3 && adjacentCells(ja, jb, cell_particles, theClusterSequence, nCellMin)) {
378 cout <<
"clusters too close in the calorimeter. calorimeter adj. break." << endl;
383 cout <<
"clusters pass distance cut" << endl;
388 cout <<
"ptHard = " << ptHard << endl;
390 if (ja.perp() < ptHard && jb.perp() < ptHard) {
392 cout <<
"two soft clusters. dead end" << endl;
396 if (ja.perp() > ptHard && jb.perp() > ptHard) {
398 cout <<
"two hard clusters. done" << endl;
402 else if (ja.perp() > jb.perp()) {
404 cout <<
"ja hard jb soft. try to split hard. j = ja" << endl;
406 vector<fastjet::PseudoJet> particles = theClusterSequence.constituents(jb);
407 leftovers.insert(leftovers.end(), particles.begin(), particles.end());
410 cout <<
"ja hard jb soft. try to split hard. j = jb" << endl;
412 vector<fastjet::PseudoJet> particles = theClusterSequence.constituents(ja);
413 leftovers.insert(leftovers.end(), particles.begin(), particles.end());
418 cout <<
"did not decluster." << endl;
420 ja.reset(0, 0, 0, 0);
421 jb.reset(0, 0, 0, 0);
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.
ptMin_(conf.getParameter< double >("ptMin"))
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)
void run(const std::vector< fastjet::PseudoJet > &cell_particles, std::vector< fastjet::PseudoJet > &hardjetsOutput, std::shared_ptr< fastjet::ClusterSequence > &fjClusterSeq)
Find the ProtoJets from the collection of input Candidates.
static std::string join(char **cmd)
T perp() const
Magnitude of transverse component.