Changes in modules/FastJetFinder.cc [35807af:341014c] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/FastJetFinder.cc
r35807af r341014c 17 17 */ 18 18 19 20 19 /** \class FastJetFinder 21 20 * … … 32 31 #include "classes/DelphesFormula.h" 33 32 33 #include "ExRootAnalysis/ExRootClassifier.h" 34 #include "ExRootAnalysis/ExRootFilter.h" 34 35 #include "ExRootAnalysis/ExRootResult.h" 35 #include "ExRootAnalysis/ExRootFilter.h" 36 #include "ExRootAnalysis/ExRootClassifier.h" 37 36 37 #include "TDatabasePDG.h" 38 #include "TFormula.h" 39 #include "TLorentzVector.h" 38 40 #include "TMath.h" 41 #include "TObjArray.h" 42 #include "TRandom3.h" 39 43 #include "TString.h" 40 #include "TFormula.h"41 #include "TRandom3.h"42 #include "TObjArray.h"43 #include "TDatabasePDG.h"44 #include "TLorentzVector.h"45 44 46 45 #include <algorithm> 47 #include <stdexcept>48 46 #include <iostream> 49 47 #include <sstream> 48 #include <stdexcept> 50 49 #include <vector> 51 50 51 #include "fastjet/ClusterSequence.hh" 52 #include "fastjet/ClusterSequenceArea.hh" 53 #include "fastjet/JetDefinition.hh" 52 54 #include "fastjet/PseudoJet.hh" 53 #include "fastjet/JetDefinition.hh"54 #include "fastjet/ClusterSequence.hh"55 55 #include "fastjet/Selector.hh" 56 #include "fastjet/ClusterSequenceArea.hh"57 56 #include "fastjet/tools/JetMedianBackgroundEstimator.hh" 58 57 58 #include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh" 59 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh" 59 60 #include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh" 60 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh" 61 #include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh" 62 63 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh" 61 62 #include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh" 64 63 #include "fastjet/contribs/Nsubjettiness/Njettiness.hh" 65 64 #include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh" 66 #include "fastjet/contribs/Nsubjettiness/ ExtraRecombiners.hh"65 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh" 67 66 68 67 #include "fastjet/contribs/ValenciaPlugin/ValenciaPlugin.hh" 69 68 69 #include "fastjet/contribs/RecursiveTools/SoftDrop.hh" 70 70 #include "fastjet/tools/Filter.hh" 71 71 #include "fastjet/tools/Pruner.hh" 72 #include "fastjet/contribs/RecursiveTools/SoftDrop.hh"73 72 74 73 using namespace std; 75 74 using namespace fastjet; 76 75 using namespace fastjet::contrib; 77 78 76 79 77 //------------------------------------------------------------------------------ … … 83 81 fDefinition(0), fAreaDefinition(0), fItInputArray(0) 84 82 { 85 86 83 } 87 84 … … 90 87 FastJetFinder::~FastJetFinder() 91 88 { 92 93 89 } 94 90 … … 120 116 fJetPTMin = GetDouble("JetPTMin", 10.0); 121 117 122 123 118 //-- N(sub)jettiness parameters -- 124 119 … … 127 122 fAxisMode = GetInt("AxisMode", 1); 128 123 fRcutOff = GetDouble("RcutOff", 0.8); // used only if Njettiness is used as jet clustering algo (case 8) 129 fN = GetInt("N", 2); 124 fN = GetInt("N", 2); // used only if Njettiness is used as jet clustering algo (case 8) 130 125 131 126 //-- Exclusive clustering for e+e- collisions -- 132 133 fNJets = GetInt("NJets", 2);127 128 fNJets = GetInt("NJets", 2); 134 129 fExclusiveClustering = GetBool("ExclusiveClustering", false); 135 130 136 131 //-- Valencia Linear Collider algorithm 132 137 133 fGamma = GetDouble("Gamma", 1.0); 138 134 //fBeta parameter see above 139 135 140 136 fMeasureDef = new NormalizedMeasure(fBeta, fParameterR); 141 137 142 138 switch(fAxisMode) 143 139 { 144 145 146 147 148 149 150 151 152 153 154 155 156 140 default: 141 case 1: 142 fAxesDef = new WTA_KT_Axes(); 143 break; 144 case 2: 145 fAxesDef = new OnePass_WTA_KT_Axes(); 146 break; 147 case 3: 148 fAxesDef = new KT_Axes(); 149 break; 150 case 4: 151 fAxesDef = new OnePass_KT_Axes(); 152 } 157 153 158 154 //-- Trimming parameters -- 159 155 160 156 fComputeTrimming = GetBool("ComputeTrimming", false); 161 157 fRTrim = GetDouble("RTrim", 0.2); 162 158 fPtFracTrim = GetDouble("PtFracTrim", 0.05); 163 164 159 165 160 //-- Pruning parameters -- 166 161 167 162 fComputePruning = GetBool("ComputePruning", false); 168 163 fZcutPrun = GetDouble("ZcutPrun", 0.1); 169 164 fRcutPrun = GetDouble("RcutPrun", 0.5); 170 165 fRPrun = GetDouble("RPrun", 0.8); 171 166 172 167 //-- SoftDrop parameters -- 173 174 fComputeSoftDrop 175 fBetaSoftDrop 168 169 fComputeSoftDrop = GetBool("ComputeSoftDrop", false); 170 fBetaSoftDrop = GetDouble("BetaSoftDrop", 0.0); 176 171 fSymmetryCutSoftDrop = GetDouble("SymmetryCutSoftDrop", 0.1); 177 fR0SoftDrop= GetDouble("R0SoftDrop=", 0.8); 178 172 fR0SoftDrop = GetDouble("R0SoftDrop=", 0.8); 179 173 180 174 // --- Jet Area Parameters --- 175 181 176 fAreaAlgorithm = GetInt("AreaAlgorithm", 0); 182 177 fComputeRho = GetBool("ComputeRho", false); … … 195 190 switch(fAreaAlgorithm) 196 191 { 197 case 1:198 fAreaDefinition = new AreaDefinition(active_area_explicit_ghosts, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));199 break;200 case 2:201 fAreaDefinition = new AreaDefinition(one_ghost_passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));202 break;203 case 3:204 fAreaDefinition = new AreaDefinition(passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));205 break;206 case 4:207 fAreaDefinition = new AreaDefinition(VoronoiAreaSpec(fEffectiveRfact));208 break;209 case 5:210 fAreaDefinition = new AreaDefinition(active_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));211 break;212 default:213 case 0:214 fAreaDefinition = 0;215 192 default: 193 case 0: 194 fAreaDefinition = 0; 195 break; 196 case 1: 197 fAreaDefinition = new AreaDefinition(active_area_explicit_ghosts, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt)); 198 break; 199 case 2: 200 fAreaDefinition = new AreaDefinition(one_ghost_passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt)); 201 break; 202 case 3: 203 fAreaDefinition = new AreaDefinition(passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt)); 204 break; 205 case 4: 206 fAreaDefinition = new AreaDefinition(VoronoiAreaSpec(fEffectiveRfact)); 207 break; 208 case 5: 209 fAreaDefinition = new AreaDefinition(active_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt)); 210 break; 216 211 } 217 212 218 213 switch(fJetAlgorithm) 219 214 { 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 215 case 1: 216 plugin = new CDFJetCluPlugin(fSeedThreshold, fConeRadius, fAdjacencyCut, fMaxIterations, fIratch, fOverlapThreshold); 217 fDefinition = new JetDefinition(plugin); 218 break; 219 case 2: 220 plugin = new CDFMidPointPlugin(fSeedThreshold, fConeRadius, fConeAreaFraction, fMaxPairSize, fMaxIterations, fOverlapThreshold); 221 fDefinition = new JetDefinition(plugin); 222 break; 223 case 3: 224 plugin = new SISConePlugin(fConeRadius, fOverlapThreshold, fMaxIterations, fJetPTMin); 225 fDefinition = new JetDefinition(plugin); 226 break; 227 case 4: 228 fDefinition = new JetDefinition(kt_algorithm, fParameterR); 229 break; 230 case 5: 231 fDefinition = new JetDefinition(cambridge_algorithm, fParameterR); 232 break; 233 default: 234 case 6: 235 fDefinition = new JetDefinition(antikt_algorithm, fParameterR); 236 break; 237 case 7: 238 recomb = new WinnerTakeAllRecombiner(); 239 fDefinition = new JetDefinition(antikt_algorithm, fParameterR, recomb, Best); 240 break; 241 case 8: 242 fNjettinessPlugin = new NjettinessPlugin(fN, Njettiness::wta_kt_axes, Njettiness::unnormalized_cutoff_measure, fBeta, fRcutOff); 243 fDefinition = new JetDefinition(fNjettinessPlugin); 244 break; 250 245 case 9: 251 fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma); 252 fDefinition = new JetDefinition(fValenciaPlugin); 253 break; 254 255 } 256 257 246 fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma); 247 fDefinition = new JetDefinition(fValenciaPlugin); 248 break; 249 } 258 250 259 251 fPlugin = plugin; … … 270 262 271 263 fEstimators.clear(); 272 for(i = 0; i < size /2; ++i)273 { 274 etaMin = param[i *2].GetDouble();275 etaMax = param[i *2 + 1].GetDouble();264 for(i = 0; i < size / 2; ++i) 265 { 266 etaMin = param[i * 2].GetDouble(); 267 etaMax = param[i * 2 + 1].GetDouble(); 276 268 estimatorStruct.estimator = new JetMedianBackgroundEstimator(SelectorRapRange(etaMin, etaMax), *fDefinition, *fAreaDefinition); 277 269 estimatorStruct.etaMin = etaMin; … … 290 282 fOutputArray = ExportArray(GetString("OutputArray", "jets")); 291 283 fRhoOutputArray = ExportArray(GetString("RhoOutputArray", "rho")); 284 fConstituentsOutputArray = ExportArray(GetString("ConstituentsOutputArray", "constituents")); 292 285 } 293 286 … … 296 289 void FastJetFinder::Finish() 297 290 { 298 vector< TEstimatorStruct>::iterator itEstimators;291 vector<TEstimatorStruct>::iterator itEstimators; 299 292 300 293 for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators) … … 306 299 if(fDefinition) delete fDefinition; 307 300 if(fAreaDefinition) delete fAreaDefinition; 308 if(fPlugin) delete static_cast<JetDefinition::Plugin *>(fPlugin);309 if(fRecomb) delete static_cast<JetDefinition::Recombiner *>(fRecomb);310 if(fNjettinessPlugin) delete static_cast<JetDefinition::Plugin *>(fNjettinessPlugin);301 if(fPlugin) delete static_cast<JetDefinition::Plugin *>(fPlugin); 302 if(fRecomb) delete static_cast<JetDefinition::Recombiner *>(fRecomb); 303 if(fNjettinessPlugin) delete static_cast<JetDefinition::Plugin *>(fNjettinessPlugin); 311 304 if(fAxesDef) delete fAxesDef; 312 305 if(fMeasureDef) delete fMeasureDef; 313 if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin*>(fValenciaPlugin); 314 306 if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin *>(fValenciaPlugin); 315 307 } 316 308 … … 325 317 Double_t time, timeWeight; 326 318 Int_t number, ncharged, nneutrals; 327 Int_t charge; 319 Int_t charge; 328 320 Double_t rho = 0.0; 329 321 PseudoJet jet, area; 330 322 ClusterSequence *sequence; 331 vector< PseudoJet> inputList, outputList, subjets;332 vector< PseudoJet>::iterator itInputList, itOutputList;333 vector< TEstimatorStruct>::iterator itEstimators;323 vector<PseudoJet> inputList, outputList, subjets; 324 vector<PseudoJet>::iterator itInputList, itOutputList; 325 vector<TEstimatorStruct>::iterator itEstimators; 334 326 Double_t excl_ymerge23 = 0.0; 335 327 Double_t excl_ymerge34 = 0.0; 336 328 Double_t excl_ymerge45 = 0.0; 337 329 Double_t excl_ymerge56 = 0.0; 338 330 339 331 DelphesFactory *factory = GetFactory(); 340 332 … … 344 336 fItInputArray->Reset(); 345 337 number = 0; 346 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))338 while((candidate = static_cast<Candidate *>(fItInputArray->Next()))) 347 339 { 348 340 momentum = candidate->Momentum; … … 381 373 outputList.clear(); 382 374 383 384 375 if(fExclusiveClustering) 385 { 386 try{ 387 outputList = sorted_by_pt(sequence->exclusive_jets( fNJets )); 388 } 389 catch(fastjet::Error) 390 { 391 outputList.clear(); 392 } 393 394 excl_ymerge23 = sequence->exclusive_ymerge( 2 ); 395 excl_ymerge34 = sequence->exclusive_ymerge( 3 ); 396 excl_ymerge45 = sequence->exclusive_ymerge( 4 ); 397 excl_ymerge56 = sequence->exclusive_ymerge( 5 ); 398 } 376 { 377 try 378 { 379 outputList = sorted_by_pt(sequence->exclusive_jets(fNJets)); 380 } 381 catch(fastjet::Error) 382 { 383 outputList.clear(); 384 } 385 386 excl_ymerge23 = sequence->exclusive_ymerge(2); 387 excl_ymerge34 = sequence->exclusive_ymerge(3); 388 excl_ymerge45 = sequence->exclusive_ymerge(4); 389 excl_ymerge56 = sequence->exclusive_ymerge(5); 390 } 399 391 else 400 401 402 392 { 393 outputList = sorted_by_pt(sequence->inclusive_jets(fJetPTMin)); 394 } 403 395 404 396 // loop over all jets and export them 405 397 detaMax = 0.0; 406 398 dphiMax = 0.0; 407 399 408 400 for(itOutputList = outputList.begin(); itOutputList != outputList.end(); ++itOutputList) 409 401 { … … 416 408 if(fAreaDefinition) area = itOutputList->area_4vector(); 417 409 418 419 420 410 candidate = factory->NewCandidate(); 421 411 … … 434 424 { 435 425 if(itInputList->user_index() < 0) continue; 436 constituent = static_cast<Candidate *>(fInputArray->At(itInputList->user_index()));426 constituent = static_cast<Candidate *>(fInputArray->At(itInputList->user_index())); 437 427 438 428 deta = TMath::Abs(momentum.Eta() - constituent->Momentum.Eta()); … … 441 431 if(dphi > dphiMax) dphiMax = dphi; 442 432 443 if(constituent->Charge == 0) nneutrals++; 444 else ncharged++; 445 446 time += TMath::Sqrt(constituent->Momentum.E())*(constituent->Position.T()); 433 if(constituent->Charge == 0) 434 nneutrals++; 435 else 436 ncharged++; 437 438 time += TMath::Sqrt(constituent->Momentum.E()) * (constituent->Position.T()); 447 439 timeWeight += TMath::Sqrt(constituent->Momentum.E()); 448 440 449 441 charge += constituent->Charge; 450 442 443 fConstituentsOutputArray->Add(constituent); 451 444 candidate->AddCandidate(constituent); 452 445 } 453 446 454 447 candidate->Momentum = momentum; 455 candidate->Position.SetT(time /timeWeight);448 candidate->Position.SetT(time / timeWeight); 456 449 candidate->Area.SetPxPyPzE(area.px(), area.py(), area.pz(), area.E()); 457 450 458 451 candidate->DeltaEta = detaMax; 459 452 candidate->DeltaPhi = dphiMax; 460 candidate->Charge = charge; 453 candidate->Charge = charge; 461 454 candidate->NNeutrals = nneutrals; 462 455 candidate->NCharged = ncharged; 463 464 456 465 457 //for exclusive clustering, access y_n,n+1 as exclusive_ymerge (fNJets); … … 468 460 candidate->ExclYmerge45 = excl_ymerge45; 469 461 candidate->ExclYmerge56 = excl_ymerge56; 470 462 471 463 //------------------------------------ 472 464 // Trimming … … 476 468 { 477 469 478 fastjet::Filter trimmer(fastjet::JetDefinition(fastjet::kt_algorithm,fRTrim),fastjet::SelectorPtFractionMin(fPtFracTrim));470 fastjet::Filter trimmer(fastjet::JetDefinition(fastjet::kt_algorithm, fRTrim), fastjet::SelectorPtFractionMin(fPtFracTrim)); 479 471 fastjet::PseudoJet trimmed_jet = trimmer(*itOutputList); 480 472 481 473 trimmed_jet = join(trimmed_jet.constituents()); 482 474 483 475 candidate->TrimmedP4[0].SetPtEtaPhiM(trimmed_jet.pt(), trimmed_jet.eta(), trimmed_jet.phi(), trimmed_jet.m()); 484 485 // four hardest subjets 476 477 // four hardest subjets 486 478 subjets.clear(); 487 479 subjets = trimmed_jet.pieces(); 488 480 subjets = sorted_by_pt(subjets); 489 481 490 482 candidate->NSubJetsTrimmed = subjets.size(); 491 483 492 for 484 for(size_t i = 0; i < subjets.size() and i < 4; i++) 493 485 { 494 if(subjets.at(i).pt() < 0) continue ; 495 candidate->TrimmedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());486 if(subjets.at(i).pt() < 0) continue; 487 candidate->TrimmedP4[i + 1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m()); 496 488 } 497 489 } 498 499 490 500 491 //------------------------------------ 501 492 // Pruning 502 493 //------------------------------------ 503 504 494 505 495 if(fComputePruning) 506 496 { 507 497 508 fastjet::Pruner pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm,fRPrun),fZcutPrun,fRcutPrun);498 fastjet::Pruner pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm, fRPrun), fZcutPrun, fRcutPrun); 509 499 fastjet::PseudoJet pruned_jet = pruner(*itOutputList); 510 500 511 501 candidate->PrunedP4[0].SetPtEtaPhiM(pruned_jet.pt(), pruned_jet.eta(), pruned_jet.phi(), pruned_jet.m()); 512 513 // four hardest subjet 502 503 // four hardest subjet 514 504 subjets.clear(); 515 505 subjets = pruned_jet.pieces(); 516 506 subjets = sorted_by_pt(subjets); 517 507 518 508 candidate->NSubJetsPruned = subjets.size(); 519 509 520 for 510 for(size_t i = 0; i < subjets.size() and i < 4; i++) 521 511 { 522 if(subjets.at(i).pt() < 0) continue ; 523 candidate->PrunedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());512 if(subjets.at(i).pt() < 0) continue; 513 candidate->PrunedP4[i + 1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m()); 524 514 } 525 526 } 527 515 } 516 528 517 //------------------------------------ 529 518 // SoftDrop 530 519 //------------------------------------ 531 520 532 521 if(fComputeSoftDrop) 533 522 { 534 535 contrib::SoftDrop softDrop(fBetaSoftDrop, fSymmetryCutSoftDrop,fR0SoftDrop);523 524 contrib::SoftDrop softDrop(fBetaSoftDrop, fSymmetryCutSoftDrop, fR0SoftDrop); 536 525 fastjet::PseudoJet softdrop_jet = softDrop(*itOutputList); 537 526 538 527 candidate->SoftDroppedP4[0].SetPtEtaPhiM(softdrop_jet.pt(), softdrop_jet.eta(), softdrop_jet.phi(), softdrop_jet.m()); 539 540 // four hardest subjet 541 528 529 // four hardest subjet 530 542 531 subjets.clear(); 543 subjets 544 subjets 532 subjets = softdrop_jet.pieces(); 533 subjets = sorted_by_pt(subjets); 545 534 candidate->NSubJetsSoftDropped = softdrop_jet.pieces().size(); 546 535 547 536 candidate->SoftDroppedJet = candidate->SoftDroppedP4[0]; 548 537 549 for (size_t i = 0; i < subjets.size()and i < 4; i++)538 for(size_t i = 0; i < subjets.size() and i < 4; i++) 550 539 { 551 if(subjets.at(i).pt() < 0) continue ; 552 candidate->SoftDroppedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());553 if(i==0) candidate->SoftDroppedSubJet1 = candidate->SoftDroppedP4[i+1];554 if(i==1) candidate->SoftDroppedSubJet2 = candidate->SoftDroppedP4[i+1];540 if(subjets.at(i).pt() < 0) continue; 541 candidate->SoftDroppedP4[i + 1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m()); 542 if(i == 0) candidate->SoftDroppedSubJet1 = candidate->SoftDroppedP4[i + 1]; 543 if(i == 1) candidate->SoftDroppedSubJet2 = candidate->SoftDroppedP4[i + 1]; 555 544 } 556 545 } 557 546 558 547 // --- compute N-subjettiness with N = 1,2,3,4,5 ---- 559 548 560 549 if(fComputeNsubjettiness) 561 550 { 562 551 563 552 Nsubjettiness nSub1(1, *fAxesDef, *fMeasureDef); 564 553 Nsubjettiness nSub2(2, *fAxesDef, *fMeasureDef); … … 566 555 Nsubjettiness nSub4(4, *fAxesDef, *fMeasureDef); 567 556 Nsubjettiness nSub5(5, *fAxesDef, *fMeasureDef); 568 557 569 558 candidate->Tau[0] = nSub1(*itOutputList); 570 559 candidate->Tau[1] = nSub2(*itOutputList); … … 572 561 candidate->Tau[3] = nSub4(*itOutputList); 573 562 candidate->Tau[4] = nSub5(*itOutputList); 574 575 563 } 576 564
Note:
See TracChangeset
for help on using the changeset viewer.