00001
00002 #ifndef JETREC_FASTJETINTERFACETOOL_H
00003 #define JETREC_FASTJETINTERFACETOOL_H
00004
00005
00006 #include "AsgTools/AsgTool.h"
00007
00008
00009 #include "fastjet/ClusterSequence.hh"
00010 #include "fastjet/JetDefinition.hh"
00011 #include "fastjet/AreaDefinition.hh"
00012
00013 #include "JetInterface/IFastJetInterfaceTool.h"
00014
00015 #include <map>
00016 #include <string>
00017 #include <vector>
00018 #include <stdint.h>
00019
00020 #ifdef ASGTOOL_ATHENA
00021
00022 #include "fastjet/SISConePlugin.hh"
00023 #include "fastjet/CMSIterativeConePlugin.hh"
00024 #endif
00025
00026
00027
00028 namespace FastJetInterface
00029 {
00031 typedef std::map<std::string,fastjet::JetAlgorithm> algomap_t;
00033 typedef std::map<std::string,fastjet::Strategy> strategymap_t;
00035 typedef std::map<std::string,fastjet::RecombinationScheme> schememap_t;
00037 #ifdef ASGTOOL_ATHENA
00038 typedef std::map<std::string,fastjet::SISConePlugin::SplitMergeScale> splitMergeScaleMap_t;
00039 #else
00040 typedef std::map<std::string,int> splitMergeScaleMap_t;
00041 #endif
00042
00043 typedef std::map<std::string,fastjet::AreaType> areamap_t;
00044
00046 typedef fastjet::PseudoJet fjet_t;
00048 typedef std::vector<fjet_t> fjetlist_t;
00049
00050
00051
00052
00053
00054
00066 template<class D,class M>
00067 static bool chkConfig(const std::string& key,D& tag,const M& map)
00068 {
00069
00070 typename M::const_iterator fMap(map.find(key));
00071 if ( fMap != map.end() ) { tag = (*fMap).second; return true; }
00072 else { return false; }
00073 }
00074
00086 template<class D,class M>
00087 const std::string& cfgName(D tag,const M& map,const std::string& invalidKey)
00088 {
00089 typename M::const_iterator fMap(map.begin());
00090 typename M::const_iterator lMap(map.end());
00091 while ( fMap != lMap && (*fMap).second != tag ) { ++fMap; }
00092 return fMap != lMap ? (*fMap).first : invalidKey;
00093 }
00094 }
00095
00102 class FastJetInterfaceTool : virtual public asg::AsgTool,
00103 virtual public IFastJetInterfaceTool {
00104
00105 public:
00106
00107 ASG_TOOL_CLASS(FastJetInterfaceTool, IFastJetInterfaceTool)
00108
00109
00110 FastJetInterfaceTool(const std::string& n);
00112 virtual ~FastJetInterfaceTool();
00113
00118 virtual StatusCode initialize();
00119
00129 virtual StatusCode execute(const fjetlist_t& inJets,fjetlist_t& outJets);
00130
00139 virtual fastjet::ClusterSequence* clusterSequence();
00140
00149 virtual const fastjet::ClusterSequence* clusterSequence() const;
00150
00162 template<class S>
00163 S* specificClusterSequence()
00164 { return dynamic_cast<S*>(this->clusterSequence()); }
00165
00166
00178 template<class S>
00179 const S* specificClusterSequence() const
00180 { return dynamic_cast<const S*>(this->clusterSequence()); }
00181
00188 const fastjet::JetDefinition* getJetDefinition() const;
00189
00196 const fastjet::AreaDefinition* getAreaDefinition() const;
00197
00204 const std::string getAreaDefinitionType() const;
00205
00207 const FastJetInterface::algomap_t& getKnownAlgorithms();
00209 const FastJetInterface::strategymap_t& getKnownStrategies();
00211 const FastJetInterface::schememap_t& getKnownRecombinationSchemes();
00213 const FastJetInterface::splitMergeScaleMap_t& getKnownSplitMergeScales();
00215 const FastJetInterface::areamap_t& getKnownAreas();
00216
00217 protected:
00218
00220 std::string m_clusterSequenceType;
00222 std::string m_jetAlgorithmType;
00224 std::string m_clusterStrategyType;
00226 std::string m_recombinationSchemeType;
00227
00229 double m_CMS_seedThreshold;
00231 double m_SIS_overlapThreshold;
00233 int m_SIS_nPass;
00235 double m_SIS_protojetPtMin;
00237 bool m_SIS_doCaching;
00239 std::string m_SIS_splitMergeScale_STRING;
00241 double m_SIS_splitMergeStopScale;
00242
00244 double m_radius;
00246 bool m_inclusive;
00248 double m_exclusiveDcut;
00250 int m_exclusiveNjets;
00252 double m_pTmin;
00253
00255 bool m_doJetArea;
00257 std::string m_jetAreaDefinitionType;
00259 double m_voronoiEffectiveRfact;
00261 double m_ghostedMaxRap;
00263 double m_ghostedMinRap;
00265 int m_ghostedRepeat;
00267 double m_ghostedArea;
00269 double m_ghostedGridScatter;
00271 double m_ghostedKtScatter;
00273 double m_ghostedMeanKt;
00274
00282 bool checkConfig(const std::string& key,fastjet::JetAlgorithm& fjalg);
00283
00291 bool checkConfig(const std::string& key,fastjet::Strategy& fjstr);
00292
00300 bool checkConfig(const std::string& key,fastjet::RecombinationScheme& fjrs);
00301
00309 #ifdef ASGTOOL_ATHENA
00310 bool checkConfig(const std::string& key,fastjet::SISConePlugin::SplitMergeScale& fjsms);
00311 #endif
00312
00319 bool checkConfig(const std::string& tag,fastjet::AreaType& fjart);
00320
00327 const std::string& configName(fastjet::JetAlgorithm fjalg);
00328
00335 const std::string& configName(fastjet::Strategy fjstr);
00336
00343 const std::string& configName(fastjet::RecombinationScheme fjrs);
00344
00351 #ifdef ASGTOOL_ATHENA
00352 const std::string& configName(fastjet::SISConePlugin::SplitMergeScale fjsms);
00353 #endif
00354
00361 const std::string& configName(fastjet::AreaType fjart);
00362
00363
00364 private:
00365
00367 static std::string m_invalidKeyReference;
00368
00370 static FastJetInterface::algomap_t s_knownAlgorithms;
00372 static FastJetInterface::strategymap_t s_knownStrategies;
00374 static FastJetInterface::schememap_t s_knownRecombinationSchemes;
00376 static FastJetInterface::splitMergeScaleMap_t s_knownSplitMergeScales;
00378 static FastJetInterface::areamap_t s_knownAreas;
00379
00381 unsigned int m_failedExecCtr;
00383 static unsigned int m_failedExecCtrMax;
00384
00385
00386
00387
00388 protected:
00389
00391 fastjet::JetAlgorithm m_jetAlgorithm;
00393 fastjet::Strategy m_strategy;
00395 fastjet::AreaType m_areaType;
00397 fastjet::RecombinationScheme m_recombinationScheme;
00399 #ifdef ASGTOOL_ATHENA
00400 fastjet::SISConePlugin::SplitMergeScale m_SIS_splitMergeScale;
00401 #endif
00402
00403 fastjet::JetDefinition* m_jetDefinition;
00405 fastjet::ClusterSequence* m_clusterSequence;
00407 fastjet::AreaDefinition* m_areaDefinition;
00408
00410 uint64_t m_baseRNDSeed;
00412 uint64_t m_userRNDSeed;
00413
00414
00416 typedef StatusCode
00417 (FastJetInterfaceTool::*PROCESSOR)(const FastJetInterface::fjetlist_t& inJets,
00418 FastJetInterface::fjetlist_t& outJets);
00420 typedef StatusCode
00421 (FastJetInterfaceTool::*EXTRACTOR)(FastJetInterface::fjetlist_t& outJets);
00422
00424 PROCESSOR m_processor;
00426 EXTRACTOR m_extractor;
00427
00443 StatusCode f_processWithoutArea(const FastJetInterface::fjetlist_t& inJets,
00444 FastJetInterface::fjetlist_t& outJets);
00445
00460 StatusCode f_processWithArea(const FastJetInterface::fjetlist_t& inJets,
00461 FastJetInterface::fjetlist_t& outJets);
00462
00469 StatusCode configJetAreas();
00480 StatusCode f_extractInclusive(FastJetInterface::fjetlist_t& outJets);
00491 StatusCode f_extractExclDcut(FastJetInterface::fjetlist_t& outJets);
00502 StatusCode f_extractExclNjets(FastJetInterface::fjetlist_t& outJets);
00503
00504
00505
00507 virtual void updateRandomSeeds();
00508
00509
00510 };
00511
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552 #endif