EventHeaderMaker.h

Go to the documentation of this file.
00001 // ================================================
00002 // EventHeaderMaker class description
00003 // ================================================
00004 //
00005 // THIS TEXT TO BE REPLACED BY ATLAS STANDARD FORMAT
00006 //
00007 //
00008 // This version....
00009 //
00010 //
00011 // Namespace Atlfast::
00012 //
00013 // class: EventHeaderMaker
00014 //
00015 // Description: 
00016 //
00017 //  Algorithm which makes the Atlfast Event Header
00018 //  This must be run as the final algorithm in the 
00019 //  Atlfast suite as it requires the information from
00020 //  all the earlier makers.
00021 //
00022 //
00023 // ................................................................
00024 //
00025 
00026 #ifndef ATLFAST_EVENTHEADERMAKER_H
00027 #define ATLFAST_EVENTHEADERMAKER_H
00028 
00029 // STL
00030 #include <string>
00031 //#include <iterator>
00032 #include <vector>
00033 
00034 // Gaudi 
00035 #include "GaudiKernel/Algorithm.h"
00036 
00037 // Other
00038 #include "CLHEP/Vector/LorentzVector.h"
00039 
00040 // Atlfast
00041 #include "AtlfastEvent/Jet.h"          //no forward dec: used in inline function
00042 #include "AtlfastUtils/TesIO.h"        //no forward dec: used in inline function
00043 
00044 #ifndef ATLFAST_COLLECTIONDEFS_H
00045 #include "AtlfastEvent/CollectionDefs.h"
00046 #endif
00047 
00048 //#ifndef ATLFAST_ASSOCTYPERECOVERER_H
00049 //#include "AtlfastAlgs/AssocTypeRecoverer.h"
00050 //#endif
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     // Constructors/Destructors
00093     //
00094     // Gaudi requires that the constructor takes certain arguments
00095     // (and passes them directly to the constructor of the base class)
00096     //-------------------------
00098     EventHeaderMaker( const std::string& name, ISvcLocator* pSvcLocator ) ; 
00100     virtual ~EventHeaderMaker();
00101     
00102     
00103     //------------------------------------------------------
00104     // Methods used by Gaudi to run the algorithm
00105     //------------------------------------------------------
00106     
00108     StatusCode initialize() ;
00110     StatusCode execute() ;
00112     StatusCode finalize() ;
00113     
00114     
00115     
00116   private:
00117     
00118     
00119     //-------------------------------
00120     // Private methods
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     // Sum of ReconstructedParticle halos
00152     double haloSum(std::string tesAddress);
00153     // Vectorial sum of ReconstructedParticle halos
00154     HepLorentzVector haloVectorSum(std::string tesAddress);
00156     HepLorentzVector unusedClusterSum(); 
00158     HepLorentzVector unusedMuonSum();    
00160     HepLorentzVector unusedCellSum();    
00161     
00162     
00163     //-------------------------------
00164     // Data members
00165     //-------------------------------
00166     
00167     // the following data members tell the
00168     // algorithm where to retrieve its input particles from
00169     // in the TES. These are written by the job Options service.
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     //holds the Stotegate MC location
00181     std::string m_mcLocation;
00182     
00183     bool m_testMode;
00184     bool m_addHalos;
00185     bool m_adjustMissETForIsolation;
00186     double m_beamEnergy; // beam energy in GeV
00187     std::vector <int> m_escapingParticles; // PDG ids for escaping particles
00188     
00189     
00190     int           m_lumi;
00191     
00192     //htp random number seed will need to be removed eventually
00193     //    currently used to set up Smearer's random number seed
00194     //    SHOULD BE REPLACED BY FRAMEWORK SERVICE!! 
00195     double        m_barrelForwardEta;
00196     
00197     TesIO*        m_tesIO;
00198     HepMC_helper::IMCselector*  m_visibleToAtlas;
00199   };
00200 
00201   //-------------------------------------------------------
00202   // numberInList
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     //    Collection aList;
00210     //    if( !m_tesIO->copy<(aList, tesAddress) ) throw "Error in numberInList";
00211     //if( !m_tesIO->get(aList) ) throw "Error in numberInList";
00212     //    return aList.size();
00213   }
00214   
00215   //-------------------------------------------------------
00216   // numberJetFlavor
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       //if(m_tesIO->get(theJets)){
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   // momentumSum
00236   //-------------------------------------------------------
00237   template <class Collection> inline HepLorentzVector
00238     EventHeaderMaker::momentumSum(std::string tesAddress) {
00239     //
00240     //    Collection aList;
00241     //
00242     //    if(!m_tesIO->copy
00243     //       <Collection, 
00244     //       Collection> 
00245     //   (aList, tesAddress) ){throw "Error in momentumSum";
00246     //    }
00247     //
00248     //    HepLorentzVector temp(0.0,0.0,0.0,0.0);
00249     //    typename Collection::const_iterator iter = aList.begin();
00250     //
00251     //    for (; iter != aList.end(); ++iter) temp += (*iter)->momentum();
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   // assocMomentumSum
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   // transverseEnergySum
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   // assocTransverseEnergySum
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   // HaloSum - only valid for ReconstructedParticles
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   // HaloVectorSum
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 } // end of namespace bracket
00360 
00361 #endif
00362 
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370 
00371 

Generated on Mon Sep 24 14:19:10 2007 for AtlfastAlgs by  doxygen 1.5.1