00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef ATLFAST_EVENTHEADERMAKER_H
00027 #define ATLFAST_EVENTHEADERMAKER_H
00028
00029
00030 #include <string>
00031
00032 #include <vector>
00033
00034
00035 #include "GaudiKernel/Algorithm.h"
00036
00037
00038
00039 #include "CLHEP/Vector/LorentzVector.h"
00040
00041
00042 #include "AtlfastEvent/Jet.h"
00043 #include "AtlfastUtils/TesIO.h"
00044
00045 class ISvcLocator;
00046 class MsgStream;
00047 namespace HepMC_helper{
00048 class IMCselector;
00049 }
00050 namespace Atlfast {
00051 class TesIO;
00052 class Jet;
00053 using std::string;
00061 class EventHeaderMaker : public Algorithm{
00062
00063 public:
00064
00065
00066
00067
00068
00069
00070
00072 EventHeaderMaker( const std::string& name, ISvcLocator* pSvcLocator ) ;
00074 virtual ~EventHeaderMaker();
00075
00076
00077
00078
00079
00080
00082 StatusCode initialize() ;
00084 StatusCode execute() ;
00086 StatusCode finalize() ;
00087
00088
00089
00090 private:
00091
00092
00093
00094
00095
00096
00098 template <class Type> int numberInList(std::string tesAddress, Type);
00100 int numberJetFlavor(std::string tesAddress, int);
00102 HepLorentzVector missingMomentum(MsgStream&);
00104 HepLorentzVector escapedMomentum(MsgStream&);
00107 template <class Type>
00108 HepLorentzVector momentumSum(std::string tesAddress, Type dummy);
00111 template <class Type>
00112 HepLorentzVector smearAndSum(std::string tesAddress, Type dummy);
00115 template <class Type, class AssType>
00116 HepLorentzVector assocMomentumSum(std::string tesAddress,
00117 Type dum1, AssType dum2);
00119 HepLorentzVector unusedClusterSum();
00121 HepLorentzVector unusedMuonSum();
00123 HepLorentzVector unusedCellSum();
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 std::string m_electronLocation ;
00134 std::string m_photonLocation ;
00135 std::string m_isolatedMuonLocation;
00136 std::string m_nonIsolatedMuonLocation;
00137 std::string m_jetLocation;
00138 std::string m_cellLocation;
00139 std::string m_clusterLocation;
00140 std::string m_mcTruthLocation;
00141 std::string m_outputLocation;
00142 std::string m_missingMomentumLocation;
00143
00144
00145 bool m_testMode;
00146 double m_beamEnergy;
00147 std::vector <int> m_escapingParticles;
00148
00149
00150 int m_lumi;
00151
00152
00153
00154
00155 double m_barrelForwardEta;
00156
00157 TesIO* m_tesIO;
00158 HepMC_helper::IMCselector* m_visibleToAtlas;
00159 };
00160
00161
00162
00163
00164 template <class Type> inline
00165 int EventHeaderMaker::numberInList(std::string tesAddress,
00166 Type ) {
00167 std::vector<Type*> aList;
00168 if( !m_tesIO->copy(aList, tesAddress) ) throw "Error in numberInList";
00169
00170 return aList.size();
00171 }
00172
00173
00174
00175
00176 inline
00177 int EventHeaderMaker::numberJetFlavor(
00178 std::string tesAddress,
00179 int flavor) {
00180 std::vector<Jet*> theJets;
00181 int temp=0;
00182 if(m_tesIO->copy(theJets, tesAddress)){
00183
00184 std::vector<Jet*>::const_iterator jet = theJets.begin();
00185 for (; jet != theJets.end(); ++jet) {
00186 if( (*jet)->pdg_id()==flavor ) ++temp;
00187 }
00188 }
00189 return temp;
00190 }
00191
00192
00193
00194
00195 template <class Type> inline HepLorentzVector
00196 EventHeaderMaker::momentumSum(std::string tesAddress, Type ) {
00197
00198 std::vector<Type*> aList;
00199
00200 if(!m_tesIO->copy(aList, tesAddress) ) throw "Error in momentumSum";
00201
00202 HepLorentzVector temp(0.0,0.0,0.0,0.0);
00203 typename std::vector<Type*>::const_iterator iter = aList.begin();
00204
00205 for (; iter != aList.end(); ++iter) temp += (*iter)->momentum();
00206
00207 return temp;
00208 }
00209
00210
00211
00212
00213 template <class Type, class AssType> inline HepLorentzVector
00214 EventHeaderMaker::assocMomentumSum(std::string tesAddress,
00215 Type ,
00216 AssType ) {
00217
00218 HepLorentzVector temp(0.0,0.0,0.0,0.0);
00219 std::vector<Type*> aList;
00220 if(!m_tesIO->copy(aList, tesAddress)) throw "Error in assoc Momentum Sum";
00221
00222
00223 typename std::vector<Type*>::const_iterator iter = aList.begin();
00224 for (; iter != aList.end(); ++iter){
00225 SmartRefVector<AssType> aList = (*iter)->associations(AssType());
00226 typename SmartRefVector<AssType>::iterator aIter = aList.begin();
00227 for(; aIter<aList.end(); ++aIter) temp+=(*aIter)->momentum();
00228 }
00229 return temp;
00230 }
00231 }
00232
00233 #endif
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243