FastJets.hh
Go to the documentation of this file.
00001 // -*- C++ -*- 00002 #ifndef RIVET_FastJets_HH 00003 #define RIVET_FastJets_HH 00004 00005 #include "Rivet/Jet.hh" 00006 #include "Rivet/Particle.hh" 00007 #include "Rivet/Projection.hh" 00008 #include "Rivet/Projections/JetAlg.hh" 00009 #include "Rivet/Projections/FinalState.hh" 00010 #include "Rivet/Tools/RivetFastJet.hh" 00011 00012 #include "fastjet/SISConePlugin.hh" 00013 #include "fastjet/ATLASConePlugin.hh" 00014 #include "fastjet/CMSIterativeConePlugin.hh" 00015 #include "fastjet/CDFJetCluPlugin.hh" 00016 #include "fastjet/CDFMidPointPlugin.hh" 00017 #include "fastjet/D0RunIIConePlugin.hh" 00018 #include "fastjet/TrackJetPlugin.hh" 00019 #include "fastjet/JadePlugin.hh" 00020 //#include "fastjet/PxConePlugin.hh" 00021 00022 namespace Rivet { 00023 00024 00025 /// Project out jets found using the FastJet package jet algorithms. 00026 class FastJets : public JetAlg { 00027 public: 00028 00029 /// Wrapper enum for selected FastJet jet algorithms. 00030 /// @todo Move to JetAlg and alias here? 00031 enum JetAlgName { KT, CAM, SISCONE, ANTIKT, 00032 // PXCONE, 00033 ATLASCONE, CMSCONE, 00034 CDFJETCLU, CDFMIDPOINT, D0ILCONE, 00035 JADE, DURHAM, TRACKJET }; 00036 00037 00038 /// @name Constructors etc. 00039 //@{ 00040 00041 /// Constructor from a FastJet JetDefinition 00042 /// 00043 /// @warning The AreaDefinition pointer must be heap-allocated: it will be stored/deleted via a shared_ptr. 00044 FastJets(const FinalState& fsp, 00045 const fastjet::JetDefinition& jdef, 00046 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00047 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES, 00048 fastjet::AreaDefinition* adef=nullptr) 00049 : JetAlg(fsp, usemuons, useinvis), _jdef(jdef), _adef(adef) 00050 { 00051 _initBase(); 00052 } 00053 00054 /// JetDefinition-based constructor with reordered args for easier specification of jet area definition 00055 /// 00056 /// @warning The AreaDefinition pointer must be heap-allocated: it will be stored/deleted via a shared_ptr. 00057 FastJets(const FinalState& fsp, 00058 const fastjet::JetDefinition& jdef, 00059 fastjet::AreaDefinition* adef, 00060 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00061 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES) 00062 : FastJets(fsp, jdef, usemuons, useinvis, adef) 00063 { } 00064 00065 /// Native argument constructor, using FastJet alg/scheme enums. 00066 /// 00067 /// @warning The AreaDefinition pointer must be heap-allocated: it will be stored/deleted via a shared_ptr. 00068 FastJets(const FinalState& fsp, 00069 fastjet::JetAlgorithm type, 00070 fastjet::RecombinationScheme recom, double rparameter, 00071 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00072 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES, 00073 fastjet::AreaDefinition* adef=nullptr) 00074 : FastJets(fsp, fastjet::JetDefinition(type, rparameter, recom), usemuons, useinvis, adef) 00075 { } 00076 00077 /// Native argument constructor with reordered args for easier specification of jet area definition 00078 /// 00079 /// @warning The AreaDefinition pointer must be heap-allocated: it will be stored/deleted via a shared_ptr. 00080 FastJets(const FinalState& fsp, 00081 fastjet::JetAlgorithm type, 00082 fastjet::RecombinationScheme recom, double rparameter, 00083 fastjet::AreaDefinition* adef, 00084 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00085 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES) 00086 : FastJets(fsp, type, recom, rparameter, usemuons, useinvis, adef) 00087 { } 00088 00089 /// @brief Explicitly pass in an externally-constructed plugin 00090 /// 00091 /// @warning Provided plugin and area definition pointers must be heap-allocated; Rivet will store/delete via a shared_ptr 00092 FastJets(const FinalState& fsp, 00093 fastjet::JetDefinition::Plugin* plugin, 00094 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00095 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES, 00096 fastjet::AreaDefinition* adef=nullptr) 00097 : FastJets(fsp, fastjet::JetDefinition(plugin), usemuons, useinvis, adef) 00098 { 00099 _plugin.reset(plugin); 00100 } 00101 00102 /// @brief Explicitly pass in an externally-constructed plugin, with reordered args for easier specification of jet area definition 00103 /// 00104 /// @warning Provided plugin and area definition pointers must be heap-allocated; Rivet will store/delete via a shared_ptr 00105 FastJets(const FinalState& fsp, 00106 fastjet::JetDefinition::Plugin* plugin, 00107 fastjet::AreaDefinition* adef, 00108 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00109 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES) 00110 : FastJets(fsp, plugin, usemuons, useinvis, adef) 00111 { } 00112 00113 /// @brief Convenience constructor using Rivet enums for most common jet algs (including some plugins). 00114 /// 00115 /// For the built-in algs, E-scheme recombination is used. For full control 00116 /// of FastJet built-in jet algs, use the constructors from native-args or a 00117 /// plugin pointer. 00118 /// 00119 /// @warning Provided area definition pointer must be heap-allocated; Rivet will store/delete via a shared_ptr 00120 FastJets(const FinalState& fsp, 00121 JetAlgName alg, double rparameter, 00122 JetAlg::MuonsStrategy usemuons=JetAlg::ALL_MUONS, 00123 JetAlg::InvisiblesStrategy useinvis=JetAlg::NO_INVISIBLES, 00124 fastjet::AreaDefinition* adef=nullptr, 00125 double seed_threshold=1.0) 00126 : JetAlg(fsp, usemuons, useinvis) 00127 { 00128 _initBase(); 00129 _initJdef(alg, rparameter, seed_threshold); 00130 } 00131 00132 00133 // /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) 00134 // /// @todo Does this work properly, without internal HeavyQuarks etc.? 00135 // FastJets(JetAlgName alg, double rparameter, double seed_threshold=1.0) { _initJdef(alg, rparameter, seed_threshold); } 00136 // /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) 00137 // /// @todo Does this work properly, without internal HeavyQuarks etc.? 00138 // FastJets(fastjet::JetAlgorithm type, fastjet::RecombinationScheme recom, double rparameter) { _initJdef(type, recom, rparameter); } 00139 // /// Same thing as above, but without an FS (for when we want to pass the particles directly to the calc method) 00140 // /// @todo Does this work properly, without internal HeavyQuarks etc.? 00141 // FastJets(fastjet::JetDefinition::Plugin* plugin) : _jdef(plugin), _plugin(plugin) { 00142 // // _plugin.reset(plugin); 00143 // // _jdef = fastjet::JetDefinition(plugin); 00144 // } 00145 00146 00147 /// Clone on the heap. 00148 DEFAULT_RIVET_PROJ_CLONE(FastJets); 00149 00150 //@} 00151 00152 00153 /// Reset the projection. Jet def, etc. are unchanged. 00154 void reset(); 00155 00156 00157 /// @brief Use provided jet area definition 00158 /// 00159 /// @warning The provided pointer must be heap-allocated: it will be stored/deleted via a shared_ptr. 00160 /// @note Provide an adef null pointer to re-disable jet area calculation 00161 void useJetArea(fastjet::AreaDefinition* adef) { 00162 _adef.reset(adef); 00163 } 00164 00165 00166 /// @name Access to the jets 00167 //@{ 00168 00169 /// Get the jets (unordered) with pT > ptmin. 00170 Jets _jets() const; 00171 00172 /// Get the pseudo jets (unordered). 00173 PseudoJets pseudoJets(double ptmin=0.0) const; 00174 /// Alias 00175 PseudoJets pseudojets(double ptmin=0.0) const { return pseudoJets(ptmin); } 00176 00177 /// Get the pseudo jets, ordered by \f$ p_T \f$. 00178 PseudoJets pseudoJetsByPt(double ptmin=0.0) const { 00179 return sorted_by_pt(pseudoJets(ptmin)); 00180 } 00181 /// Alias 00182 PseudoJets pseudojetsByPt(double ptmin=0.0) const { return pseudoJetsByPt(ptmin); } 00183 00184 /// Get the pseudo jets, ordered by \f$ E \f$. 00185 PseudoJets pseudoJetsByE(double ptmin=0.0) const { 00186 return sorted_by_E(pseudoJets(ptmin)); 00187 } 00188 /// Alias 00189 PseudoJets pseudojetsByE(double ptmin=0.0) const { return pseudoJetsByE(ptmin); } 00190 00191 /// Get the pseudo jets, ordered by rapidity. 00192 PseudoJets pseudoJetsByRapidity(double ptmin=0.0) const { 00193 return sorted_by_rapidity(pseudoJets(ptmin)); 00194 } 00195 /// Alias 00196 PseudoJets pseudojetsByRapidity(double ptmin=0.0) const { return pseudoJetsByRapidity(ptmin); } 00197 00198 /// Trim (filter) a jet, keeping tag and constituent info in the resulting jet 00199 Jet trimJet(const Jet& input, const fastjet::Filter& trimmer) const; 00200 00201 //@} 00202 00203 00204 /// @name Access to the FastJet clustering objects such as jet def, area def, and cluster 00205 //@{ 00206 00207 /// Return the cluster sequence. 00208 /// @todo Care needed re. const shared_ptr<T> vs. shared_ptr<const T> 00209 const shared_ptr<fastjet::ClusterSequence> clusterSeq() const { 00210 return _cseq; 00211 } 00212 // const fastjet::ClusterSequence* clusterSeq() const { 00213 // return _cseq.get(); 00214 // } 00215 00216 /// Return the area-enabled cluster sequence (if an area defn exists, otherwise returns a null ptr). 00217 /// @todo Care needed re. const shared_ptr<T> vs. shared_ptr<const T> 00218 const shared_ptr<fastjet::ClusterSequenceArea> clusterSeqArea() const { 00219 return areaDef() ? dynamic_pointer_cast<fastjet::ClusterSequenceArea>(_cseq) : nullptr; 00220 } 00221 // const fastjet::ClusterSequenceArea* clusterSeqArea() const { 00222 // return areaDef() ? dynamic_cast<fastjet::ClusterSequenceArea*>(_cseq.get()) : nullptr; 00223 // } 00224 00225 /// Return the jet definition. 00226 const fastjet::JetDefinition& jetDef() const { 00227 return _jdef; 00228 } 00229 00230 /// @brief Return the area definition. 00231 /// 00232 /// @warning May be null! 00233 /// @todo Care needed re. const shared_ptr<T> vs. shared_ptr<const T> 00234 const shared_ptr<fastjet::AreaDefinition> areaDef() const { 00235 return _adef; 00236 } 00237 // const fastjet::AreaDefinition* areaDef() const { 00238 // return _adef.get(); 00239 // } 00240 00241 //@} 00242 00243 00244 private: 00245 00246 /// Shared utility functions to implement constructor behaviour 00247 /// @todo Replace with calls between constructors when C++11 available? 00248 void _initBase(); 00249 void _initJdef(JetAlgName alg, double rparameter, double seed_threshold); 00250 // void _init2(fastjet::JetAlgorithm type, fastjet::RecombinationScheme recom, double rparameter); 00251 // void _init3(const fastjet::JetDefinition& plugin); 00252 // void _init4(fastjet::JetDefinition::Plugin* plugin); 00253 00254 /// Function to make Rivet::Jet from fastjet::PseudoJet, including constituent and tag info 00255 Jet _mkJet(const PseudoJet& pj) const; 00256 00257 protected: 00258 00259 /// Perform the projection on the Event. 00260 void project(const Event& e); 00261 00262 /// Compare projections. 00263 int compare(const Projection& p) const; 00264 00265 public: 00266 00267 /// Do the calculation locally (no caching). 00268 void calc(const Particles& fsparticles, const Particles& tagparticles=Particles()); 00269 00270 00271 private: 00272 00273 /// Jet definition 00274 fastjet::JetDefinition _jdef; 00275 00276 /// Pointer to user-handled area definition 00277 std::shared_ptr<fastjet::AreaDefinition> _adef; 00278 00279 /// Cluster sequence 00280 std::shared_ptr<fastjet::ClusterSequence> _cseq; 00281 00282 /// FastJet external plugin 00283 std::shared_ptr<fastjet::JetDefinition::Plugin> _plugin; 00284 00285 /// Map of vectors of y scales. This is mutable so we can use caching/lazy evaluation. 00286 mutable std::map<int, vector<double> > _yscales; 00287 00288 /// set of particles sorted by their PT2 00289 //set<Particle, ParticleBase::byPTAscending> _particles; 00290 std::map<int, Particle> _particles; 00291 00292 }; 00293 00294 } 00295 00296 #endif Generated on Thu Sep 22 2016 17:50:28 for The Rivet MC analysis system by ![]() |