fastjet 2.4.5
|
00001 //STARTHEADER 00002 // $Id: fastjet_timing_plugins.cc 2416 2011-07-15 01:19:11Z salam $ 00003 // 00004 // Copyright (c) 2005-2009, Matteo Cacciari, Gavin Salam and Gregory Soyez 00005 // 00006 //---------------------------------------------------------------------- 00007 // This file is part of FastJet. 00008 // 00009 // FastJet is free software; you can redistribute it and/or modify 00010 // it under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation; either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // The algorithms that underlie FastJet have required considerable 00015 // development and are described in hep-ph/0512210. If you use 00016 // FastJet as part of work towards a scientific publication, please 00017 // include a citation to the FastJet paper. 00018 // 00019 // FastJet is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with FastJet; if not, write to the Free Software 00026 // Foundation, Inc.: 00027 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00028 //---------------------------------------------------------------------- 00029 //ENDHEADER 00030 00031 00032 //---------------------------------------------------------------------- 00170 00171 00172 #include "fastjet/PseudoJet.hh" 00173 #include "fastjet/ClusterSequenceArea.hh" 00174 #include<iostream> 00175 #include<sstream> 00176 #include<fstream> 00177 #include<valarray> 00178 #include<vector> 00179 #include <cstdlib> 00180 #include<cstddef> // for size_t 00181 #include "CmdLine.hh" 00182 00183 // get info on how fastjet was configured 00184 #include "fastjet/config.h" 00185 00186 // include the installed plugins (don't delete this line) 00187 #ifdef ENABLE_PLUGIN_SISCONE 00188 #include "fastjet/SISConePlugin.hh" 00189 #include "fastjet/SISConeSphericalPlugin.hh" 00190 #endif 00191 #ifdef ENABLE_PLUGIN_CDFCONES 00192 #include "fastjet/CDFMidPointPlugin.hh" 00193 #include "fastjet/CDFJetCluPlugin.hh" 00194 #endif 00195 #ifdef ENABLE_PLUGIN_PXCONE 00196 #include "fastjet/PxConePlugin.hh" 00197 #endif 00198 #ifdef ENABLE_PLUGIN_D0RUNIICONE 00199 #include "fastjet/D0RunIIConePlugin.hh" 00200 #endif 00201 #ifdef ENABLE_PLUGIN_TRACKJET 00202 #include "fastjet/TrackJetPlugin.hh" 00203 #endif 00204 #ifdef ENABLE_PLUGIN_ATLASCONE 00205 #include "fastjet/ATLASConePlugin.hh" 00206 #endif 00207 #ifdef ENABLE_PLUGIN_EECAMBRIDGE 00208 #include "fastjet/EECambridgePlugin.hh" 00209 #endif 00210 #ifdef ENABLE_PLUGIN_JADE 00211 #include "fastjet/JadePlugin.hh" 00212 #endif 00213 #ifdef ENABLE_PLUGIN_CMSITERATIVECONE 00214 #include "fastjet/CMSIterativeConePlugin.hh" 00215 #endif 00216 // end of installed plugins inclusion (don't delete this line) 00217 00218 using namespace std; 00219 00220 // to avoid excessive typing, define an abbreviation for the 00221 // fastjet namespace 00222 namespace fj = fastjet; 00223 00224 inline double pow2(const double x) {return x*x;} 00225 00226 // pretty print the jets and their subjets 00227 void print_jets_and_sub (fj::ClusterSequence & clust_seq, 00228 const vector<fj::PseudoJet> & jets, double dcut); 00229 00230 string rootfile; 00231 CmdLine * cmdline_p; 00232 00233 bool do_areas; 00234 00237 bool ee_print = false; 00238 void print_jets(const vector<fj::PseudoJet> & jets, const fj::ClusterSequence & cs, bool show_const = false); 00239 00240 void is_unavailable(const string & algname) { 00241 cerr << algname << " requested, but not available for this compilation"; 00242 exit(0); 00243 } 00244 00245 00248 int main (int argc, char ** argv) { 00249 00250 CmdLine cmdline(argc,argv); 00251 cmdline_p = &cmdline; 00252 // allow the use to specify the fj::Strategy either through the 00253 // -clever or the -strategy options (both will take numerical 00254 // values); the latter will override the former. 00255 fj::Strategy strategy = fj::Strategy(cmdline.int_val("-strategy", 00256 cmdline.int_val("-clever", fj::Best))); 00257 int repeat = cmdline.int_val("-repeat",1); 00258 int combine = cmdline.int_val("-combine",1); 00259 bool write = cmdline.present("-write"); 00260 bool unique_write = cmdline.present("-unique_write"); 00261 bool hydjet = cmdline.present("-hydjet"); 00262 double ktR = cmdline.double_val("-r",1.0); 00263 ktR = cmdline.double_val("-R",ktR); // allow -r and -R 00264 double inclkt = cmdline.double_val("-incl",-1.0); 00265 int excln = cmdline.int_val ("-excln",-1); 00266 double excld = cmdline.double_val("-excld",-1.0); 00267 double excly = cmdline.double_val("-excly",-1.0); 00268 ee_print = cmdline.present("-ee-print"); 00269 bool get_all_dij = cmdline.present("-get-all-dij"); 00270 bool get_all_yij = cmdline.present("-get-all-yij"); 00271 double subdcut = cmdline.double_val("-subdcut",-1.0); 00272 double etamax = cmdline.double_val("-etamax",1.0e305); 00273 bool show_constituents = cmdline.present("-const"); 00274 bool massless = cmdline.present("-massless"); 00275 int nev = cmdline.int_val("-nev",1); 00276 bool add_dense_coverage = cmdline.present("-dense"); 00277 double ghost_maxrap = cmdline.value("-ghost-maxrap",5.0); 00278 do_areas = cmdline.present("-area"); 00279 fj::AreaDefinition area_def; 00280 if (do_areas) { 00281 assert(!write); // it's incompatible 00282 fj::GhostedAreaSpec ghost_spec(ghost_maxrap, 00283 cmdline.value("-area:repeat", 1), 00284 cmdline.value("-ghost-area", 0.01)); 00285 cmdline.present("-area:fj2"); // we only have fj2 areas, but allow the option anyway 00286 if (cmdline.present("-area:explicit")) { 00287 area_def = fj::AreaDefinition(fj::active_area_explicit_ghosts, ghost_spec); 00288 } else if (cmdline.present("-area:passive")) { 00289 area_def = fj::AreaDefinition(fj::passive_area, ghost_spec); 00290 } else if (cmdline.present("-area:voronoi")) { 00291 double Rfact = cmdline.value<double>("-area:voronoi"); 00292 area_def = fj::AreaDefinition(fj::voronoi_area, 00293 fj::VoronoiAreaSpec(Rfact)); 00294 } else { 00295 cmdline.present("-area:active"); // allow, but do not require, arg 00296 area_def = fj::AreaDefinition(fj::active_area, ghost_spec); 00297 } 00298 } 00299 00300 bool show_cones = cmdline.present("-cones"); // only works for siscone 00301 00302 // for cone algorithms 00303 // allow -f and -overlap 00304 double overlap_threshold = cmdline.double_val("-overlap",0.5); 00305 overlap_threshold = cmdline.double_val("-f",overlap_threshold); 00306 double seed_threshold = cmdline.double_val("-seed",1.0); 00307 00308 // for ee algorithms, allow to specify ycut 00309 double ycut = cmdline.double_val("-ycut",0.08); 00310 00311 // for printing jets to a file for reading by root 00312 rootfile = cmdline.value<string>("-root",""); 00313 00314 // out default scheme is the E_scheme 00315 fj::RecombinationScheme scheme = fj::E_scheme; 00316 00317 // The following option causes the Cambridge algo to be used. 00318 // Note that currently the only output that works sensibly here is 00319 // "-incl 0" 00320 fj::JetDefinition jet_def; 00321 if (cmdline.present("-cam") || cmdline.present("-CA")) { 00322 jet_def = fj::JetDefinition(fj::cambridge_algorithm, ktR, scheme, strategy); 00323 } else if (cmdline.present("-antikt")) { 00324 jet_def = fj::JetDefinition(fj::antikt_algorithm, ktR, scheme, strategy); 00325 } else if (cmdline.present("-genkt")) { 00326 double p = cmdline.value<double>("-genkt"); 00327 jet_def = fj::JetDefinition(fj::genkt_algorithm, ktR, p, scheme, strategy); 00328 } else if (cmdline.present("-eekt")) { 00329 jet_def = fj::JetDefinition(fj::ee_kt_algorithm); 00330 } else if (cmdline.present("-eegenkt")) { 00331 double p = cmdline.value<double>("-eegenkt"); 00332 jet_def = fj::JetDefinition(fj::ee_genkt_algorithm, ktR, p, scheme, strategy); 00333 00334 // checking if one asks to run a plugin (don't delete this line) 00335 } else if (cmdline.present("-midpoint")) { 00336 #ifdef ENABLE_PLUGIN_CDFCONES 00337 typedef fj::CDFMidPointPlugin MPPlug; // for brevity 00338 double cone_area_fraction = 1.0; 00339 int max_pair_size = 2; 00340 int max_iterations = 100; 00341 MPPlug::SplitMergeScale sm_scale = MPPlug::SM_pt; 00342 if (cmdline.present("-sm-pttilde")) sm_scale = MPPlug::SM_pttilde; 00343 if (cmdline.present("-sm-pt")) sm_scale = MPPlug::SM_pt; // default 00344 if (cmdline.present("-sm-mt")) sm_scale = MPPlug::SM_mt; 00345 if (cmdline.present("-sm-Et")) sm_scale = MPPlug::SM_Et; 00346 jet_def = fj::JetDefinition( new fj::CDFMidPointPlugin ( 00347 seed_threshold, ktR, 00348 cone_area_fraction, max_pair_size, 00349 max_iterations, overlap_threshold, 00350 sm_scale)); 00351 #else // ENABLE_PLUGIN_CDFCONES 00352 is_unavailable("midpoint"); 00353 #endif // ENABLE_PLUGIN_CDFCONES 00354 } else if (cmdline.present("-pxcone")) { 00355 #ifdef ENABLE_PLUGIN_PXCONE 00356 double min_jet_energy = 5.0; 00357 jet_def = fj::JetDefinition( new fj::PxConePlugin ( 00358 ktR, min_jet_energy, 00359 overlap_threshold)); 00360 #else // ENABLE_PLUGIN_PXCONE 00361 is_unavailable("pxcone"); 00362 #endif // ENABLE_PLUGIN_PXCONE 00363 } else if (cmdline.present("-jetclu")) { 00364 #ifdef ENABLE_PLUGIN_CDFCONES 00365 jet_def = fj::JetDefinition( new fj::CDFJetCluPlugin ( 00366 ktR, overlap_threshold, seed_threshold)); 00367 #else // ENABLE_PLUGIN_CDFCONES 00368 is_unavailable("pxcone"); 00369 #endif // ENABLE_PLUGIN_CDFCONES 00370 } else if (cmdline.present("-siscone") || cmdline.present("-sisconespheri")) { 00371 #ifdef ENABLE_PLUGIN_SISCONE 00372 typedef fj::SISConePlugin SISPlug; // for brevity 00373 int npass = cmdline.value("-npass",0); 00374 if (cmdline.present("-siscone")) { 00375 double sisptmin = cmdline.value("-sisptmin",0.0); 00376 SISPlug * plugin = new SISPlug (ktR, overlap_threshold,npass,sisptmin); 00377 if (cmdline.present("-sm-pt")) plugin->set_split_merge_scale(SISPlug::SM_pt); 00378 if (cmdline.present("-sm-mt")) plugin->set_split_merge_scale(SISPlug::SM_mt); 00379 if (cmdline.present("-sm-Et")) plugin->set_split_merge_scale(SISPlug::SM_Et); 00380 if (cmdline.present("-sm-pttilde")) plugin->set_split_merge_scale(SISPlug::SM_pttilde); 00381 // cause it to use the jet-definition's own recombiner 00382 plugin->set_use_jet_def_recombiner(true); 00383 jet_def = fj::JetDefinition(plugin); 00384 } else { 00385 double sisEmin = cmdline.value("-sisEmin",0.0); 00386 fj::SISConeSphericalPlugin * plugin = 00387 new fj::SISConeSphericalPlugin(ktR, overlap_threshold,npass,sisEmin); 00388 if (cmdline.present("-ghost-sep")) { 00389 plugin->set_ghost_separation_scale(cmdline.value<double>("-ghost-sep")); 00390 } 00391 jet_def = fj::JetDefinition(plugin); 00392 } 00393 #else // ENABLE_PLUGIN_SISCONE 00394 is_unavailable("siscone"); 00395 #endif // ENABLE_PLUGIN_SISCONE 00396 } else if (cmdline.present("-d0runiicone")) { 00397 #ifdef ENABLE_PLUGIN_D0RUNIICONE 00398 double min_jet_Et = 6.0; // was 8 GeV in earlier work 00399 jet_def = fj::JetDefinition(new fj::D0RunIIConePlugin(ktR,min_jet_Et)); 00400 #else // ENABLE_PLUGIN_D0RUNIICONE 00401 is_unavailable("D0RunIICone"); 00402 #endif // ENABLE_PLUGIN_D0RUNIICONE 00403 } else if (cmdline.present("-trackjet")) { 00404 #ifdef ENABLE_PLUGIN_TRACKJET 00405 jet_def = fj::JetDefinition(new fj::TrackJetPlugin(ktR)); 00406 #else // ENABLE_PLUGIN_TRACKJET 00407 is_unavailable("TrackJet"); 00408 #endif // ENABLE_PLUGIN_TRACKJET 00409 } else if (cmdline.present("-atlascone")) { 00410 #ifdef ENABLE_PLUGIN_ATLASCONE 00411 jet_def = fj::JetDefinition(new fj::ATLASConePlugin(ktR)); 00412 #else // ENABLE_PLUGIN_ATLASCONE 00413 is_unavailable("ATLASCone"); 00414 #endif // ENABLE_PLUGIN_ATLASCONE 00415 } else if (cmdline.present("-eecambridge")) { 00416 #ifdef ENABLE_PLUGIN_EECAMBRIDGE 00417 jet_def = fj::JetDefinition(new fj::EECambridgePlugin(ycut)); 00418 #else // ENABLE_PLUGIN_EECAMBRIDGE 00419 is_unavailable("EECambridge"); 00420 #endif // ENABLE_PLUGIN_EECAMBRIDGE 00421 } else if (cmdline.present("-jade")) { 00422 #ifdef ENABLE_PLUGIN_JADE 00423 jet_def = fj::JetDefinition(new fj::JadePlugin()); 00424 #else // ENABLE_PLUGIN_JADE 00425 is_unavailable("Jade"); 00426 #endif // ENABLE_PLUGIN_JADE 00427 } else if (cmdline.present("-cmsiterativecone")) { 00428 #ifdef ENABLE_PLUGIN_CMSITERATIVECONE 00429 jet_def = fj::JetDefinition(new fj::CMSIterativeConePlugin(ktR,seed_threshold)); 00430 #else // ENABLE_PLUGIN_CMSITERATIVECONE 00431 is_unavailable("CMSIterativeCone"); 00432 #endif // ENABLE_PLUGIN_CMSITERATIVECONE 00433 // end of checking if one asks to run a plugin (don't delete this line) 00434 } else { 00435 cmdline.present("-kt"); // kt is default, but allow user to specify it too [and ignore return value!] 00436 jet_def = fj::JetDefinition(fj::kt_algorithm, ktR, strategy); 00437 } 00438 00439 00440 00441 if (!cmdline.all_options_used()) {cerr << 00442 "Error: some options were not recognized"<<endl; 00443 exit(-1);} 00444 00445 00446 for (int iev = 0; iev < nev; iev++) { 00447 vector<fj::PseudoJet> jets; 00448 string line; 00449 int ndone = 0; 00450 while (getline(cin, line)) { 00451 //cout << line<<endl; 00452 istringstream linestream(line); 00453 if (line == "#END") { 00454 ndone += 1; 00455 if (ndone == combine) {break;} 00456 } 00457 if (line.substr(0,1) == "#") {continue;} 00458 valarray<double> fourvec(4); 00459 if (hydjet) { 00460 // special reading from hydjet.txt event record (though actually 00461 // this is supposed to be a standard pythia event record, so 00462 // being able to read from it is perhaps not so bad an idea...) 00463 int ii, istat,id,m1,m2,d1,d2; 00464 double mass; 00465 linestream >> ii>> istat >> id >> m1 >> m2 >> d1 >> d2 00466 >> fourvec[0] >> fourvec[1] >> fourvec[2] >> mass; 00467 // current file contains mass of particle as 4th entry 00468 if (istat == 1) { 00469 fourvec[3] = sqrt(+pow2(fourvec[0])+pow2(fourvec[1]) 00470 +pow2(fourvec[2])+pow2(mass)); 00471 } 00472 } else { 00473 if (massless) { 00474 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2]; 00475 fourvec[3] = sqrt(pow2(fourvec[0])+pow2(fourvec[1])+pow2(fourvec[2]));} 00476 else { 00477 linestream >> fourvec[0] >> fourvec[1] >> fourvec[2] >> fourvec[3]; 00478 } 00479 } 00480 fj::PseudoJet psjet(fourvec); 00481 if (abs(psjet.rap() < etamax)) {jets.push_back(psjet);} 00482 } 00483 00484 // add a fake underlying event which is very soft, uniformly distributed 00485 // in eta,phi so as to allow one to reconstruct the area that is associated 00486 // with each jet. 00487 if (add_dense_coverage) { 00488 fj::GhostedAreaSpec ghosted_area_spec(ghost_maxrap); 00489 //fj::GhostedAreaSpec ghosted_area_spec(-2.0,4.0); // asymmetric range 00490 // for plots, reduce the scatter default of 1, to avoid "holes" 00491 // in the subsequent calorimeter view 00492 ghosted_area_spec.set_grid_scatter(0.5); 00493 ghosted_area_spec.add_ghosts(jets); 00494 //----- old code ------------------ 00495 // srand(2); 00496 // int nphi = 60; 00497 // int neta = 100; 00498 // double kt = 1e-1; 00499 // for (int iphi = 0; iphi<nphi; iphi++) { 00500 // for (int ieta = -neta; ieta<neta+1; ieta++) { 00501 // double phi = (iphi+0.5) * (fj::twopi/nphi) + rand()*0.001/RAND_MAX; 00502 // double eta = ieta * (10.0/neta) + rand()*0.001/RAND_MAX; 00503 // kt = 1e-20*(1+rand()*0.1/RAND_MAX); 00504 // double pminus = kt*exp(-eta); 00505 // double pplus = kt*exp(+eta); 00506 // double px = kt*sin(phi); 00507 // double py = kt*cos(phi); 00508 // //cout << kt<<" "<<eta<<" "<<phi<<"\n"; 00509 // fj::PseudoJet mom(px,py,0.5*(pplus-pminus),0.5*(pplus+pminus)); 00510 // jets.push_back(mom); 00511 // } 00512 // } 00513 } 00514 00515 for (int irepeat = 0; irepeat < repeat ; irepeat++) { 00516 int nparticles = jets.size(); 00517 try { 00518 auto_ptr<fj::ClusterSequence> clust_seq; 00519 if (do_areas) { 00520 clust_seq.reset(new fj::ClusterSequenceArea(jets,jet_def,area_def)); 00521 } else { 00522 clust_seq.reset(new fj::ClusterSequence(jets,jet_def,write)); 00523 } 00524 if (irepeat != 0) {continue;} 00525 cout << "iev "<<iev<< ": number of particles = "<< nparticles << endl; 00526 cout << "strategy used = "<< clust_seq->strategy_string()<< endl; 00527 cout << "Algorithm: " << jet_def.description() << " (" << fj::fastjet_version_string() << ")" << endl; 00528 if (do_areas && iev == 0) cout << "Area definition: " << area_def.description() << endl; 00529 00530 // now provide some nice output... 00531 if (inclkt >= 0.0) { 00532 vector<fj::PseudoJet> jets = sorted_by_pt(clust_seq->inclusive_jets(inclkt)); 00533 print_jets(jets, *clust_seq, show_constituents); 00534 00535 } 00536 00537 if (excln > 0) { 00538 cout << "Printing "<<excln<<" exclusive jets\n"; 00539 print_jets(clust_seq->exclusive_jets(excln), *clust_seq, show_constituents); 00540 } 00541 00542 if (excld > 0.0) { 00543 cout << "Printing exclusive jets for d = "<<excld<<"\n"; 00544 print_jets(clust_seq->exclusive_jets(excld), *clust_seq, show_constituents); 00545 } 00546 00547 if (excly > 0.0) { 00548 cout << "Printing exclusive jets for ycut = "<<excly<<"\n"; 00549 print_jets(clust_seq->exclusive_jets_ycut(excly), *clust_seq, show_constituents); 00550 } 00551 00552 if (get_all_dij) { 00553 for (int i = nparticles-1; i >= 0; i--) { 00554 printf("d for n = %4d -> %4d is %14.5e\n", i+1, i, clust_seq->exclusive_dmerge(i)); 00555 } 00556 } 00557 if (get_all_yij) { 00558 for (int i = nparticles-1; i >= 0; i--) { 00559 printf("y for n = %4d -> %4d is %14.5e\n", i+1, i, clust_seq->exclusive_ymerge(i)); 00560 } 00561 } 00562 00563 // have the option of printing out the subjets (at scale dcut) of 00564 // each inclusive jet 00565 if (subdcut >= 0.0) { 00566 print_jets_and_sub(*clust_seq, clust_seq->inclusive_jets(), subdcut); 00567 } 00568 00569 // useful for testing that recombination sequences are unique 00570 if (unique_write) { 00571 vector<int> unique_history = clust_seq->unique_history_order(); 00572 // construct the inverse of the above mapping 00573 vector<int> inv_unique_history(clust_seq->history().size()); 00574 for (unsigned int i = 0; i < unique_history.size(); i++) { 00575 inv_unique_history[unique_history[i]] = i;} 00576 00577 for (unsigned int i = 0; i < unique_history.size(); i++) { 00578 fj::ClusterSequence::history_element el = 00579 clust_seq->history()[unique_history[i]]; 00580 int uhp1 = el.parent1>=0 ? inv_unique_history[el.parent1] : el.parent1; 00581 int uhp2 = el.parent2>=0 ? inv_unique_history[el.parent2] : el.parent2; 00582 printf("%7d u %15.8e %7d u %7d u\n",i,el.dij,uhp1, uhp2); 00583 } 00584 } 00585 00586 00587 #ifdef ENABLE_PLUGIN_SISCONE 00588 // provide some complementary information for SISCone 00589 if (show_cones) { 00590 const fj::SISConeExtras * extras = 00591 dynamic_cast<const fj::SISConeExtras *>(clust_seq->extras()); 00592 cout << "most ambiguous split (difference in squared dist) = " 00593 << extras->most_ambiguous_split() << endl; 00594 vector<fastjet::PseudoJet> stable_cones(extras->stable_cones()); 00595 stable_cones = sorted_by_rapidity(stable_cones); 00596 for (unsigned int i = 0; i < stable_cones.size(); i++) { 00597 //if (stable_cones[i].phi() < 5.0 && stable_cones[i].phi() > 4.0) { 00598 printf("%5u %15.8f %15.8f %15.8f\n", 00599 i,stable_cones[i].rap(),stable_cones[i].phi(), 00600 stable_cones[i].perp() ); 00601 //} 00602 } 00603 00604 // also show passes for jets 00605 vector<fj::PseudoJet> sisjets = clust_seq->inclusive_jets(); 00606 printf("\n%15s %15s %15s %12s %8s %8s\n","rap","phi","pt","user-index","pass","nconst"); 00607 for (unsigned i = 0; i < sisjets.size(); i++) { 00608 printf("%15.8f %15.8f %15.8f %12d %8d %8d\n", 00609 sisjets[i].rap(), sisjets[i].phi(), sisjets[i].perp(), 00610 sisjets[i].user_index(), extras->pass(sisjets[i]), 00611 clust_seq->constituents(sisjets[i]).size() 00612 ); 00613 00614 } 00615 } 00616 #endif // ENABLE_PLUGIN_SISCONE 00617 } // try 00618 catch (fastjet::Error fjerr) { 00619 cout << "Caught fastjet error, exiting gracefully" << endl; 00620 exit(0); 00621 } 00622 00623 } // irepeat 00624 } // iev 00625 00626 // if we've instantiated a plugin, delete it 00627 if (jet_def.strategy()==fj::plugin_strategy){ 00628 delete jet_def.plugin(); 00629 } 00630 } 00631 00632 00633 00634 00635 //------ HELPER ROUTINES ----------------------------------------------- 00637 void print_jet (const fj::ClusterSequence & clust_seq, 00638 const fj::PseudoJet & jet) { 00639 int n_constituents = clust_seq.constituents(jet).size(); 00640 printf("%15.8f %15.8f %15.8f %8u\n", 00641 jet.rap(), jet.phi(), jet.perp(), n_constituents); 00642 } 00643 00644 00645 //---------------------------------------------------------------------- 00646 void print_jets(const vector<fj::PseudoJet> & jets_in, const fj::ClusterSequence & cs, bool show_constituents) { 00647 vector<fj::PseudoJet> jets; 00648 if (ee_print) { 00649 jets = sorted_by_E(jets_in); 00650 for (size_t j = 0; j < jets.size(); j++) { 00651 printf("%5u %15.8f %15.8f %15.8f %15.8f\n", 00652 j,jets[j].px(),jets[j].py(),jets[j].pz(),jets[j].E()); 00653 if (show_constituents) { 00654 vector<fj::PseudoJet> const_jets = cs.constituents(jets[j]); 00655 for (size_t k = 0; k < const_jets.size(); k++) { 00656 printf(" jet%03u %15.8f %15.8f %15.8f %15.8f\n",j,const_jets[k].px(), 00657 const_jets[k].py(),const_jets[k].pz(),const_jets[k].E()); 00658 } 00659 cout << "\n\n"; 00660 } 00661 00662 } 00663 } else { 00664 jets = sorted_by_pt(jets_in); 00665 for (size_t j = 0; j < jets.size(); j++) { 00666 printf("%5u %15.8f %15.8f %15.8f", 00667 j,jets[j].rap(),jets[j].phi(),jets[j].perp()); 00668 // also print out the scalar area and the perp component of the 00669 // 4-vector (just enough to check a reasonable 4-vector?) 00670 if (do_areas) { 00671 const fj::ClusterSequenceAreaBase * csab = 00672 dynamic_cast<const fj::ClusterSequenceAreaBase *>(&cs); 00673 printf(" %15.8f %15.8f", csab->area(jets[j]), 00674 csab->area_4vector(jets[j]).perp()); 00675 } 00676 cout << "\n"; 00677 00678 if (show_constituents) { 00679 vector<fj::PseudoJet> const_jets = cs.constituents(jets[j]); 00680 for (size_t k = 0; k < const_jets.size(); k++) { 00681 printf(" jet%03u %15.8f %15.8f %15.8f\n",j,const_jets[k].rap(), 00682 const_jets[k].phi(),sqrt(const_jets[k].kt2())); 00683 } 00684 cout << "\n\n"; 00685 } 00686 } 00687 } 00688 00689 if (rootfile != "") { 00690 ofstream ostr(rootfile.c_str()); 00691 ostr << "# " << cmdline_p->command_line() << endl; 00692 ostr << "# output for root" << endl; 00693 cs.print_jets_for_root(jets,ostr); 00694 } 00695 00696 } 00697 00698 00699 //----- SUBJETS -------------------------------------------------------- 00702 void print_jets_and_sub (fj::ClusterSequence & clust_seq, 00703 const vector<fj::PseudoJet> & jets, double dcut) { 00704 00705 // sort jets into increasing pt 00706 vector<fj::PseudoJet> sorted_jets = sorted_by_pt(jets); 00707 00708 // label the columns 00709 printf("Printing jets and their subjets with subdcut = %10.5f\n",dcut); 00710 printf("%5s %15s %15s %15s %15s\n","jet #", "rapidity", 00711 "phi", "pt", "n constituents"); 00712 00713 // have various kinds of subjet finding, to test consistency among them 00714 enum SubType {internal, newclust_dcut, newclust_R}; 00715 SubType subtype = internal; 00716 //SubType subtype = newclust_dcut; 00717 00718 // print out the details for each jet 00719 for (unsigned int i = 0; i < sorted_jets.size(); i++) { 00720 // if jet pt^2 < dcut with kt alg, then some methods of 00721 // getting subjets will return nothing -- so skip the jet 00722 if (clust_seq.jet_def().jet_algorithm() == fj::kt_algorithm 00723 && sorted_jets[i].perp2() < dcut) continue; 00724 00725 printf("%5u ",i); 00726 print_jet(clust_seq, sorted_jets[i]); 00727 vector<fj::PseudoJet> subjets; 00728 fj::ClusterSequence * cspoint; 00729 if (subtype == internal) { 00730 cspoint = &clust_seq; 00731 subjets = clust_seq.exclusive_subjets(sorted_jets[i], dcut); 00732 //subjets = clust_seq.exclusive_subjets(sorted_jets[i], 5); 00733 double ddnp1 = clust_seq.exclusive_subdmerge_max(sorted_jets[i], subjets.size()); 00734 double ddn = clust_seq.exclusive_subdmerge_max(sorted_jets[i], subjets.size()-1); 00735 cout << " for " << ddnp1 << " < d < " << ddn << " one has " << endl; 00736 //subjets = clust_seq.exclusive_subjets(sorted_jets[i], dd*1.0000001); 00737 } else if (subtype == newclust_dcut) { 00738 cspoint = new fj::ClusterSequence(clust_seq.constituents(sorted_jets[i]), 00739 clust_seq.jet_def()); 00740 subjets = cspoint->exclusive_jets(dcut); 00741 //subjets = cspoint->exclusive_jets(int(min(5U,cspoint->n_particles()))); 00742 } else if (subtype == newclust_R) { 00743 assert(clust_seq.jet_def().jet_algorithm() == fj::cambridge_algorithm); 00744 fj::JetDefinition subjd(clust_seq.jet_def().jet_algorithm(), 00745 clust_seq.jet_def().R()*sqrt(dcut)); 00746 cspoint = new fj::ClusterSequence(clust_seq.constituents(sorted_jets[i]), 00747 subjd); 00748 subjets = cspoint->inclusive_jets(); 00749 } else { 00750 cerr << "unrecognized subtype for subjet finding" << endl; 00751 exit(-1); 00752 } 00753 00754 subjets = sorted_by_pt(subjets); 00755 for (unsigned int j = 0; j < subjets.size(); j++) { 00756 printf(" -sub-%02u ",j); 00757 print_jet(*cspoint, subjets[j]); 00758 } 00759 00760 if (cspoint != &clust_seq) delete cspoint; 00761 00762 //fj::ClusterSequence subseq(clust_seq.constituents(sorted_jets[i]), 00763 // fj::JetDefinition(fj::cambridge_algorithm, 0.4)); 00764 //vector<fj::PseudoJet> subjets = sorted_by_pt(subseq.inclusive_jets()); 00765 //for (unsigned int j = 0; j < subjets.size(); j++) { 00766 // printf(" -sub-%02u ",j); 00767 // print_jet(subseq, subjets[j]); 00768 //} 00769 } 00770 00771 } 00772