Changeset 341014c in git for modules/FastJetFinder.cc
- Timestamp:
- Feb 12, 2019, 9:29:17 PM (6 years ago)
- Branches:
- ImprovedOutputFile, Timing, llp, master
- Children:
- 6455202
- Parents:
- 45e58be
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/FastJetFinder.cc
r45e58be 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 … … 126 122 fAxisMode = GetInt("AxisMode", 1); 127 123 fRcutOff = GetDouble("RcutOff", 0.8); // used only if Njettiness is used as jet clustering algo (case 8) 128 fN = GetInt("N", 2); 124 fN = GetInt("N", 2); // used only if Njettiness is used as jet clustering algo (case 8) 129 125 130 126 //-- Exclusive clustering for e+e- collisions -- 131 127 132 fNJets = GetInt("NJets", 2);128 fNJets = GetInt("NJets", 2); 133 129 fExclusiveClustering = GetBool("ExclusiveClustering", false); 134 130 … … 142 138 switch(fAxisMode) 143 139 { 144 145 146 147 148 149 150 151 152 153 154 155 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(); 156 152 } 157 153 … … 161 157 fRTrim = GetDouble("RTrim", 0.2); 162 158 fPtFracTrim = GetDouble("PtFracTrim", 0.05); 163 164 159 165 160 //-- Pruning parameters -- … … 172 167 //-- SoftDrop parameters -- 173 168 174 fComputeSoftDrop 175 fBetaSoftDrop 169 fComputeSoftDrop = GetBool("ComputeSoftDrop", false); 170 fBetaSoftDrop = GetDouble("BetaSoftDrop", 0.0); 176 171 fSymmetryCutSoftDrop = GetDouble("SymmetryCutSoftDrop", 0.1); 177 fR0SoftDrop = GetDouble("R0SoftDrop=", 0.8);172 fR0SoftDrop = GetDouble("R0SoftDrop=", 0.8); 178 173 179 174 // --- Jet Area Parameters --- … … 195 190 switch(fAreaAlgorithm) 196 191 { 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 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 case 1: 221 plugin = new CDFJetCluPlugin(fSeedThreshold, fConeRadius, fAdjacencyCut, fMaxIterations, fIratch, fOverlapThreshold); 222 fDefinition = new JetDefinition(plugin); 223 break; 224 case 2: 225 plugin = new CDFMidPointPlugin(fSeedThreshold, fConeRadius, fConeAreaFraction, fMaxPairSize, fMaxIterations, fOverlapThreshold); 226 fDefinition = new JetDefinition(plugin); 227 break; 228 case 3: 229 plugin = new SISConePlugin(fConeRadius, fOverlapThreshold, fMaxIterations, fJetPTMin); 230 fDefinition = new JetDefinition(plugin); 231 break; 232 case 4: 233 fDefinition = new JetDefinition(kt_algorithm, fParameterR); 234 break; 235 case 5: 236 fDefinition = new JetDefinition(cambridge_algorithm, fParameterR); 237 break; 238 default: 239 case 6: 240 fDefinition = new JetDefinition(antikt_algorithm, fParameterR); 241 break; 242 case 7: 243 recomb = new WinnerTakeAllRecombiner(); 244 fDefinition = new JetDefinition(antikt_algorithm, fParameterR, recomb, Best); 245 break; 246 case 8: 247 fNjettinessPlugin = new NjettinessPlugin(fN, Njettiness::wta_kt_axes, Njettiness::unnormalized_cutoff_measure, fBeta, fRcutOff); 248 fDefinition = new JetDefinition(fNjettinessPlugin); 249 break; 250 case 9: 251 fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma); 252 fDefinition = new JetDefinition(fValenciaPlugin); 253 break; 254 255 } 256 257 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; 245 case 9: 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; … … 297 289 void FastJetFinder::Finish() 298 290 { 299 vector< TEstimatorStruct>::iterator itEstimators;291 vector<TEstimatorStruct>::iterator itEstimators; 300 292 301 293 for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators) … … 307 299 if(fDefinition) delete fDefinition; 308 300 if(fAreaDefinition) delete fAreaDefinition; 309 if(fPlugin) delete static_cast<JetDefinition::Plugin *>(fPlugin);310 if(fRecomb) delete static_cast<JetDefinition::Recombiner *>(fRecomb);311 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); 312 304 if(fAxesDef) delete fAxesDef; 313 305 if(fMeasureDef) delete fMeasureDef; 314 if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin*>(fValenciaPlugin); 315 306 if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin *>(fValenciaPlugin); 316 307 } 317 308 … … 330 321 PseudoJet jet, area; 331 322 ClusterSequence *sequence; 332 vector< PseudoJet> inputList, outputList, subjets;333 vector< PseudoJet>::iterator itInputList, itOutputList;334 vector< TEstimatorStruct>::iterator itEstimators;323 vector<PseudoJet> inputList, outputList, subjets; 324 vector<PseudoJet>::iterator itInputList, itOutputList; 325 vector<TEstimatorStruct>::iterator itEstimators; 335 326 Double_t excl_ymerge23 = 0.0; 336 327 Double_t excl_ymerge34 = 0.0; … … 345 336 fItInputArray->Reset(); 346 337 number = 0; 347 while((candidate = static_cast<Candidate *>(fItInputArray->Next())))338 while((candidate = static_cast<Candidate *>(fItInputArray->Next()))) 348 339 { 349 340 momentum = candidate->Momentum; … … 383 374 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 … … 432 424 { 433 425 if(itInputList->user_index() < 0) continue; 434 constituent = static_cast<Candidate *>(fInputArray->At(itInputList->user_index()));426 constituent = static_cast<Candidate *>(fInputArray->At(itInputList->user_index())); 435 427 436 428 deta = TMath::Abs(momentum.Eta() - constituent->Momentum.Eta()); … … 439 431 if(dphi > dphiMax) dphiMax = dphi; 440 432 441 if(constituent->Charge == 0) nneutrals++; 442 else ncharged++; 443 444 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()); 445 439 timeWeight += TMath::Sqrt(constituent->Momentum.E()); 446 440 … … 452 446 453 447 candidate->Momentum = momentum; 454 candidate->Position.SetT(time /timeWeight);448 candidate->Position.SetT(time / timeWeight); 455 449 candidate->Area.SetPxPyPzE(area.px(), area.py(), area.pz(), area.E()); 456 450 … … 461 455 candidate->NCharged = ncharged; 462 456 463 464 457 //for exclusive clustering, access y_n,n+1 as exclusive_ymerge (fNJets); 465 458 candidate->ExclYmerge23 = excl_ymerge23; … … 475 468 { 476 469 477 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)); 478 471 fastjet::PseudoJet trimmed_jet = trimmer(*itOutputList); 479 472 … … 489 482 candidate->NSubJetsTrimmed = subjets.size(); 490 483 491 for 484 for(size_t i = 0; i < subjets.size() and i < 4; i++) 492 485 { 493 if(subjets.at(i).pt() < 0) continue;494 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()); 495 488 } 496 489 } 497 498 490 499 491 //------------------------------------ … … 501 493 //------------------------------------ 502 494 503 504 495 if(fComputePruning) 505 496 { 506 497 507 fastjet::Pruner pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm,fRPrun),fZcutPrun,fRcutPrun);498 fastjet::Pruner pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm, fRPrun), fZcutPrun, fRcutPrun); 508 499 fastjet::PseudoJet pruned_jet = pruner(*itOutputList); 509 500 … … 517 508 candidate->NSubJetsPruned = subjets.size(); 518 509 519 for 510 for(size_t i = 0; i < subjets.size() and i < 4; i++) 520 511 { 521 if(subjets.at(i).pt() < 0) continue;522 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()); 523 514 } 524 525 515 } 526 516 … … 532 522 { 533 523 534 contrib::SoftDrop softDrop(fBetaSoftDrop, fSymmetryCutSoftDrop,fR0SoftDrop);524 contrib::SoftDrop softDrop(fBetaSoftDrop, fSymmetryCutSoftDrop, fR0SoftDrop); 535 525 fastjet::PseudoJet softdrop_jet = softDrop(*itOutputList); 536 526 … … 540 530 541 531 subjets.clear(); 542 subjets 543 subjets 532 subjets = softdrop_jet.pieces(); 533 subjets = sorted_by_pt(subjets); 544 534 candidate->NSubJetsSoftDropped = softdrop_jet.pieces().size(); 545 535 546 536 candidate->SoftDroppedJet = candidate->SoftDroppedP4[0]; 547 537 548 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++) 549 539 { 550 if(subjets.at(i).pt() < 0) continue;551 candidate->SoftDroppedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());552 if(i==0) candidate->SoftDroppedSubJet1 = candidate->SoftDroppedP4[i+1];553 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]; 554 544 } 555 545 } … … 571 561 candidate->Tau[3] = nSub4(*itOutputList); 572 562 candidate->Tau[4] = nSub5(*itOutputList); 573 574 563 } 575 564
Note:
See TracChangeset
for help on using the changeset viewer.