Fork me on GitHub

Changeset d77b51d in git for modules/FastJetFinder.cc


Ignore:
Timestamp:
Sep 29, 2015, 2:08:10 PM (9 years ago)
Author:
Michele Selvaggi <michele.selvaggi@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
a98c7ef
Parents:
d870fc5 (diff), 06ec139 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge remote-tracking branch 'upstream/master'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/FastJetFinder.cc

    rd870fc5 rd77b51d  
    6666#include "fastjet/contribs/Nsubjettiness/WinnerTakeAllRecombiner.hh"
    6767
     68#include "fastjet/tools/Filter.hh"
     69#include "fastjet/tools/Pruner.hh"
     70#include "fastjet/contribs/RecursiveTools/SoftDrop.hh"
     71
    6872using namespace std;
    6973using namespace fastjet;
     
    9296  JetDefinition::Plugin *plugin = 0;
    9397  JetDefinition::Recombiner *recomb = 0;
    94   NjettinessPlugin *njetPlugin = 0;
    95 
    96   // read eta ranges
    97 
    98   ExRootConfParam param = GetParam("RhoEtaRange");
     98  ExRootConfParam param;
    9999  Long_t i, size;
    100 
    101   fEtaRangeMap.clear();
    102   size = param.GetSize();
    103   for(i = 0; i < size/2; ++i)
    104   {
    105     fEtaRangeMap[param[i*2].GetDouble()] = param[i*2 + 1].GetDouble();
    106   }
     100  Double_t etaMin, etaMax;
     101  TEstimatorStruct estimatorStruct;
    107102
    108103  // define algorithm
     
    130125  fN = GetInt("N", 2);                  // used only if Njettiness is used as jet clustering algo (case 8)
    131126
     127  //-- Trimming parameters --
     128 
     129  fComputeTrimming = GetBool("ComputeTrimming", false);
     130  fRTrim = GetDouble("RTrim", 0.2);
     131  fPtFracTrim = GetDouble("PtFracTrim", 0.05);
     132 
     133
     134  //-- Pruning parameters --
     135 
     136  fComputePruning = GetBool("ComputePruning", false);
     137  fZcutPrun = GetDouble("ZcutPrun", 0.1);
     138  fRcutPrun = GetDouble("RcutPrun", 0.5);
     139  fRPrun = GetDouble("RPrun", 0.8);
     140 
     141  //-- SoftDrop parameters --
     142 
     143  fComputeSoftDrop     = GetBool("ComputeSoftDrop", false);
     144  fBetaSoftDrop        = GetDouble("BetaSoftDrop", 0.0);
     145  fSymmetryCutSoftDrop = GetDouble("SymmetryCutSoftDrop", 0.1);
     146  fR0SoftDrop= GetDouble("R0SoftDrop=", 0.8);
     147 
     148
    132149  // ---  Jet Area Parameters ---
    133150  fAreaAlgorithm = GetInt("AreaAlgorithm", 0);
     
    197214      break;
    198215    case 8:
    199       njetPlugin = new NjettinessPlugin(fN, Njettiness::wta_kt_axes, Njettiness::unnormalized_cutoff_measure, fBeta, fRcutOff);
    200       fDefinition = new JetDefinition(njetPlugin);
     216      fNjettinessPlugin = new NjettinessPlugin(fN, Njettiness::wta_kt_axes, Njettiness::unnormalized_cutoff_measure, fBeta, fRcutOff);
     217      fDefinition = new JetDefinition(fNjettinessPlugin);
    201218      break;
    202219  }
     
    204221  fPlugin = plugin;
    205222  fRecomb = recomb;
    206   fNjettinessPlugin = njetPlugin;
    207223
    208224  ClusterSequence::print_banner();
     225
     226  if(fComputeRho && fAreaDefinition)
     227  {
     228    // read eta ranges
     229
     230    param = GetParam("RhoEtaRange");
     231    size = param.GetSize();
     232
     233    fEstimators.clear();
     234    for(i = 0; i < size/2; ++i)
     235    {
     236      etaMin = param[i*2].GetDouble();
     237      etaMax = param[i*2 + 1].GetDouble();
     238      estimatorStruct.estimator = new JetMedianBackgroundEstimator(SelectorEtaRange(etaMin, etaMax), *fDefinition, *fAreaDefinition);
     239      estimatorStruct.etaMin = etaMin;
     240      estimatorStruct.etaMax = etaMax;
     241      fEstimators.push_back(estimatorStruct);
     242    }
     243  }
    209244
    210245  // import input array
     
    223258void FastJetFinder::Finish()
    224259{
     260  vector< TEstimatorStruct >::iterator itEstimators;
     261
     262  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
     263  {
     264    if(itEstimators->estimator) delete itEstimators->estimator;
     265  }
     266
    225267  if(fItInputArray) delete fItInputArray;
    226268  if(fDefinition) delete fDefinition;
     
    241283  Double_t time, timeWeight;
    242284  Int_t number;
     285  Int_t charge;
    243286  Double_t rho = 0.0;
    244287  PseudoJet jet, area;
    245   vector<PseudoJet> inputList, outputList;
    246288  ClusterSequence *sequence;
    247   map< Double_t, Double_t >::iterator itEtaRangeMap;
     289  vector< PseudoJet > inputList, outputList, subjets;
     290  vector< PseudoJet >::iterator itInputList, itOutputList;
     291  vector< TEstimatorStruct >::iterator itEstimators;
    248292
    249293  DelphesFactory *factory = GetFactory();
     
    276320  if(fComputeRho && fAreaDefinition)
    277321  {
    278     for(itEtaRangeMap = fEtaRangeMap.begin(); itEtaRangeMap != fEtaRangeMap.end(); ++itEtaRangeMap)
    279     {
    280       Selector select_rapidity = SelectorAbsRapRange(itEtaRangeMap->first, itEtaRangeMap->second);
    281       JetMedianBackgroundEstimator estimator(select_rapidity, *fDefinition, *fAreaDefinition);
    282       estimator.set_particles(inputList);
    283       rho = estimator.rho();
     322    for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
     323    {
     324      itEstimators->estimator->set_particles(inputList);
     325      rho = itEstimators->estimator->rho();
    284326
    285327      candidate = factory->NewCandidate();
    286328      candidate->Momentum.SetPtEtaPhiE(rho, 0.0, 0.0, rho);
    287       candidate->Edges[0] = itEtaRangeMap->first;
    288       candidate->Edges[1] = itEtaRangeMap->second;
     329      candidate->Edges[0] = itEstimators->etaMin;
     330      candidate->Edges[1] = itEstimators->etaMax;
    289331      fRhoOutputArray->Add(candidate);
    290332    }
     
    298340  detaMax = 0.0;
    299341  dphiMax = 0.0;
    300   vector<PseudoJet>::iterator itInputList, itOutputList;
    301342  for(itOutputList = outputList.begin(); itOutputList != outputList.end(); ++itOutputList)
    302343  {
     
    314355    timeWeight = 0.0;
    315356
     357    charge = 0;
     358
    316359    inputList.clear();
    317360    inputList = sequence->constituents(*itOutputList);
     
    319362    for(itInputList = inputList.begin(); itInputList != inputList.end(); ++itInputList)
    320363    {
     364      if(itInputList->user_index() < 0) continue;
    321365      constituent = static_cast<Candidate*>(fInputArray->At(itInputList->user_index()));
    322366
     
    329373      timeWeight += TMath::Sqrt(constituent->Momentum.E());
    330374
     375      charge += constituent->Charge;
     376
    331377      candidate->AddCandidate(constituent);
    332378    }
     
    338384    candidate->DeltaEta = detaMax;
    339385    candidate->DeltaPhi = dphiMax;
    340 
     386    candidate->Charge = charge;
     387    //------------------------------------
     388    // Trimming
     389    //------------------------------------
     390
     391     if(fComputeTrimming)
     392    {
     393
     394      fastjet::Filter    trimmer(fastjet::JetDefinition(fastjet::kt_algorithm,fRTrim),fastjet::SelectorPtFractionMin(fPtFracTrim));
     395      fastjet::PseudoJet trimmed_jet = trimmer(*itOutputList);
     396     
     397      trimmed_jet = join(trimmed_jet.constituents());
     398     
     399      candidate->TrimmedP4[0].SetPtEtaPhiM(trimmed_jet.pt(), trimmed_jet.eta(), trimmed_jet.phi(), trimmed_jet.m());
     400       
     401      // four hardest subjets
     402      subjets.clear();
     403      subjets = trimmed_jet.pieces();
     404      subjets = sorted_by_pt(subjets);
     405     
     406      candidate->NSubJetsTrimmed = subjets.size();
     407
     408      for (size_t i = 0; i < subjets.size() and i < 4; i++){
     409        if(subjets.at(i).pt() < 0) continue ;
     410        candidate->TrimmedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
     411      }
     412    }
     413   
     414   
     415    //------------------------------------
     416    // Pruning
     417    //------------------------------------
     418   
     419   
     420    if(fComputePruning)
     421    {
     422
     423      fastjet::Pruner    pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm,fRPrun),fZcutPrun,fRcutPrun);
     424      fastjet::PseudoJet pruned_jet = pruner(*itOutputList);
     425
     426      candidate->PrunedP4[0].SetPtEtaPhiM(pruned_jet.pt(), pruned_jet.eta(), pruned_jet.phi(), pruned_jet.m());
     427         
     428      // four hardest subjet
     429      subjets.clear();
     430      subjets = pruned_jet.pieces();
     431      subjets = sorted_by_pt(subjets);
     432     
     433      candidate->NSubJetsPruned = subjets.size();
     434
     435      for (size_t i = 0; i < subjets.size() and i < 4; i++){
     436        if(subjets.at(i).pt() < 0) continue ;
     437        candidate->PrunedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
     438      }
     439
     440    }
     441     
     442    //------------------------------------
     443    // SoftDrop
     444    //------------------------------------
     445   
     446    if(fComputeSoftDrop)
     447    {
     448   
     449      contrib::SoftDrop  softDrop(fBetaSoftDrop,fSymmetryCutSoftDrop,fR0SoftDrop);
     450      fastjet::PseudoJet softdrop_jet = softDrop(*itOutputList);
     451     
     452      candidate->SoftDroppedP4[0].SetPtEtaPhiM(softdrop_jet.pt(), softdrop_jet.eta(), softdrop_jet.phi(), softdrop_jet.m());
     453       
     454      // four hardest subjet
     455     
     456      subjets.clear();
     457      subjets    = softdrop_jet.pieces();
     458      subjets    = sorted_by_pt(subjets);
     459      candidate->NSubJetsSoftDropped = softdrop_jet.pieces().size();
     460
     461      for (size_t i = 0; i < subjets.size()  and i < 4; i++){
     462        if(subjets.at(i).pt() < 0) continue ;
     463        candidate->SoftDroppedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
     464      }
     465    }
     466 
    341467    // --- compute N-subjettiness with N = 1,2,3,4,5 ----
    342468
     
    377503    }
    378504
    379 
    380505    fOutputArray->Add(candidate);
    381506  }
Note: See TracChangeset for help on using the changeset viewer.