StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StjFastJet.cxx
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 31 Aug 2011
5 //
6 // $Id: StjFastJet.cxx,v 1.3 2016/01/06 22:00:17 gdwebb Exp $
7 //
8 // $Log: StjFastJet.cxx,v $
9 // Revision 1.3 2016/01/06 22:00:17 gdwebb
10 // This is code to implement the off axis cone underlying event analysis.
11 //
12 // Revision 1.2 2012/03/10 23:09:53 pibero
13 // Addeed support for fastjet plugins
14 //
15 // Revision 1.1 2011/08/31 17:58:01 pibero
16 // Support for FastJet
17 //
18 // http://www.lpthe.jussieu.fr/~salam/fastjet/
19 // http://www.star.bnl.gov/HyperNews-star/protected/get/starsoft/8521.html
20 //
21 //
22 
23 #include <vector>
24 #include "fastjet/ClusterSequence.hh"
25 #include "fastjet/ClusterSequenceArea.hh"
26 #include "StjFastJet.h"
27 
28 void StjFastJet::findJets(JetList& protoJetList, const FourVecList& particleList)
29 {
30  // Read in input particles
31  std::vector<fastjet::PseudoJet> inputParticles;
32  for (size_t i = 0; i < particleList.size(); ++i) {
33  fastjet::PseudoJet pseudojet(particleList[i]->px(),particleList[i]->py(),particleList[i]->pz(),particleList[i]->e());
34  pseudojet.set_user_index(i);
35  inputParticles.push_back(pseudojet);
36  }
37  if(!mPars.jetAreaFlag()){
38  // Run the jet clustering with the above jet definition
39  fastjet::ClusterSequence clusterSequence(inputParticles,jetDefinition());
40  // Extract inclusive jets with pt > ptmin
41  std::vector<fastjet::PseudoJet> inclusiveJets = clusterSequence.inclusive_jets(mPars.ptMin());
42  for (size_t i = 0; i < inclusiveJets.size(); ++i) {
43  StProtoJet protojet;
44  std::vector<fastjet::PseudoJet> constituents = clusterSequence.constituents(inclusiveJets[i]);
45  for (size_t j = 0; j < constituents.size(); ++j) {
46  const_cast<FourVecList&>(protojet.list()).push_back(particleList[constituents[j].user_index()]);
47  }
48  protojet.update();
49  protoJetList.push_back(protojet);
50  }
51 
52  }else if(mPars.jetAreaFlag()){
53  //jet clustering with ghost area
54  fastjet::ClusterSequenceArea clusterSequenceArea(inputParticles, jetDefinition(), areaDefinition());
55  std::vector<fastjet::PseudoJet> inclusiveJets = clusterSequenceArea.inclusive_jets(mPars.ptMin());
56  for (size_t i = 0; i < inclusiveJets.size(); ++i) {
57  StProtoJet protojet;
58  std::vector<fastjet::PseudoJet> constituents = clusterSequenceArea.constituents(inclusiveJets[i]);
59  protojet.setArea(inclusiveJets[i].area());
60  protojet.setAreaError(inclusiveJets[i].area_error());
61  for (size_t j = 0; j < constituents.size(); ++j) {
62  const_cast<FourVecList&>(protojet.list()).push_back(particleList[constituents[j].user_index()]);
63  }
64  protojet.update();
65  protoJetList.push_back(protojet);
66  }
67  }
68 }
69 
70 fastjet::JetDefinition StjFastJet::jetDefinition() const
71 {
72  return (mPars.jetAlgorithm() == fastjet::plugin_algorithm)
73  ? fastjet::JetDefinition(static_cast<fastjet::JetDefinition::Plugin*>(mPars.plugin()))
74  : fastjet::JetDefinition(static_cast<fastjet::JetAlgorithm>(mPars.jetAlgorithm()),
75  mPars.Rparam(),
76  static_cast<fastjet::RecombinationScheme>(mPars.recombinationScheme()),
77  static_cast<fastjet::Strategy>(mPars.strategy()));
78 }
79 fastjet::AreaDefinition StjFastJet::areaDefinition() const
80 {
81  fastjet::GhostedAreaSpec area_spec(mPars.jetArea()->ghostMaxRap(), mPars.jetArea()->repeat(), mPars.jetArea()->ghostArea(), mPars.jetArea()->gridScatter(), mPars.jetArea()->ptScatter(), mPars.jetArea()->meanGhostPt());
82  return fastjet::AreaDefinition(static_cast<fastjet::AreaType>(mPars.jetArea()->areaType()), area_spec);
83 }