Changeset 35cdc46 in git for external/fastjet/tools/JetMedianBackgroundEstimator.cc
- Timestamp:
- Sep 3, 2014, 3:18:54 PM (10 years ago)
- Branches:
- ImprovedOutputFile, Timing, dual_readout, llp, master
- Children:
- be2222c
- Parents:
- 5b5a56b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
external/fastjet/tools/JetMedianBackgroundEstimator.cc
r5b5a56b r35cdc46 1 // STARTHEADER2 // $Id $3 // 4 // Copyright (c) 2005-201 1, Matteo Cacciari, Gavin P. Salam and Gregory Soyez1 //FJSTARTHEADER 2 // $Id: JetMedianBackgroundEstimator.cc 3517 2014-08-01 14:23:13Z soyez $ 3 // 4 // Copyright (c) 2005-2014, Matteo Cacciari, Gavin P. Salam and Gregory Soyez 5 5 // 6 6 //---------------------------------------------------------------------- … … 13 13 // 14 14 // The algorithms that underlie FastJet have required considerable 15 // development and are described in hep-ph/0512210. If you use 15 // development. They are described in the original FastJet paper, 16 // hep-ph/0512210 and in the manual, arXiv:1111.6097. If you use 16 17 // FastJet as part of work towards a scientific publication, please 17 // include a citation to the FastJet paper. 18 // quote the version you use and include a citation to the manual and 19 // optionally also to hep-ph/0512210. 18 20 // 19 21 // FastJet is distributed in the hope that it will be useful, … … 25 27 // along with FastJet. If not, see <http://www.gnu.org/licenses/>. 26 28 //---------------------------------------------------------------------- 27 // ENDHEADER29 //FJENDHEADER 28 30 29 31 #include "fastjet/tools/JetMedianBackgroundEstimator.hh" … … 31 33 #include <fastjet/ClusterSequenceStructure.hh> 32 34 #include <iostream> 35 #include <sstream> 33 36 34 37 FASTJET_BEGIN_NAMESPACE // defined in fastjet/internal/base.hh … … 37 40 38 41 double BackgroundJetScalarPtDensity::result(const PseudoJet & jet) const { 39 std::vector<PseudoJet> constituents = jet.constituents(); 42 // do not include the ghosts in the list of constituents to have a 43 // correct behaviour when _pt_power is <= 0 44 std::vector<PseudoJet> constituents = (!SelectorIsPureGhost())(jet.constituents()); 40 45 double scalar_pt = 0; 41 46 for (unsigned i = 0; i < constituents.size(); i++) { … … 43 48 } 44 49 return scalar_pt / jet.area(); 50 } 51 52 53 std::string BackgroundJetScalarPtDensity::description() const { 54 ostringstream oss; 55 oss << "BackgroundScalarJetPtDensity"; 56 if (_pt_power != 1.0) oss << " with pt_power = " << _pt_power; 57 return oss.str(); 45 58 } 46 59 … … 72 85 const JetDefinition &jet_def, 73 86 const AreaDefinition &area_def) 74 : _rho_range(rho_range), _jet_def(jet_def), _area_def(area_def) 87 : _rho_range(rho_range), _jet_def(jet_def), _area_def(area_def){ 75 88 76 89 // initialise things decently … … 261 274 262 275 //---------------------------------------------------------------------- 276 // returns rho_m (particle-masses contribution to the 4-vector density) 277 double JetMedianBackgroundEstimator::rho_m() const { 278 if (! has_rho_m()){ 279 throw Error("JetMediamBackgroundEstimator: rho_m requested but rho_m calculation is disabled (either eplicitly or due to the presence of a jet density class)."); 280 } 281 if (_rho_range.takes_reference()) 282 throw Error("The background estimation is obtained from a selector that takes a reference jet. rho(PseudoJet) should be used in that case"); 283 _recompute_if_needed(); 284 return _rho_m; 285 } 286 287 288 //---------------------------------------------------------------------- 289 // returns sigma_m (particle-masses contribution to the 4-vector 290 // density); must be multipled by sqrt(area) to get fluctuations 291 // for a region of a given area. 292 double JetMedianBackgroundEstimator::sigma_m() const{ 293 if (! has_rho_m()){ 294 throw Error("JetMediamBackgroundEstimator: sigma_m requested but rho_m/sigma_m calculation is disabled (either explicitly or due to the presence of a jet density class)."); 295 } 296 if (_rho_range.takes_reference()) 297 throw Error("The background estimation is obtained from a selector that takes a reference jet. rho(PseudoJet) should be used in that case"); 298 _recompute_if_needed(); 299 return _sigma_m; 300 } 301 302 //---------------------------------------------------------------------- 303 // returns rho_m locally at the position of a given jet. As for 304 // rho(jet), it is non-const. 305 double JetMedianBackgroundEstimator::rho_m(const PseudoJet & jet) { 306 _recompute_if_needed(jet); 307 double our_rho = _rho_m; 308 if (_rescaling_class != 0) { 309 our_rho *= (*_rescaling_class)(jet); 310 } 311 return our_rho; 312 } 313 314 315 //---------------------------------------------------------------------- 316 // returns sigma_m locally at the position of a given jet. As for 317 // rho(jet), it is non-const. 318 double JetMedianBackgroundEstimator::sigma_m(const PseudoJet & jet){ 319 _recompute_if_needed(jet); 320 double our_sigma = _sigma_m; 321 if (_rescaling_class != 0) { 322 our_sigma *= (*_rescaling_class)(jet); 323 } 324 return our_sigma; 325 } 326 327 //---------------------------------------------------------------------- 263 328 // configuring behaviour 264 329 //---------------------------------------------------------------------- … … 271 336 set_provide_fj2_sigma(false); 272 337 338 _enable_rho_m = true; 339 273 340 // reset the computed values 274 341 _rho = _sigma = 0.0; 342 _rho_m = _sigma_m = 0.0; 275 343 _n_jets_used = _n_empty_jets = 0; 276 344 _empty_area = _mean_area = 0.0; … … 289 357 // is used (as occurs also if this function is not called). 290 358 void JetMedianBackgroundEstimator::set_jet_density_class(const FunctionOfPseudoJet<double> * jet_density_class_in) { 291 _warnings_preliminary.warn("JetMedianBackgroundEstimator::set_jet_density_class: density classes are still preliminary in FastJet 3. 0. Their interface may differ in future releases (without guaranteeing backward compatibility).");359 _warnings_preliminary.warn("JetMedianBackgroundEstimator::set_jet_density_class: density classes are still preliminary in FastJet 3.1. Their interface may differ in future releases (without guaranteeing backward compatibility). Note that since FastJet 3.1, rho_m and sigma_m are accessible direclty in JetMedianBackgroundEstimator and GridMedianBackgroundEstimator(with no need for a density class)."); 292 360 _jet_density_class = jet_density_class_in; 293 361 _uptodate = false; … … 338 406 // fill the vector of pt/area (or the quantity from the jet density class) 339 407 // - in the range 340 vector<double> vector_for_median; 408 vector<double> vector_for_median_pt; 409 vector<double> vector_for_median_dt; 341 410 double total_area = 0.0; 342 411 _n_jets_used = 0; … … 346 415 347 416 // compute the pt/area for the selected jets 417 double median_input_pt, median_input_dt=0.0; 418 BackgroundJetPtMDensity m_density; 419 bool do_rho_m = has_rho_m(); 348 420 for (unsigned i = 0; i < selected_jets.size(); i++) { 349 421 const PseudoJet & current_jet = selected_jets[i]; 350 422 351 423 double this_area = (_use_area_4vector) ? current_jet.area_4vector().perp() : current_jet.area(); 352 353 424 if (this_area>0){ 354 double median_input; 425 // for the pt component, we either use pt or the user-provided 426 // density class 355 427 if (_jet_density_class == 0) { 356 median_input = current_jet.perp()/this_area;428 median_input_pt = current_jet.perp()/this_area; 357 429 } else { 358 median_input = (*_jet_density_class)(current_jet);430 median_input_pt = (*_jet_density_class)(current_jet); 359 431 } 432 433 // handle the rho_m part if requested 434 // note that we're using the scalar area as a normalisation inside the 435 // density class! 436 if (do_rho_m) 437 median_input_dt = m_density(current_jet); 438 439 // perform rescaling if needed 360 440 if (_rescaling_class != 0) { 361 median_input /= (*_rescaling_class)(current_jet); 441 double resc = (*_rescaling_class)(current_jet);; 442 median_input_pt /= resc; 443 median_input_dt /= resc; 362 444 } 363 vector_for_median.push_back(median_input); 445 446 // store the result for future computation of the median 447 vector_for_median_pt.push_back(median_input_pt); 448 if (do_rho_m) 449 vector_for_median_dt.push_back(median_input_dt); 450 364 451 total_area += this_area; 365 452 _n_jets_used++; … … 367 454 _warnings_zero_area.warn("JetMedianBackgroundEstimator::_compute(...): discarded jet with zero area. Zero-area jets may be due to (i) too large a ghost area (ii) a jet being outside the ghost range (iii) the computation not being done using an appropriate algorithm (kt;C/A)."); 368 455 } 369 370 456 } 371 457 372 458 // there is nothing inside our region, so answer will always be zero 373 if (vector_for_median .size() == 0) {459 if (vector_for_median_pt.size() == 0) { 374 460 _rho = 0.0; 375 461 _sigma = 0.0; 462 _rho_m = 0.0; 463 _sigma_m = 0.0; 376 464 _mean_area = 0.0; 377 465 return; … … 392 480 393 481 double stand_dev; 394 _median_and_stddev(vector_for_median , _n_empty_jets, _rho, stand_dev,482 _median_and_stddev(vector_for_median_pt, _n_empty_jets, _rho, stand_dev, 395 483 _provide_fj2_sigma); 396 484 … … 398 486 _mean_area = total_area / total_njets; 399 487 _sigma = stand_dev * sqrt(_mean_area); 488 489 // compute the rho_m part now 490 if (do_rho_m){ 491 _median_and_stddev(vector_for_median_dt, _n_empty_jets, _rho_m, stand_dev, 492 _provide_fj2_sigma); 493 _sigma_m = stand_dev * sqrt(_mean_area); 494 } 400 495 401 496 // record that the computation has been performed … … 439 534 440 535 441 442 536 FASTJET_END_NAMESPACE 443 537
Note:
See TracChangeset
for help on using the changeset viewer.