|
fastjet 3.0alpha2
|
00001 //---------------------------------------------------------------------- 00002 /// \file 00003 /// \page Example12 12 - use of filtering 00004 /// 00005 /// fastjet example program illustrating the use of a Filter 00006 /// 00007 /// To do that, we apply different filter examples on a either the 00008 /// hardest jet of the given event or the compositipon of the two 00009 /// hardest jets: a filter keeping a fixed number of subjets (as in 00010 /// arXiv:0802.2470), and a "trimmer" i.e. a filter keeping subjets 00011 /// carrying a sufficient fraction of the pt of the jet 00012 /// (arXiv:0912.1342). 00013 /// 00014 /// run it with : ./12-filter < data/single-event.dat 00015 /// 00016 /// Source code: 12-filter.cc 00017 //---------------------------------------------------------------------- 00018 00019 #include <fastjet/PseudoJet.hh> 00020 #include <fastjet/ClusterSequence.hh> 00021 #include <fastjet/Selector.hh> 00022 #include <iostream> 00023 #include "fastjet/tools/Filter.hh" 00024 00025 #include <cstdio> // needed for io 00026 00027 using namespace fastjet; 00028 using namespace std; 00029 00030 /// an example program showing how to use fastjet 00031 int main (int argc, char ** argv) { 00032 // read in input particles 00033 //---------------------------------------------------------- 00034 vector<PseudoJet> input_particles; 00035 00036 double px, py , pz, E; 00037 while (cin >> px >> py >> pz >> E) { 00038 // create a fastjet::PseudoJet with these components and put it onto 00039 // back of the input_particles vector 00040 input_particles.push_back(PseudoJet(px,py,pz,E)); 00041 } 00042 00043 // get the resulting jets ordered in pt 00044 //---------------------------------------------------------- 00045 JetDefinition jet_def(cambridge_algorithm, 1.2); 00046 ClusterSequence clust_seq(input_particles, jet_def); 00047 vector<fastjet::PseudoJet> inclusive_jets = sorted_by_pt(clust_seq.inclusive_jets(5.0)); 00048 00049 // label the columns 00050 printf("%5s %15s %15s %15s\n","jet #", "rapidity", "phi", "pt"); 00051 00052 // print out the details for each jet 00053 for (unsigned int i = 0; i < inclusive_jets.size(); i++) { 00054 printf("%5u %15.8f %15.8f %15.8f\n", 00055 i, inclusive_jets[i].rap(), inclusive_jets[i].phi(), 00056 inclusive_jets[i].perp()); 00057 } 00058 00059 // simple test to avoid that the example below crashes: 00060 // make sure there is at least 2 jets above our 5 GeV 00061 if (inclusive_jets.size()<2){ 00062 cout << "Please provide an event with at least 2 jets above 5 GeV" << endl; 00063 return 1; 00064 } 00065 00066 // the sample PseudoJet that we shall filter 00067 // - the hardest jet of the event 00068 // - the compositiomn of the 2 hardest jets (showing that the Filter can also be applied on a CompositeJet) 00069 //---------------------------------------------------------- 00070 vector<PseudoJet> candidates; 00071 candidates.push_back(inclusive_jets[0]); 00072 candidates.push_back(join(inclusive_jets[0],inclusive_jets[1])); 00073 00074 // create a few filters 00075 //---------------------------------------------------------- 00076 vector<Filter> filters; 00077 00078 // the Aachen/Cambridge filter as in arXiv:0802.2470 00079 filters.push_back(Filter(JetDefinition(cambridge_algorithm, 0.3), SelectorNHardest(3))); 00080 00081 // Filtering with a pt cut as for trimming (arXiv:0912.1342) 00082 filters.push_back(Filter(JetDefinition(kt_algorithm, 0.2), SelectorPtFractionMin(0.03))); 00083 00084 // apply the various filters on the test PseudoJet 00085 // and show the result 00086 //---------------------------------------------------------- 00087 for (vector<PseudoJet>::iterator jit=candidates.begin(); jit!=candidates.end(); jit++){ 00088 const PseudoJet & c = *jit; 00089 cout << "Original jet : " << c.description() << endl; 00090 cout << " rap = " << c.rap() << ", phi = " << c.phi() << ", pt = " << c.perp() << endl; 00091 00092 for (vector<Filter>::iterator it=filters.begin(); it!=filters.end(); it++){ 00093 const Filter & f = *it; 00094 00095 cout << "Applying filter: " << f.description() << endl; 00096 PseudoJet j = f(c); 00097 00098 cout << "Resulting jet : " << j.description() << endl; 00099 cout << " rap = " << j.rap() << ", phi = " << j.phi() << ", pt = " << j.perp() << endl; 00100 cout << " #pieces: " << j.pieces().size() << endl; 00101 00102 // note that, alternatively, we could directly access teh 00103 // relevant structure 00104 assert(j.has_properties_of<Filter>()); 00105 const FilteredJetStructure * fj_struct = j.extra_properties<Filter>(); 00106 cout << " #rejected pieces: " << fj_struct->rejected().size() << endl; 00107 } 00108 cout << endl; 00109 } 00110 00111 return 0; 00112 }
1.7.3