00001 // emacs, this file is -*- c++ -*- 00002 #ifndef JETUTILS_JETCALOHELPER_H 00003 #define JETUTILS_JETCALOHELPER_H 00004 00005 #include "xAODJet/JetConstituentVector.h" 00006 #include "xAODJet/JetAttributes.h" 00007 00008 #include <vector> 00009 00010 #include "xAODJet/Jet.h" 00011 00012 #include "xAODCaloEvent/CaloCluster.h" 00013 00014 namespace CaloConstitHelpers { 00015 00027 struct CaloConstitExtractor { 00028 virtual ~CaloConstitExtractor(){} 00029 virtual bool valid(xAOD::JetConstituentVector::iterator &) {return false;} 00030 virtual double moment( xAOD::JetConstituentVector::iterator & , xAOD::CaloCluster::MomentType ) {return 0;}; 00031 virtual double time(xAOD::JetConstituentVector::iterator & ){return 0.;} 00032 virtual double energyHEC(xAOD::JetConstituentVector::iterator & ){return 0.;} 00033 }; 00034 } 00035 00036 namespace jet { 00072 class JetCaloCalculator { 00073 public: 00074 //typedef typename Jet::navigable_type::paramter_type cellweight_t; 00075 typedef double weight_t; 00076 00077 JetCaloCalculator() : m_name("JetCaloCalculator"){} 00078 JetCaloCalculator(xAOD::JetAttribute::AttributeID id) ; 00079 00080 virtual ~JetCaloCalculator(){} 00081 00082 virtual bool setupEvent() {return true; }; 00083 virtual bool setupJet(const xAOD::Jet* /*jet*/) = 0; 00084 00085 00089 virtual bool processConstituent(xAOD::JetConstituentVector::iterator& /*it*/) {return true;}; 00090 00091 00093 virtual double jetCalculation() const {return 0;}; 00094 00096 virtual double operator()(const xAOD::Jet* jet, xAOD::JetConstitScale s=xAOD::UncalibratedJetConstituent); 00097 00098 virtual std::string name() const {return m_name;} 00099 00100 void setName(std::string n){m_name = n;} 00101 00102 00103 void setExtractor(CaloConstitHelpers::CaloConstitExtractor* ex){m_constitExtractor = ex;} 00104 00106 virtual JetCaloCalculator* clone() const =0; 00107 00108 protected: 00109 std::string m_name; 00110 xAOD::JetAttribute::AttributeID m_id; // unused for now. 00111 CaloConstitHelpers::CaloConstitExtractor *m_constitExtractor; // used to retrieve the cluster moment from the constituent (which can be a PFO object or a cluster) 00112 }; 00113 00114 00119 #define JETCALCFUNCDECL( cname, id, others) \ 00120 public: \ 00121 virtual bool setupJet(const xAOD::Jet* jet); \ 00122 virtual bool processConstituent(xAOD::JetConstituentVector::iterator& iter); \ 00123 double jetCalculation() const ; \ 00124 cname(xAOD::JetAttribute::AttributeID i=id) : JetCaloCalculator( i ) { others } \ 00125 virtual JetCaloCalculator* clone() const {return new cname(*this); } 00126 00127 00141 class JetCaloCalculations { 00142 public: 00143 00144 JetCaloCalculations(bool ownCalc=true) : m_owncalculators(ownCalc) {} 00145 00146 virtual ~JetCaloCalculations(){clear();} 00147 void addCalculator(JetCaloCalculator* c); 00148 00149 bool setupEvent(); 00150 00152 virtual std::vector<double> process(const xAOD::Jet* jet) const ; 00153 00154 void clear(); 00155 00156 00157 size_t numCalculators() const {return m_calculators.size();} 00158 const JetCaloCalculator* at(size_t i) const {return m_calculators[i];} 00159 00160 00161 00162 protected: 00163 std::vector<JetCaloCalculator*> m_calculators; 00164 bool m_owncalculators; 00165 }; 00166 00167 } 00168 #endif