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 #include "CLHEP/Vector/LorentzVector.h"
00039
00040
00041 #include "AtlfastEvent/Jet.h"
00042 #include "AtlfastUtils/TesIO.h"
00043
00044 #ifndef ATLFAST_COLLECTIONDEFS_H
00045 #include "AtlfastEvent/CollectionDefs.h"
00046 #endif
00047
00048
00049
00050
00051
00052 #ifndef ATLFAST_TYPEVISITOR_H
00053 #include "AtlfastEvent/TypeVisitor.h"
00054 #endif
00055
00056 #ifndef ATLFAST_MOMENTUMSUMVISITOR_H
00057 #include "AtlfastUtils/MomentumSumVisitor.h"
00058 #endif
00059
00060 #ifndef ATLFAST_TRANSVERSEENERGYSUMVISITOR_H
00061 #include "AtlfastUtils/TransverseEnergySumVisitor.h"
00062 #endif
00063
00064 #ifndef ATLFAST_CONTAINERASSOCSDISPATCHER_H
00065 #include "AtlfastAlgs/ContainerAssocsDispatcher.h"
00066 #endif
00067
00068 class ISvcLocator;
00069 class MsgStream;
00070 namespace HepMC_helper{
00071 class IMCselector;
00072 }
00073 namespace Atlfast {
00074
00075 class TesIO;
00076 class Jet;
00077 using std::string;
00078
00087 class EventHeaderMaker : public Algorithm{
00088
00089 public:
00090
00091
00092
00093
00094
00095
00096
00098 EventHeaderMaker( const std::string& name, ISvcLocator* pSvcLocator ) ;
00100 virtual ~EventHeaderMaker();
00101
00102
00103
00104
00105
00106
00108 StatusCode initialize() ;
00110 StatusCode execute() ;
00112 StatusCode finalize() ;
00113
00114
00115
00116 private:
00117
00118
00119
00120
00121
00122
00124 template <class Collection> int numberInList(std::string tesAddress);
00126 int numberJetFlavor(std::string tesAddress, int);
00128 HepLorentzVector missingMomentum(MsgStream&, double&);
00130 HepLorentzVector escapedMomentum(MsgStream&);
00133 template <class Collection>
00134 HepLorentzVector momentumSum(std::string tesAddress);
00137 template <class Type>
00138 HepLorentzVector smearAndSum(std::string tesAddress, Type dummy);
00141 template <class Collection, class AssType>
00142 HepLorentzVector assocMomentumSum(std::string tesAddress);
00145 template <class Collection>
00146 double transverseEnergySum(std::string tesAddress);
00149 template <class Collection, class AssType>
00150 double assocTransverseEnergySum(std::string tesAddress);
00151
00152 double haloSum(std::string tesAddress);
00153
00154 HepLorentzVector haloVectorSum(std::string tesAddress);
00156 HepLorentzVector unusedClusterSum();
00158 HepLorentzVector unusedMuonSum();
00160 HepLorentzVector unusedCellSum();
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 std::string m_electronLocation ;
00171 std::string m_photonLocation ;
00172 std::string m_isolatedMuonLocation;
00173 std::string m_nonIsolatedMuonLocation;
00174 std::string m_jetLocation;
00175 std::string m_cellLocation;
00176 std::string m_clusterLocation;
00177 std::string m_outputLocation;
00178 std::string m_missingMomentumLocation;
00179
00180
00181 std::string m_mcLocation;
00182
00183 bool m_testMode;
00184 bool m_addHalos;
00185 bool m_adjustMissETForIsolation;
00186 double m_beamEnergy;
00187 std::vector <int> m_escapingParticles;
00188
00189
00190 int m_lumi;
00191
00192
00193
00194
00195 double m_barrelForwardEta;
00196
00197 TesIO* m_tesIO;
00198 HepMC_helper::IMCselector* m_visibleToAtlas;
00199 };
00200
00201
00202
00203
00204 template <class Collection> inline
00205 int EventHeaderMaker::numberInList(std::string tesAddress) {
00206 const Collection* dh(0);
00207 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00208 return dh->size();
00209
00210
00211
00212
00213 }
00214
00215
00216
00217
00218 inline
00219 int EventHeaderMaker::numberJetFlavor(
00220 std::string tesAddress,
00221 int flavor) {
00222 std::vector<Jet*> theJets;
00223 int temp=0;
00224 if(m_tesIO->copy<JetCollection >(theJets, tesAddress)){
00225
00226 std::vector<Jet*>::const_iterator jet = theJets.begin();
00227 for (; jet != theJets.end(); ++jet) {
00228 if( fabs((*jet)->pdg_id()) == flavor ) ++temp;
00229 }
00230 }
00231 return temp;
00232 }
00233
00234
00235
00236
00237 template <class Collection> inline HepLorentzVector
00238 EventHeaderMaker::momentumSum(std::string tesAddress) {
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252 HepLorentzVector temp(0.0,0.0,0.0,0.0);
00253
00254 const Collection* dh(0);
00255 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00256
00257 typename Collection::const_iterator iter = dh->begin();
00258 typename Collection::const_iterator end = dh->end();
00259
00260 for (; iter != end; ++iter) temp += (*iter)->momentum();
00261
00262 return temp;
00263 }
00264
00265
00266
00267
00268 template <class Collection, class AssType> inline HepLorentzVector
00269 EventHeaderMaker::assocMomentumSum(std::string tesAddress) {
00270
00271 HepLorentzVector temp(0.0,0.0,0.0,0.0);
00272
00273 const Collection* dh(0);
00274 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in assocMomentumSum";
00275
00276 MomentumSumVisitor msv = ContainerAssocsDispatcher(
00277 dh->begin(),
00278 dh->end(),
00279 MomentumSumVisitor()
00280 );
00281
00282 return msv.momSum(AssType());
00283 }
00284
00285
00286
00287
00288 template <class Collection> inline double
00289 EventHeaderMaker::transverseEnergySum(std::string tesAddress) {
00290
00291 double temp(0.);
00292
00293 const Collection* dh(0);
00294 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00295
00296 typename Collection::const_iterator iter = dh->begin();
00297 typename Collection::const_iterator end = dh->end();
00298
00299 for (; iter != end; ++iter){
00300 temp += (*iter)->eT();
00301 }
00302
00303 return temp;
00304 }
00305
00306
00307
00308
00309 template <class Collection, class AssType> inline double
00310 EventHeaderMaker::assocTransverseEnergySum(std::string tesAddress) {
00311
00312 const Collection* dh(0);
00313 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in assocMomentumSum";
00314
00315 TransverseEnergySumVisitor tesv =
00316 ContainerAssocsDispatcher( dh->begin(), dh->end(), TransverseEnergySumVisitor() );
00317
00318 return tesv.sumET(AssType());
00319 }
00320
00321
00322
00323
00324 inline double EventHeaderMaker::haloSum(std::string tesAddress) {
00325
00326 double temp(0.);
00327
00328 const ReconstructedParticleCollection* dh(0);
00329 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00330
00331 ReconstructedParticleCollection::const_iterator iter = dh->begin();
00332 ReconstructedParticleCollection::const_iterator end = dh->end();
00333
00334 for (; iter != end; ++iter)
00335 temp += (*iter)->halo();
00336
00337 return temp;
00338 }
00339
00340
00341
00342
00343 inline HepLorentzVector EventHeaderMaker::haloVectorSum(std::string tesAddress) {
00344
00345 HepLorentzVector temp(0.,0.,0.,0.);
00346
00347 const ReconstructedParticleCollection* dh(0);
00348 if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00349
00350 ReconstructedParticleCollection::const_iterator iter = dh->begin();
00351 ReconstructedParticleCollection::const_iterator end = dh->end();
00352
00353 for (; iter != end; ++iter)
00354 temp += (*iter)->halovector();
00355
00356 return temp;
00357 }
00358
00359 }
00360
00361 #endif
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371