22 vector<CompoundPseudoJet> & hardjetsOutput,
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;
67 fastjet::Strategy strategy = fastjet::Best;
68 fastjet::RecombinationScheme recombScheme = fastjet::E_scheme;
71 fastjet::JetAlgorithm
algorithm =
static_cast<fastjet::JetAlgorithm
>( algorithm_ );
73 fastjet::JetDefinition jetDef( algorithm,
74 rBins_[sumEtBinId], recombScheme, strategy);
76 if ( verbose_ )
cout <<
"About to do jet clustering in CA" << endl;
78 fastjet::ClusterSequence clusterSeq(cell_particles, jetDef);
80 if ( verbose_ )
cout <<
"Getting inclusive jets" << endl;
82 vector<fastjet::PseudoJet> inclusiveJets = clusterSeq.inclusive_jets(ptMin_);
84 if ( verbose_ )
cout <<
"Getting central jets" << endl;
86 vector<fastjet::PseudoJet> centralJets;
87 for (
unsigned int i = 0;
i < inclusiveJets.size();
i++) {
89 if (inclusiveJets[
i].
perp() > ptMin_ && fabs(inclusiveJets[
i].rapidity()) < centralEtaCut_) {
90 centralJets.push_back(inclusiveJets[
i]);
95 sort( centralJets.begin(), centralJets.end(), compEt );
98 vector<math::XYZTLorentzVector> p4_hardJets;
102 vector<vector<int> > indices( centralJets.size() );
105 vector<fastjet::PseudoJet>::iterator jetIt = centralJets.begin(),
106 centralJetsBegin = centralJets.begin(),
107 centralJetsEnd = centralJets.end();
108 if ( verbose_ )
cout<<
"Loop over jets"<<endl;
110 for ( ; jetIt != centralJetsEnd; ++jetIt ) {
111 if ( verbose_ )
cout<<
"\nJet "<<i<<endl;
113 fastjet::PseudoJet localJet = *jetIt;
119 if ( verbose_ )
cout<<
"local jet pt = "<<localJet.perp()<<endl;
120 if ( verbose_ )
cout<<
"deltap = "<<ptFracBins_[sumEtBinId]<<endl;
122 double ptHard = ptFracBins_[sumEtBinId]*localJet.perp();
123 vector<fastjet::PseudoJet> leftoversAll;
126 if ( verbose_ )
cout <<
"Doing decomposition 1" << endl;
127 fastjet::PseudoJet ja, jb;
128 vector<fastjet::PseudoJet> leftovers1;
129 bool hardBreak1 = decomposeJet(localJet,clusterSeq,cell_particles,ptHard,nCellMin,deltarcut,ja,jb,leftovers1);
130 leftoversAll.insert(leftoversAll.end(),leftovers1.begin(),leftovers1.end());
135 if ( verbose_ )
cout <<
"Doing decomposition 2. ja->jaa+jab?" << endl;
136 fastjet::PseudoJet jaa, jab;
137 vector<fastjet::PseudoJet> leftovers2a;
138 bool hardBreak2a =
false;
139 if (hardBreak1) hardBreak2a = decomposeJet(ja,clusterSeq,cell_particles,ptHard,nCellMin,deltarcut,jaa,jab,leftovers2a);
140 leftoversAll.insert(leftoversAll.end(),leftovers2a.begin(),leftovers2a.end());
142 if ( verbose_ )
cout <<
"Doing decomposition 2. ja->jba+jbb?" << endl;
143 fastjet::PseudoJet jba, jbb;
144 vector<fastjet::PseudoJet> leftovers2b;
145 bool hardBreak2b =
false;
146 if (hardBreak1) hardBreak2b = decomposeJet(jb,clusterSeq,cell_particles,ptHard,nCellMin,deltarcut,jba,jbb,leftovers2b);
147 leftoversAll.insert(leftoversAll.end(),leftovers2b.begin(),leftovers2b.end());
154 if ( verbose_ )
cout <<
"Done with decomposition" << endl;
157 fastjet::PseudoJet hardA = blankJet, hardB = blankJet, hardC = blankJet, hardD = blankJet;
158 if (!hardBreak2a && !hardBreak2b) { nBreak2 = 0; hardA = ja; hardB = jb; hardC = blankJet; hardD = blankJet; }
159 if ( hardBreak2a && !hardBreak2b) { nBreak2 = 1; hardA = jaa; hardB = jab; hardC = jb; hardD = blankJet; }
160 if (!hardBreak2a && hardBreak2b) { nBreak2 = 1; hardA = jba; hardB = jbb; hardC = ja; hardD = blankJet;}
161 if ( hardBreak2a && hardBreak2b) { nBreak2 = 2; hardA = jaa; hardB = jab; hardC = jba; hardD = jbb; }
164 fastjet::PseudoJet subjet1 = blankJet;
165 fastjet::PseudoJet subjet2 = blankJet;
166 fastjet::PseudoJet subjet3 = blankJet;
167 fastjet::PseudoJet subjet4 = blankJet;
168 subjet1 = hardA; subjet2 = hardB; subjet3 = hardC; subjet4 = hardD;
171 vector<fastjet::PseudoJet> hardSubjets;
173 if ( subjet1.user_index() >= 0 )
174 hardSubjets.push_back(subjet1);
175 if ( subjet2.user_index() >= 0 )
176 hardSubjets.push_back(subjet2);
177 if ( subjet3.user_index() >= 0 )
178 hardSubjets.push_back(subjet3);
179 if ( subjet4.user_index() >= 0 )
180 hardSubjets.push_back(subjet4);
181 sort(hardSubjets.begin(), hardSubjets.end(), compEt );
184 vector<CompoundPseudoSubJet> subjetsOutput;
185 std::vector<fastjet::PseudoJet>::const_iterator itSubJetBegin = hardSubjets.begin(),
186 itSubJet = itSubJetBegin, itSubJetEnd = hardSubjets.end();
187 for (; itSubJet != itSubJetEnd; ++itSubJet ){
192 vector<fastjet::PseudoJet> subjetFastjetConstituents = clusterSeq.constituents( *itSubJet );
195 vector<int> constituents;
198 vector<fastjet::PseudoJet>::const_iterator fastSubIt = subjetFastjetConstituents.begin(),
199 transConstBegin = subjetFastjetConstituents.begin(),
200 transConstEnd = subjetFastjetConstituents.end();
201 for ( ; fastSubIt != transConstEnd; ++fastSubIt ) {
202 if ( fastSubIt->user_index() >= 0 &&
static_cast<unsigned int>(fastSubIt->user_index()) < cell_particles.size() ) {
203 constituents.push_back( fastSubIt->user_index() );
228 const vector<fastjet::PseudoJet> & cell_particles,
229 const fastjet::ClusterSequence & theClusterSequence,
230 double nCellMin )
const {
233 double eta1 = jet1.rapidity();
234 double phi1 = jet1.phi();
235 double eta2 = jet2.rapidity();
236 double phi2 = jet2.phi();
238 double deta =
abs(eta2 - eta1) / 0.087;
241 return ( ( deta + dphi ) <= nCellMin );
250 const fastjet::ClusterSequence & theClusterSequence,
251 const vector<fastjet::PseudoJet> & cell_particles,
252 double ptHard,
double nCellMin,
double deltarcut,
253 fastjet::PseudoJet & ja, fastjet::PseudoJet & jb,
254 vector<fastjet::PseudoJet> & leftovers)
const {
257 fastjet::PseudoJet
j = theJet;
258 double InputObjectPt = j.perp();
259 if ( verbose_ )
cout<<
"Input Object Pt = "<<InputObjectPt<<endl;
260 if ( verbose_ )
cout<<
"ptHard = "<<ptHard<<endl;
262 if ( verbose_ )
cout<<
"start while loop"<<endl;
265 goodBreak = theClusterSequence.has_parents(j,ja,jb);
267 if ( verbose_ )
cout<<
"bad break. this is one cell. can't decluster anymore."<<endl;
271 if ( verbose_ )
cout<<
"good break. ja Pt = "<<ja.perp()<<
" jb Pt = "<<jb.perp()<<endl;
276 double clusters_deltar=fabs(ja.eta()-jb.eta())+fabs(
deltaPhi(ja.phi(),jb.phi()));
278 if ( verbose_ && useAdjacency_ ==1)
cout<<
"clusters_deltar = "<<clusters_deltar<<endl;
279 if ( verbose_ && useAdjacency_ ==1)
cout<<
"deltar cut = "<<deltarcut<<endl;
281 if ( useAdjacency_==1 && clusters_deltar < deltarcut){
282 if ( verbose_ )
cout<<
"clusters too close. consant adj. break."<<endl;
287 double clusters_deltaR=
deltaR( ja.eta(), ja.phi(), jb.eta(), jb.phi() );
289 if ( verbose_ && useAdjacency_ ==2)
cout<<
"clusters_deltaR = "<<clusters_deltaR<<endl;
290 if ( verbose_ && useAdjacency_ ==2)
cout<<
"0.4-0.0004*InputObjectPt = "<<0.4-0.0004*InputObjectPt<<endl;
292 if ( useAdjacency_==2 && clusters_deltaR < 0.4-0.0004*InputObjectPt)
294 if ( verbose_ )
cout<<
"clusters too close. modified adj. break."<<endl;
299 if ( useAdjacency_==3 && adjacentCells(ja,jb,cell_particles,theClusterSequence,nCellMin) ){
300 if ( verbose_ )
cout<<
"clusters too close in the calorimeter. calorimeter adj. break."<<endl;
304 if ( verbose_ )
cout<<
"clusters pass distance cut"<<endl;
308 if ( verbose_ )
cout<<
"ptHard = "<<ptHard<<endl;
310 if (ja.perp() < ptHard && jb.perp() < ptHard){
311 if ( verbose_ )
cout<<
"two soft clusters. dead end"<<endl;
315 if (ja.perp() > ptHard && jb.perp() > ptHard){
316 if ( verbose_ )
cout<<
"two hard clusters. done"<<endl;
320 else if (ja.perp() > jb.perp()) {
321 if ( verbose_ )
cout<<
"ja hard jb soft. try to split hard. j = ja"<<endl;
323 vector<fastjet::PseudoJet> particles = theClusterSequence.constituents(jb);
324 leftovers.insert(leftovers.end(),particles.begin(),particles.end());
327 if ( verbose_ )
cout<<
"ja hard jb soft. try to split hard. j = jb"<<endl;
329 vector<fastjet::PseudoJet> particles = theClusterSequence.constituents(ja);
330 leftovers.insert(leftovers.end(),particles.begin(),particles.end());
334 if ( verbose_ )
cout<<
"did not decluster."<<endl;
void run(const std::vector< fastjet::PseudoJet > &cell_particles, std::vector< CompoundPseudoJet > &hardjetsOutput, edm::EventSetup const &c)
Find the ProtoJets from the collection of input Candidates.
double deltaPhi(float phi1, float phi2)
T perp() const
Magnitude of transverse component.
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
CompoundPseudoJet holds an association of fastjet::PseudoJets that represent a "hard" top jet with su...
double deltaR(double eta1, double eta2, double phi1, double phi2)
double deltaPhi(double phi1, double phi2)