Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

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 //#include "GaudiKernel/DataObject.h"
00037 
00038 // Other
00039 #include "CLHEP/Vector/LorentzVector.h"
00040 
00041 // Atlfast
00042 #include "AtlfastEvent/Jet.h"          //no forward dec: used in inline function
00043 #include "AtlfastUtils/TesIO.h"        //no forward dec: used in inline function
00044 
00045 #ifndef ATLFAST_COLLECTIONDEFS_H
00046 #include "AtlfastEvent/CollectionDefs.h"
00047 #endif
00048 
00049 class ISvcLocator;
00050 class MsgStream;
00051 namespace HepMC_helper{
00052   class IMCselector;
00053 }
00054 namespace Atlfast {
00055   class TesIO;
00056   class Jet;
00057   using std::string;
00065   class EventHeaderMaker : public Algorithm{
00066     
00067   public:
00068     
00069     //-------------------------
00070     // Constructors/Destructors
00071     //
00072     // Gaudi requires that the constructor takes certain arguments
00073     // (and passes them directly to the constructor of the base class)
00074     //-------------------------
00076     EventHeaderMaker( const std::string& name, ISvcLocator* pSvcLocator ) ; 
00078     virtual ~EventHeaderMaker();
00079     
00080     
00081     //------------------------------------------------------
00082     // Methods used by Gaudi to run the algorithm
00083     //------------------------------------------------------
00084     
00086     StatusCode initialize() ;
00088     StatusCode execute() ;
00090     StatusCode finalize() ;
00091     
00092     
00093     
00094   private:
00095     
00096     
00097     //-------------------------------
00098     // Private methods
00099     //-------------------------------
00100     
00102     template <class Collection> int numberInList(std::string tesAddress);
00104     int numberJetFlavor(std::string tesAddress, int);
00106     HepLorentzVector missingMomentum(MsgStream&);
00108     HepLorentzVector escapedMomentum(MsgStream&);
00111     template <class Collection> 
00112       HepLorentzVector momentumSum(std::string tesAddress);
00115     template <class Type> 
00116       HepLorentzVector smearAndSum(std::string tesAddress, Type dummy);
00119     template <class Collection, class AssType> 
00120       HepLorentzVector assocMomentumSum(std::string tesAddress);
00122     HepLorentzVector unusedClusterSum(); 
00124     HepLorentzVector unusedMuonSum();    
00126     HepLorentzVector unusedCellSum();    
00127     
00128     
00129     //-------------------------------
00130     // Data members
00131     //-------------------------------
00132     
00133     // the following data members tell the
00134     // algorithm where to retrieve its input particles from
00135     // in the TES. These are written by the job Options service.
00136     std::string m_electronLocation ;
00137     std::string m_photonLocation ;
00138     std::string m_isolatedMuonLocation;
00139     std::string m_nonIsolatedMuonLocation;
00140     std::string m_jetLocation;
00141     std::string m_cellLocation;
00142     std::string m_clusterLocation;
00143     std::string m_mcTruthLocation;
00144     std::string m_outputLocation;
00145     std::string m_missingMomentumLocation;
00146     
00147     
00148     bool m_testMode;
00149     double m_beamEnergy; // beam energy in GeV
00150     std::vector <int> m_escapingParticles; // PDG ids for escaping particles
00151     
00152     
00153     int           m_lumi;
00154     
00155     //htp random number seed will need to be removed eventually
00156     //    currently used to set up Smearer's random number seed
00157     //    SHOULD BE REPLACED BY FRAMEWORK SERVICE!! 
00158     double        m_barrelForwardEta;
00159     
00160     TesIO*        m_tesIO;
00161     HepMC_helper::IMCselector*  m_visibleToAtlas;
00162   };
00163 
00164   //-------------------------------------------------------
00165   // numberInList
00166   //-------------------------------------------------------
00167   template <class Collection> inline 
00168     int EventHeaderMaker::numberInList(std::string tesAddress) {
00169     DataHandle<Collection> dh;
00170     if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00171     return dh->size();
00172     //    Collection aList;
00173     //    if( !m_tesIO->copy<(aList, tesAddress) ) throw "Error in numberInList";
00174     //if( !m_tesIO->get(aList) ) throw "Error in numberInList";
00175     //    return aList.size();
00176   }
00177   
00178   //-------------------------------------------------------
00179   // numberJetFlavor
00180   //-------------------------------------------------------
00181   inline
00182     int EventHeaderMaker::numberJetFlavor(
00183                                           std::string tesAddress, 
00184                                           int flavor) {
00185     std::vector<Jet*> theJets;
00186     int temp=0;
00187     if(m_tesIO->copy<JetCollection >(theJets, tesAddress)){
00188       //if(m_tesIO->get(theJets)){
00189       std::vector<Jet*>::const_iterator jet  = theJets.begin();
00190       for (; jet != theJets.end(); ++jet) {
00191         if( (*jet)->pdg_id()==flavor ) ++temp;
00192       }
00193     }
00194     return temp;
00195   }
00196   
00197   //-------------------------------------------------------
00198   // momentumSum
00199   //-------------------------------------------------------
00200   template <class Collection> inline HepLorentzVector
00201     EventHeaderMaker::momentumSum(std::string tesAddress) {
00202     //
00203     //    Collection aList;
00204     //
00205     //    if(!m_tesIO->copy
00206     //       <Collection, 
00207     //       Collection> 
00208     //   (aList, tesAddress) ){throw "Error in momentumSum";
00209     //    }
00210     //
00211     //    HepLorentzVector temp(0.0,0.0,0.0,0.0);
00212     //    typename Collection::const_iterator iter = aList.begin();
00213     //
00214     //    for (; iter != aList.end(); ++iter) temp += (*iter)->momentum();
00215     HepLorentzVector temp(0.0,0.0,0.0,0.0);
00216 
00217     DataHandle<Collection> dh;
00218     if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in numberInList";
00219 
00220     typename Collection::const_iterator iter = dh->begin();
00221     typename Collection::const_iterator end  = dh->end();
00222 
00223     for (; iter != end; ++iter) temp += (*iter)->momentum();
00224     
00225     return temp;
00226   }
00227   
00228   //-------------------------------------------------------
00229   // assocMomentumSum
00230   //-------------------------------------------------------
00231   template <class Collection, class AssType> inline HepLorentzVector 
00232     EventHeaderMaker::assocMomentumSum(std::string tesAddress) {
00233     
00234     HepLorentzVector temp(0.0,0.0,0.0,0.0);
00235 
00236     DataHandle<Collection> dh;
00237     if( !m_tesIO->getDH(dh, tesAddress) ) throw "Error in assocMomentumSum";
00238 
00239     typename Collection::const_iterator iter = dh->begin();
00240     typename Collection::const_iterator end  = dh->end();
00241 
00242     for (; iter != end; ++iter){
00243       IAssociationManager* ia  = *iter;
00244       AssType assType;
00245       std::vector<const AssType*> aList  = ia->associations(assType);
00246       typename std::vector<const AssType*>::const_iterator aIter = aList.begin();
00247       for(; aIter<aList.end(); ++aIter) temp+=(*aIter)->momentum();
00248     }
00249     return temp;  
00250   }
00251 } // end of namespace bracket
00252 
00253 #endif
00254 
00255 
00256 
00257 
00258 
00259 
00260 
00261 
00262 
00263 

Generated on Tue Jan 28 09:57:13 2003 for AtlfastAlgs by doxygen1.3-rc1