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

AtlfastProtoJetMaker.h

Go to the documentation of this file.
00001 // AtlfastProtoJet Maker.h
00002 //
00003 
00004 #ifndef ATLFAST_ATLFASTPROTOJETMAKER_H
00005 #define ATLFAST_ATLFASTPROTOJETMAKER_H
00006 
00007 // Normal STL and physical vectors
00008 
00009 #include "CLHEP/Vector/LorentzVector.h"  //used by template function
00010 #include <vector>
00011 #include <string>
00012 
00013 // Gaudi
00014 #include "GaudiKernel/Algorithm.h"   //needed for inheritance
00015 #include "GaudiKernel/MsgStream.h"   //def used by inline functions
00016 
00017 #include "JetEvent/Jet.h"   //definition used by inline funtions
00018 //Atlfast
00019 #include "AtlfastUtils/TesIO.h" //needed for TesIOstat definition
00020 
00021 class ISvcLocator;
00022 
00023 namespace Atlfast {
00024   class ISmearer;
00025   class AtlfastProtoJet;
00026 
00027   using std::string;
00028 
00037   class AtlfastProtoJetMaker : public Algorithm {
00038 
00039   public:
00040     //Gaudi style constructor and execution methods
00042     AtlfastProtoJetMaker(const std::string& name, ISvcLocator* pSvcLocator);
00044     ~AtlfastProtoJetMaker();
00045     
00047     StatusCode          initialize();
00049     StatusCode          execute();
00051     //    StatusCode          finalize() {return StatusCode::SUCCESS;}
00052     StatusCode          finalize();
00053 
00054   private:
00055     //Paths in the transient event store to get/put things
00056     //Currently set in member variables to be overwritten
00057     //by job options service
00059     std::string m_inputCellLocation; 
00060     std::string m_inputClusterLocation;
00062     std::string m_outputTowerPJKey;
00063     std::string m_outputClusterPJKey;
00064     std::string m_outputFinalStatePJKey;
00066     std::string m_outputTowerJetKey;
00067     std::string m_outputClusterJetKey;
00068     std::string m_outputFinalStateJetKey;
00070     TesIO* m_tesIO;
00071     bool m_towerPJConstruct;
00072     bool m_clusterPJConstruct;
00073     bool m_finalStatePJConstruct;
00074     bool m_towerPJSmearOn;
00075     bool m_clusterPJSmearOn;
00076   //--------------------------------------------
00077   // Smearer helper class
00078   // which knows all about how to do smearing
00079   // for my PJs
00080   //---------------------------------------------
00081     ISmearer* m_smearer;
00082 
00083   //Methods for filling PJs-----------------------
00084     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00085                                                            T2*,
00086                                                            const std::string&,
00087                                                            const std::string&);
00088     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00089                                                            T2*,
00090                                                            const std::string&,
00091                                                            const std::string&,
00092                                                            bool);
00093     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00094                                                            T2*);
00095   };
00096 //***********************************************************************
00097   //Fill ProtoJet and put in TES by key NO SMEARING available
00098   template <class T1, class T2> inline
00099     StatusCode 
00100     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00101                                         T2* proJ, 
00102                                         const std::string& PJoutputLocation, 
00103                                         const std::string& JoutputLocation){
00104     bool smear = false;
00105     return this->FillProtoJets(vec,
00106                                proJ,
00107                                PJoutputLocation, 
00108                                JoutputLocation, 
00109                                smear);
00110   }//----------------------------------------------------------------------
00111   //Fill ProtoJet and put in TES by key SMEARING available
00112   template <class T1, class T2> inline
00113     StatusCode 
00114     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00115                                         T2* proJ, 
00116                                         const std::string& PJoutputLocation, 
00117                                         const std::string& JoutputLocation,
00118                                         bool smear){
00119     MsgStream log( messageService(), name() ) ;
00120     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00121     ObjectVector< ::Jet >* jets = new ObjectVector< ::Jet >;
00122     typename std::vector<T1*>::const_iterator itr = vec.begin();
00123     HepLorentzVector hepvec;
00124     ::Jet* jet;
00125     for (; itr != vec.end(); ++itr) {
00126       hepvec = (*itr)->momentum();
00127       if(smear){
00128         hepvec = m_smearer->smear(hepvec);
00129       } 
00130       proJ = new T2(hepvec);
00131       pjs->push_back(proJ);
00132       jet = new ::Jet();
00133       jet->add(*proJ,1.);
00134       jets->push_back(jet);
00135     }
00136     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00137     //store protojets
00138     TesIoStat stat = m_tesIO -> store(pjs, PJoutputLocation);
00139     std::string message;
00140     message = stat ? "AtlfastProtoJet stored by key":
00141       "Failed to store AtlfastProtoJet by key";
00142     log<<MSG::DEBUG<<message<<endreq;
00143     if (!stat) {return StatusCode::FAILURE;}
00144     //store JetRec Jets
00145     stat = m_tesIO -> store(jets, JoutputLocation);
00146     message = stat ?  "JetRec Jet stored by key":
00147       "Failed to store JetRec Jet by key";
00148     log<<MSG::DEBUG<<message<<endreq;
00149     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00150   }//-------------------------------------------------------------------------
00151   //Fill ProtoJet and put in TES by type doesn't work yet!! dunno why!
00152   template <class T1, class T2> inline
00153     StatusCode 
00154     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec, T2* proJ){
00155     MsgStream log( messageService(), name() ) ;
00156     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00157     typename std::vector<T1*>::const_iterator itr = vec.begin();
00158     for (; itr != vec.end(); ++itr) {
00159       proJ = new T2((*itr)->momentum());
00160       pjs->push_back(proJ);
00161     }
00162     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00163     //store protojets
00164     TesIoStat stat = m_tesIO -> store(pjs);
00165     message = stat ? "AtlfastProtoJet stored by type":
00166       "Failed to store AtlfastProtoJet type";
00167     log<<MSG::DEBUG<<message<<endreq;
00168     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00169   }
00170   
00171 } // end of namespace bracket
00172 #endif
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 
00186 
00187 
00188 
00189 
00190 
00191 

Generated on Wed May 1 14:11:31 2002 for AtlfastAlgs by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001