00001
00002
00003
00004 #ifndef PseudoJetGetter_H
00005 #define PseudoJetGetter_H
00006
00007
00008
00009
00030
00031 #include "AsgTools/AsgTool.h"
00032 #include "JetInterface/IPseudoJetGetter.h"
00033 #include "fastjet/PseudoJet.hh"
00034 #include "xAODCaloEvent/CaloClusterContainer.h"
00035 #include "xAODJet/JetContainer.h"
00036 #include "JetEDM/PseudoJetVector.h"
00037 #include "JetEDM/IndexedConstituentUserInfo.h"
00038 #include "JetEDM/LabelIndex.h"
00039
00040 class PseudoJetGetter
00041 : public asg::AsgTool,
00042 virtual public IPseudoJetGetter {
00043 ASG_TOOL_CLASS(PseudoJetGetter, IPseudoJetGetter)
00044
00045 public:
00046
00047 typedef jet::LabelIndex LabelIndex;
00048 typedef jet::PseudoJetVector PseudoJetVector;
00049
00051 PseudoJetGetter(const std::string& myname);
00052
00055 virtual StatusCode initialize();
00056
00061 const PseudoJetVector* get() const;
00062
00065 virtual int appendTo(PseudoJetVector& psjs, const LabelIndex* pli) const;
00066
00069 template<typename TList>
00070 int append(const TList& inputs, PseudoJetVector& psjs, const LabelIndex* pli) const;
00071
00073 std::string label() const;
00074
00076 void print() const;
00077
00082 int inputContainerNames(std::vector<std::string>& connames);
00083
00088 int outputContainerNames(std::vector<std::string>& connames);
00089
00090 protected:
00091
00092 virtual jet::IConstituentUserInfo*
00093 buildCUI(const xAOD::IParticle* ppar, jet::IConstituentUserInfo::Index idx,
00094 const LabelIndex* pli) const;
00095
00096 protected:
00097
00098
00099 std::string m_incoll;
00100 std::string m_outcoll;
00101 std::string m_label;
00102 bool m_skipNegativeEnergy;
00103 double m_ghostscale;
00104 bool m_negEnergyAsGhosts;
00105
00106
00107
00108 bool m_emtopo;
00109
00110 };
00111
00112
00113 #ifdef USE_BOOST_AUTO
00114 #include <boost/typeof/typeof.hpp>
00115 #endif
00116
00117 template<typename TList>
00118 int PseudoJetGetter::
00119 append(const TList& inputs, PseudoJetVector& psjs, const LabelIndex* pli) const {
00120 int nskip = 0;
00121 jet::IConstituentUserInfo::Index labidx = 0;
00122 if ( pli != 0 ) labidx = pli->index(m_label);
00123 else ATH_MSG_WARNING("Index-to-label map is not supplied.");
00124
00125 if(!m_negEnergyAsGhosts && m_ghostscale) labidx = -labidx;
00126 ATH_MSG_DEBUG( "Ghost scale = " << m_ghostscale << "; idx = " << labidx );
00127
00129 #ifdef USE_BOOST_AUTO
00130 for ( BOOST_AUTO(iinp, inputs.begin()); iinp!=inputs.end(); ++iinp ) {
00131 BOOST_AUTO(ppar, *iinp);
00132 #else
00133 for ( auto iinp=inputs.begin(); iinp!=inputs.end(); ++iinp ) {
00134 auto ppar = *iinp;
00135 #endif
00136 if ( ppar == 0 || (m_skipNegativeEnergy && ppar->e() <= 0.0) ) {
00137 if ( ppar == 0 ) ATH_MSG_DEBUG("NUll object!");
00138 else ATH_MSG_VERBOSE("Skipping cluster with E = " << ppar->e());
00139 ++nskip;
00140 continue;
00141 }
00142
00143 fastjet::PseudoJet psj(ppar->p4());
00144
00145 if ( m_emtopo ) {
00146 const xAOD::CaloCluster* pclu = dynamic_cast<const xAOD::CaloCluster*>(ppar);
00147 if ( pclu == 0 ) {
00148 ATH_MSG_WARNING("EM particle is not type CaloCluster");
00149 continue;
00150 }
00151 psj.reset(pclu->p4(xAOD::CaloCluster::UNCALIBRATED));
00152 }
00153
00154 if( m_negEnergyAsGhosts) {
00155 if (ppar->e() <= 0.0) {
00156 psj.reset_momentum(psj.px(), psj.py(), psj.pz(), std::abs( psj.e() ));
00157 psj *= m_ghostscale;
00158 }
00159 } else if ( m_ghostscale ) psj *= m_ghostscale;
00160
00161 bool show = psjs.size() < 20;
00162 if ( show ) ATH_MSG_VERBOSE("index/label: " << labidx << "/" << m_label);
00163 if ( show ) ATH_MSG_VERBOSE("old/p4/new"
00164 << " pt: " << ppar->pt() << "/" << ppar->p4().Pt() << "/" << psj.pt()
00165 << ", pz: /" << ppar->p4().Pz() << "/" << psj.pz()
00166 << ", p: /" << ppar->p4().P() << "/"
00167 << ", E: " << ppar->e() << "/" << ppar->p4().E() << "/" << psj.e()
00168 << ", m: " << ppar->m() << "/" << ppar->p4().M() << "/" << psj.m()
00169 << ", eta: " << ppar->eta() << "/" << ppar->p4().Eta() << "/" << psj.eta()
00170 );
00171 if ( pli != 0 ) {
00172 jet::IConstituentUserInfo* pcui = this->buildCUI(ppar, labidx, pli);
00173 psj.set_user_info(pcui);
00174 if ( show ) ATH_MSG_VERBOSE("User info particle: " << pcui->particle());
00175 }
00176 psjs.push_back(psj);
00177 }
00178
00179 if ( nskip ) ATH_MSG_DEBUG("Skipped constituent count: " << nskip);
00180 ATH_MSG_DEBUG("After append, PseudoJet count is " << psjs.size());
00181 return 0;
00182 }
00183
00184 #endif