21 vector<fastjet::PseudoJet> & hardjetsOutput,
22 boost::shared_ptr<fastjet::ClusterSequence> & fjClusterSeq
25 if ( verbose_ )
cout <<
"Welcome to CATopSubJetAlgorithm::run" << endl;
32 for (
unsigned i = 0;
i < cell_particles.size(); ++
i) {
33 sumEt += cell_particles[
i].perp();
38 for (
unsigned int i = 0;
i < sumEtBins_.size(); ++
i ) {
39 if ( sumEt > sumEtBins_[
i] ) sumEtBinId =
i;
41 if ( verbose_ )
cout <<
"Using sumEt = " << sumEt <<
", bin = " << sumEtBinId << endl;
44 if ( sumEtBinId < 0 ) {
49 fastjet::PseudoJet blankJetA(0,0,0,0);
50 blankJetA.set_user_index(-1);
51 const fastjet::PseudoJet blankJet = blankJetA;
54 double deltarcut = deltarBins_[sumEtBinId];
55 double nCellMin = nCellBins_[sumEtBinId];
57 if ( verbose_ )
cout<<
"useAdjacency_ = "<<useAdjacency_<<endl;
58 if ( verbose_ && useAdjacency_==0)
cout<<
"No Adjacency"<<endl;
59 if ( verbose_ && useAdjacency_==1)
cout<<
"using deltar adjacency"<<endl;
60 if ( verbose_ && useAdjacency_==2)
cout<<
"using modified adjacency"<<endl;
61 if ( verbose_ && useAdjacency_==3)
cout<<
"using calorimeter nearest neighbor based adjacency"<<endl;
62 if ( verbose_ && useAdjacency_==1)
cout <<
"Using deltarcut = " << deltarcut << endl;
63 if ( verbose_ && useAdjacency_==3)
cout <<
"Using nCellMin = " << nCellMin << endl;
65 if ( verbose_ )
cout <<
"About to do jet clustering in CA" << endl;
79 if ( verbose_ )
cout <<
"Getting inclusive jets" << endl;
81 vector<fastjet::PseudoJet> inclusiveJets = fjClusterSeq->inclusive_jets(ptMin_);
83 if ( verbose_ )
cout <<
"Getting central jets" << endl;
85 vector<fastjet::PseudoJet> centralJets;
86 for (
unsigned int i = 0;
i < inclusiveJets.size();
i++) {
88 if (inclusiveJets[
i].
perp() > ptMin_ && fabs(inclusiveJets[
i].rapidity()) < centralEtaCut_) {
89 centralJets.push_back(inclusiveJets[
i]);
94 sort( centralJets.begin(), centralJets.end(), compEt );
97 vector<math::XYZTLorentzVector> p4_hardJets;
101 vector<vector<int> >
indices( centralJets.size() );
104 vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(),
105 centralJetsEnd = centralJets.end();
106 if ( verbose_ )
cout<<
"Loop over jets"<<endl;
108 for ( ; jetIt != centralJetsEnd; ++jetIt ) {
109 if ( verbose_ )
cout<<
"\nJet "<<i<<endl;
111 fastjet::PseudoJet localJet = *jetIt;
117 if ( verbose_ )
cout<<
"local jet pt = "<<localJet.perp()<<endl;
118 if ( verbose_ )
cout<<
"deltap = "<<ptFracBins_[sumEtBinId]<<endl;
120 double ptHard = ptFracBins_[sumEtBinId]*localJet.perp();
121 vector<fastjet::PseudoJet> leftoversAll;
124 if ( verbose_ )
cout <<
"Doing decomposition 1" << endl;
125 fastjet::PseudoJet ja, jb;
126 vector<fastjet::PseudoJet> leftovers1;
127 bool hardBreak1 = decomposeJet(localJet,*fjClusterSeq,cell_particles,ptHard,nCellMin,deltarcut,ja,jb,leftovers1);
128 leftoversAll.insert(leftoversAll.end(),leftovers1.begin(),leftovers1.end());
133 if ( verbose_ )
cout <<
"Doing decomposition 2. ja->jaa+jab?" << endl;
134 fastjet::PseudoJet jaa, jab;
135 vector<fastjet::PseudoJet> leftovers2a;
136 bool hardBreak2a =
false;
137 if (hardBreak1) hardBreak2a = decomposeJet(ja,*fjClusterSeq,cell_particles,ptHard,nCellMin,deltarcut,jaa,jab,leftovers2a);
138 leftoversAll.insert(leftoversAll.end(),leftovers2a.begin(),leftovers2a.end());
140 if ( verbose_ )
cout <<
"Doing decomposition 2. ja->jba+jbb?" << endl;
141 fastjet::PseudoJet jba, jbb;
142 vector<fastjet::PseudoJet> leftovers2b;
143 bool hardBreak2b =
false;
144 if (hardBreak1) hardBreak2b = decomposeJet(jb,*fjClusterSeq,cell_particles,ptHard,nCellMin,deltarcut,jba,jbb,leftovers2b);
145 leftoversAll.insert(leftoversAll.end(),leftovers2b.begin(),leftovers2b.end());
152 if ( verbose_ )
cout <<
"Done with decomposition" << endl;
154 if ( verbose_ )
cout<<
"hardBreak1 = "<<hardBreak1<<endl;
155 if ( verbose_ )
cout<<
"hardBreak2a = "<<hardBreak2a<<endl;
156 if ( verbose_ )
cout<<
"hardBreak2b = "<<hardBreak2b<<endl;
158 fastjet::PseudoJet hardA = blankJet, hardB = blankJet, hardC = blankJet, hardD = blankJet;
164 if(verbose_)
cout<<
"Hardbreak failed. Save subjet1=localJet"<<endl;
166 if (hardBreak1 && !hardBreak2a && !hardBreak2b) {
171 if(verbose_)
cout<<
"First decomposition succeeded, both second decompositions failed. Save subjet1=ja subjet2=jb"<<endl;
173 if (hardBreak1 && hardBreak2a && !hardBreak2b) {
178 if(verbose_)
cout<<
"First decomposition succeeded, ja split succesfully, jb did not split. Save subjet1=jaa subjet2=jab subjet3=jb"<<endl;
180 if (hardBreak1 && !hardBreak2a && hardBreak2b) {
185 if(verbose_)
cout<<
"First decomposition succeeded, jb split succesfully, ja did not split. Save subjet1=jba subjet2=jbb subjet3=ja"<<endl;
187 if (hardBreak1 && hardBreak2a && hardBreak2b) {
192 if(verbose_)
cout<<
"First decomposition and both secondary decompositions succeeded. Save subjet1=jaa subjet2=jab subjet3=jba subjet4=jbb"<<endl;
196 fastjet::PseudoJet subjet1 = blankJet;
197 fastjet::PseudoJet subjet2 = blankJet;
198 fastjet::PseudoJet subjet3 = blankJet;
199 fastjet::PseudoJet subjet4 = blankJet;
200 subjet1 = hardA; subjet2 = hardB; subjet3 = hardC; subjet4 = hardD;
203 vector<fastjet::PseudoJet> hardSubjets;
206 std::cout <<
"HardA : user_index = " << hardA.user_index() <<
", (Pt,Y,Phi,M) = ("
207 << hardA.pt() <<
", " << hardA.rapidity() <<
", "
208 << hardA.phi() <<
", " << hardA.m() <<
")" << std::endl;
210 std::cout <<
"HardB : user_index = " << hardB.user_index() <<
", (Pt,Y,Phi,M) = ("
211 << hardB.pt() <<
", " << hardB.rapidity() <<
", "
212 << hardB.phi() <<
", " << hardB.m() <<
")" << std::endl;
214 std::cout <<
"HardC : user_index = " << hardC.user_index() <<
", (Pt,Y,Phi,M) = ("
215 << hardC.pt() <<
", " << hardC.rapidity() <<
", "
216 << hardC.phi() <<
", " << hardC.m() <<
")" << std::endl;
218 std::cout <<
"HardD : user_index = " << hardD.user_index() <<
", (Pt,Y,Phi,M) = ("
219 << hardD.pt() <<
", " << hardD.rapidity() <<
", "
220 << hardD.phi() <<
", " << hardD.m() <<
")" << std::endl;
227 if ( subjet1.pt() > 0.0001 )
228 hardSubjets.push_back(subjet1);
229 if ( subjet2.pt() > 0.0001 )
230 hardSubjets.push_back(subjet2);
231 if ( subjet3.pt() > 0.0001 )
232 hardSubjets.push_back(subjet3);
233 if ( subjet4.pt() > 0.0001 )
234 hardSubjets.push_back(subjet4);
235 sort(hardSubjets.begin(), hardSubjets.end(), compEt );
238 fastjet::PseudoJet candidate =
join(hardSubjets);
240 candidate.reset_momentum( jetIt->px(), jetIt->py(), jetIt->pz(), jetIt->e() );
243 std::cout <<
"Final top-jet candidate: (Pt,Y,Phi,M) = ("
244 << candidate.pt() <<
", " << candidate.rapidity() <<
", "
245 << candidate.phi() <<
", " << candidate.m() <<
")" << std::endl;
246 std::vector<fastjet::PseudoJet>
pieces = candidate.pieces();
247 std::cout <<
"Number of pieces = " << pieces.size() << std::endl;
248 for ( std::vector<fastjet::PseudoJet>::const_iterator ibegin = pieces.begin(), iend = pieces.end(), i = ibegin;
250 std::cout <<
" Piece : " << i - ibegin <<
", (Pt,Y,Phi,M) = ("
251 << i->pt() <<
", " << i->rapidity() <<
", "
252 << i->phi() <<
", " << i->m() <<
")" << std::endl;
256 hardjetsOutput.push_back( candidate );
270 const vector<fastjet::PseudoJet> & cell_particles,
271 const fastjet::ClusterSequence & theClusterSequence,
272 double nCellMin )
const {
275 double eta1 = jet1.rapidity();
276 double phi1 = jet1.phi();
277 double eta2 = jet2.rapidity();
278 double phi2 = jet2.phi();
280 double deta =
abs(eta2 - eta1) / 0.087;
283 return ( ( deta + dphi ) <= nCellMin );
292 const fastjet::ClusterSequence & theClusterSequence,
293 const vector<fastjet::PseudoJet> & cell_particles,
294 double ptHard,
double nCellMin,
double deltarcut,
295 fastjet::PseudoJet & ja, fastjet::PseudoJet & jb,
296 vector<fastjet::PseudoJet> & leftovers)
const {
299 fastjet::PseudoJet
j = theJet;
300 double InputObjectPt = j.perp();
301 if ( verbose_ )
cout<<
"Input Object Pt = "<<InputObjectPt<<endl;
302 if ( verbose_ )
cout<<
"ptHard = "<<ptHard<<endl;
304 if ( verbose_ )
cout<<
"start while loop"<<endl;
307 goodBreak = theClusterSequence.has_parents(j,ja,jb);
309 if ( verbose_ )
cout<<
"bad break. this is one cell. can't decluster anymore."<<endl;
313 if ( verbose_ )
cout<<
"good break. ja Pt = "<<ja.perp()<<
" jb Pt = "<<jb.perp()<<endl;
318 double clusters_deltar=fabs(ja.eta()-jb.eta())+fabs(
deltaPhi(ja.phi(),jb.phi()));
320 if ( verbose_ && useAdjacency_ ==1)
cout<<
"clusters_deltar = "<<clusters_deltar<<endl;
321 if ( verbose_ && useAdjacency_ ==1)
cout<<
"deltar cut = "<<deltarcut<<endl;
323 if ( useAdjacency_==1 && clusters_deltar < deltarcut){
324 if ( verbose_ )
cout<<
"clusters too close. consant adj. break."<<endl;
329 double clusters_deltaR=
deltaR( ja.eta(), ja.phi(), jb.eta(), jb.phi() );
331 if ( verbose_ && useAdjacency_ ==2)
cout<<
"clusters_deltaR = "<<clusters_deltaR<<endl;
332 if ( verbose_ && useAdjacency_ ==2)
cout<<
"0.4-0.0004*InputObjectPt = "<<0.4-0.0004*InputObjectPt<<endl;
334 if ( useAdjacency_==2 && clusters_deltaR < 0.4-0.0004*InputObjectPt)
336 if ( verbose_ )
cout<<
"clusters too close. modified adj. break."<<endl;
341 if ( useAdjacency_==3 && adjacentCells(ja,jb,cell_particles,theClusterSequence,nCellMin) ){
342 if ( verbose_ )
cout<<
"clusters too close in the calorimeter. calorimeter adj. break."<<endl;
346 if ( verbose_ )
cout<<
"clusters pass distance cut"<<endl;
350 if ( verbose_ )
cout<<
"ptHard = "<<ptHard<<endl;
352 if (ja.perp() < ptHard && jb.perp() < ptHard){
353 if ( verbose_ )
cout<<
"two soft clusters. dead end"<<endl;
357 if (ja.perp() > ptHard && jb.perp() > ptHard){
358 if ( verbose_ )
cout<<
"two hard clusters. done"<<endl;
362 else if (ja.perp() > jb.perp()) {
363 if ( verbose_ )
cout<<
"ja hard jb soft. try to split hard. j = ja"<<endl;
365 vector<fastjet::PseudoJet> particles = theClusterSequence.constituents(jb);
366 leftovers.insert(leftovers.end(),particles.begin(),particles.end());
369 if ( verbose_ )
cout<<
"ja hard jb soft. try to split hard. j = jb"<<endl;
371 vector<fastjet::PseudoJet> particles = theClusterSequence.constituents(ja);
372 leftovers.insert(leftovers.end(),particles.begin(),particles.end());
376 if ( verbose_ )
cout<<
"did not decluster."<<endl;
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
double deltaR(double eta1, double eta2, double phi1, double phi2)
double deltaPhi(double phi1, double phi2)
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.