00001
00002
00003
00004
00005 #ifndef _Atlfast_AtlfastProtoJetMaker_H
00006 #define _Atlfast_AtlfastProtoJetMaker_H
00007
00008
00009
00010 #include "CLHEP/Vector/LorentzVector.h"
00011 #include "CLHEP/Vector/ThreeVector.h"
00012 #include <vector>
00013 #include <string>
00014
00015
00016 #include "GaudiKernel/ISvcLocator.h"
00017 #include "GaudiKernel/Algorithm.h"
00018 #include "GaudiKernel/MsgStream.h"
00019 #include "GaudiKernel/DataObject.h"
00020
00021 #include "HepMC/GenEvent.h"
00022 #include "HepMC/GenParticle.h"
00023 #include "JetRec/Jet.h"
00024
00025 #include "AtlfastCode/AtlfastProtoJet.h"
00026
00027 #include "AtlfastCode/HepMC_helper.h"
00028 #include "AtlfastCode/TesIO.h"
00029 #include "AtlfastCode/Cell.h"
00030 #include "AtlfastCode/ISmearer.h"
00031 #include "AtlfastCode/JetSmearer.h"
00032
00033
00034
00035
00036 #define DEFAULT_inputCellLocation "/Event/AtlfastCells"
00037 #define DEFAULT_inputClusterLocation "/Event/AtlfastClusters"
00038 #define DEFAULT_outputTowerPJKey "/Event/AtlfastTowerProtoJets"
00039 #define DEFAULT_outputClusterPJKey "/Event/AtlfastClusterProtoJets"
00040 #define DEFAULT_outputFinalStatePJKey "/Event/AtlfastFinalStateProtoJets"
00041 #define DEFAULT_outputTowerJetKey "/Event/AtlfastTowerJets"
00042 #define DEFAULT_outputClusterJetKey "/Event/AtlfastClusterJets"
00043 #define DEFAULT_outputFinalStateJetKey "/Event/AtlfastFinalStateJets"
00044 #define DEFAULT_towerPJConstruct true
00045 #define DEFAULT_clusterPJConstruct true
00046 #define DEFAULT_finalStatePJConstruct true
00047 #define DEFAULT_finalStatePJConstruct true
00048 #define DEFAULT_towerPJSmearOn false
00049 #define DEFAULT_clusterPJSmearOn false
00050
00051 namespace Atlfast {
00052
00061 class AtlfastProtoJetMaker : public Algorithm {
00062
00063 public:
00064
00066 AtlfastProtoJetMaker(const std::string& name, ISvcLocator* pSvcLocator);
00068 ~AtlfastProtoJetMaker();
00069
00071 StatusCode initialize();
00073 StatusCode execute();
00075
00076 StatusCode finalize();
00077
00078 private:
00079
00080
00081
00083 std::string m_inputCellLocation;
00084 std::string m_inputClusterLocation;
00086 std::string m_outputTowerPJKey;
00087 std::string m_outputClusterPJKey;
00088 std::string m_outputFinalStatePJKey;
00090 std::string m_outputTowerJetKey;
00091 std::string m_outputClusterJetKey;
00092 std::string m_outputFinalStateJetKey;
00094 TesIO* m_tesIO;
00095 bool m_notInit;
00096 bool m_towerPJConstruct;
00097 bool m_clusterPJConstruct;
00098 bool m_finalStatePJConstruct;
00099 bool m_towerPJSmearOn;
00100 bool m_clusterPJSmearOn;
00101
00102
00103
00104
00105
00106 ISmearer* m_smearer;
00107
00108
00109 template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00110 T2*,
00111 const std::string&,
00112 const std::string&);
00113 template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00114 T2*,
00115 const std::string&,
00116 const std::string&,
00117 bool);
00118 template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00119 T2*);
00120 };
00121
00122
00123 template <class T1, class T2> inline
00124 StatusCode AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00125 T2* proJ,
00126 const std::string& PJoutputLocation,
00127 const std::string& JoutputLocation)
00128 {
00129 bool smear = false;
00130 return this->FillProtoJets(vec,proJ,PJoutputLocation, JoutputLocation, smear);
00131 }
00132
00133 template <class T1, class T2> inline
00134 StatusCode AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00135 T2* proJ,
00136 const std::string& PJoutputLocation,
00137 const std::string& JoutputLocation,
00138 bool smear)
00139 {
00140 MsgStream log( messageService(), name() ) ;
00141 ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00142 ObjectVector< ::Jet >* jets = new ObjectVector< ::Jet >;
00143 typename std::vector<T1*>::const_iterator itr = vec.begin();
00144 HepLorentzVector hepvec;
00145 ::Jet* jet;
00146 for (; itr != vec.end(); ++itr) {
00147 hepvec = (*itr)->momentum();
00148 if(smear){
00149 hepvec = m_smearer->smear(hepvec);
00150 }
00151 proJ = new T2(hepvec);
00152 pjs->push_back(proJ);
00153 jet = new ::Jet();
00154 jet->add(*proJ,1.);
00155 jets->push_back(jet);
00156 }
00157 log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00158
00159 TesIoStat stat = m_tesIO -> store(pjs, PJoutputLocation);
00160 std::string message = stat ? "AtlfastProtoJet stored by key":"Failed to store AtlfastProtoJet by key";
00161 log<<MSG::DEBUG<<message<<endreq;
00162 if (!stat) {return StatusCode::FAILURE;}
00163
00164 stat = m_tesIO -> store(pjs, JoutputLocation);
00165 message = stat ? "JetRec Jet stored by key":"Failed to store JetRec Jet by key";
00166 log<<MSG::DEBUG<<message<<endreq;
00167 return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00168 }
00169
00170 template <class T1, class T2> inline
00171 StatusCode AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00172 T2* proJ)
00173 {
00174 MsgStream log( messageService(), name() ) ;
00175 ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00176 typename std::vector<T1*>::const_iterator itr = vec.begin();
00177 for (; itr != vec.end(); ++itr) {
00178 proJ = new T2((*itr)->momentum());
00179 pjs->push_back(proJ);
00180 }
00181 log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00182
00183 TesIoStat stat = m_tesIO -> store(pjs);
00184 std::string message = stat ? "AtlfastProtoJet stored by type":"Failed to store AtlfastProtoJet type";
00185 log<<MSG::DEBUG<<message<<endreq;
00186 return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00187 }
00188
00189 }
00190 #endif
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209