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__
00027 #define __ATLFAST_EventHeaderMaker__
00028
00029
00030 #include <string>
00031 #include <iterator>
00032 #include <vector>
00033
00034
00035
00036 #include "GaudiKernel/ISvcLocator.h"
00037 #include "GaudiKernel/Algorithm.h"
00038 #include "GaudiKernel/MsgStream.h"
00039 #include "GaudiKernel/DataObject.h"
00040
00041
00042 #include "CLHEP/Vector/LorentzVector.h"
00043 #include "HepMC/GenEvent.h"
00044 #include "HepMC/GenParticle.h"
00045
00046
00047 #include "AtlfastCode/ReconstructedParticle.h"
00048 #include "AtlfastCode/CommonData.h"
00049 #include "AtlfastCode/TesIO.h"
00050 #include "AtlfastCode/HepMC_helper.h"
00051 #include "AtlfastCode/Jet.h"
00052
00053
00054
00055
00056
00057
00058
00059 #define DEFAULT_beamEnergy 7000.0;
00060
00061 #define DEFAULT_lumi 1 // Luminosity option (1=low, 2=high)
00062 #define DEFAULT_randSeed 12345 // Random number seed
00063
00064
00065
00066
00067
00068
00069 #define DEFAULT_electronLocation "/Event/AtlfastIsolatedElectrons"
00070 #define DEFAULT_photonLocation "/Event/AtlfastIsolatedPhotons"
00071 #define DEFAULT_isolatedMuonLocation "/Event/AtlfastIsolatedMuons"
00072 #define DEFAULT_nonIsolatedMuonLocation "/Event/AtlfastNonIsolatedMuons"
00073 #define DEFAULT_jetLocation "/Event/AtlfastJets"
00074 #define DEFAULT_cellLocation "/Event/AtlfastCells"
00075 #define DEFAULT_clusterLocation "/Event/AtlfastClusters"
00076 #define DEFAULT_mcTruthLocation "/Event/McEventCollection"
00077 #define DEFAULT_outputLocation "/Event/AtlfastEventHeader"
00078 #define DEFAULT_commonDataLocation "/Event/AtlfastCommonData"
00079 #define DEFAULT_missingMomentumLocation "/Event/AtlfastMissingMomentum"
00080 #define DEFAULT_runNumber 1000;
00081 #define DEFAULT_evtNumber 0;
00082 #define DEFAULT_testMode false;
00083
00084 namespace Atlfast {
00085
00093 class EventHeaderMaker : public Algorithm{
00094
00095 public:
00096
00097
00098
00099
00100
00101
00102
00104 EventHeaderMaker( const std::string& name, ISvcLocator* pSvcLocator ) ;
00106 virtual ~EventHeaderMaker();
00107
00108
00109
00110
00111
00112
00114 StatusCode initialize() ;
00116 StatusCode execute() ;
00118 StatusCode finalize() ;
00119
00120
00121
00122 private:
00123
00124
00125
00126
00127
00128
00130 template <class Type> int numberInList(std::string tesAddress, Type);
00132 int numberJetFlavor(std::string tesAddress, int);
00134 HepLorentzVector missingMomentum(MsgStream&);
00136 HepLorentzVector escapedMomentum(MsgStream&);
00139 template <class Type>
00140 HepLorentzVector momentumSum(std::string tesAddress, Type dummy);
00143 template <class Type>
00144 HepLorentzVector smearAndSum(std::string tesAddress, Type dummy);
00147 template <class Type, class AssType>
00148 HepLorentzVector assocMomentumSum(std::string tesAddress,
00149 Type dum1, AssType dum2);
00151 HepLorentzVector unusedClusterSum();
00153 HepLorentzVector unusedMuonSum();
00155 HepLorentzVector unusedCellSum();
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165 std::string m_electronLocation ;
00166 std::string m_photonLocation ;
00167 std::string m_isolatedMuonLocation;
00168 std::string m_nonIsolatedMuonLocation;
00169 std::string m_jetLocation;
00170 std::string m_cellLocation;
00171 std::string m_clusterLocation;
00172 std::string m_mcTruthLocation;
00173 std::string m_outputLocation;
00174 std::string m_commonDataLocation;
00175 std::string m_missingMomentumLocation;
00176
00177
00178 bool m_testMode;
00179 int m_runNumber;
00180 int m_evtNumber;
00181 double m_beamEnergy;
00182 std::vector <int> m_escapingParticles;
00183
00184
00185 int m_lumi;
00186
00187
00188
00189
00190 int m_randSeed;
00191 double m_barrelForwardEta;
00192
00193 double m_notInit;
00194 TesIO* m_tesIO;
00195 HepMC_helper::IMCselector* m_visibleToAtlas;
00196 };
00197
00198
00199
00200
00201 template <class Type> inline
00202 int EventHeaderMaker::numberInList(std::string tesAddress,
00203 Type ) {
00204 std::vector<Type*> aList;
00205 if( !m_tesIO->copy(aList, tesAddress) ) throw "Error in numberInList";
00206
00207 return aList.size();
00208 }
00209
00210
00211
00212
00213 inline
00214 int EventHeaderMaker::numberJetFlavor(
00215 std::string tesAddress,
00216 int flavor) {
00217 std::vector<Jet*> theJets;
00218 int temp=0;
00219 if(m_tesIO->copy(theJets, tesAddress)){
00220
00221 std::vector<Jet*>::const_iterator jet = theJets.begin();
00222 for (; jet != theJets.end(); ++jet) {
00223 if( (*jet)->pdg_id()==flavor ) ++temp;
00224 }
00225 }
00226 return temp;
00227 }
00228
00229
00230
00231
00232 template <class Type> inline HepLorentzVector
00233 EventHeaderMaker::momentumSum(std::string tesAddress, Type ) {
00234
00235 std::vector<Type*> aList;
00236
00237 if(!m_tesIO->copy(aList, tesAddress) ) throw "Error in momentumSum";
00238
00239 HepLorentzVector temp(0.0,0.0,0.0,0.0);
00240 typename std::vector<Type*>::const_iterator iter = aList.begin();
00241
00242 for (; iter != aList.end(); ++iter) temp += (*iter)->momentum();
00243
00244 return temp;
00245 }
00246
00247
00248
00249
00250 template <class Type, class AssType> inline HepLorentzVector
00251 EventHeaderMaker::assocMomentumSum(std::string tesAddress,
00252 Type ,
00253 AssType ) {
00254
00255 HepLorentzVector temp(0.0,0.0,0.0,0.0);
00256 std::vector<Type*> aList;
00257 if(!m_tesIO->copy(aList, tesAddress)) throw "Error in assoc Momentum Sum";
00258
00259
00260 typename std::vector<Type*>::const_iterator iter = aList.begin();
00261 for (; iter != aList.end(); ++iter){
00262 SmartRefVector<AssType> aList = (*iter)->associations(AssType());
00263 typename SmartRefVector<AssType>::iterator aIter = aList.begin();
00264 for(; aIter<aList.end(); ++aIter) temp+=(*aIter)->momentum();
00265 }
00266 return temp;
00267 }
00268 }
00269
00270 #endif
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280