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 #include "ProtoJetEvent/ProtoJet.h"
00017 #include "ProtoJetEvent/ProtoJetCollection.h"
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     TesIO* m_tesIO;
00067     bool m_towerPJConstruct;
00068     bool m_clusterPJConstruct;
00069     bool m_finalStatePJConstruct;
00070     bool m_towerPJSmearOn;
00071     bool m_clusterPJSmearOn;
00072   //--------------------------------------------
00073   // Smearer helper class
00074   // which knows all about how to do smearing
00075   // for my PJs
00076   //---------------------------------------------
00077     ISmearer* m_smearer;
00078 
00079   //Methods for filling PJs-----------------------
00080     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00081                                                            T2*,
00082                                                            const std::string&);
00083     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00084                                                            T2*,
00085                                                            const std::string&,
00086                                                            bool);
00087     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00088                                                            T2*);
00089   };
00090 //***********************************************************************
00091   //Fill ProtoJet and put in TES by key NO SMEARING available
00092   template <class T1, class T2> inline
00093     StatusCode 
00094     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00095                                         T2* proJ, 
00096                                         const std::string& PJoutputLocation){
00097     bool smear = false;
00098     return this->FillProtoJets(vec,
00099                                proJ,
00100                                PJoutputLocation, 
00101                                smear);
00102   }//----------------------------------------------------------------------
00103   //Fill ProtoJet and put in TES by key SMEARING available
00104   template <class T1, class T2> inline
00105     StatusCode 
00106     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00107                                         T2* proJ, 
00108                                         const std::string& PJoutputLocation, 
00109                                         bool smear){
00110     MsgStream log( messageService(), name() ) ;
00111     ProtoJetCollection<ProtoJet>* pjs = new ProtoJetCollection<ProtoJet>;
00112     typename std::vector<T1*>::const_iterator itr = vec.begin();
00113     HepLorentzVector hepvec;
00114       for (; itr != vec.end(); ++itr) {
00115       hepvec = (*itr)->momentum();
00116       if(smear){
00117         hepvec = m_smearer->smear(hepvec);
00118       } 
00119       proJ = new T2(hepvec);
00120       pjs->push_back(proJ);
00121       }
00122     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00123     //store protojets
00124     TesIoStat stat = m_tesIO -> store(pjs, PJoutputLocation);
00125     std::string message;
00126     message = stat ? "AtlfastProtoJet stored by key":
00127       "Failed to store AtlfastProtoJet by key";
00128     log<<MSG::DEBUG<<message<<endreq;
00129     if (!stat) {return StatusCode::FAILURE;}
00130     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00131   }//-------------------------------------------------------------------------
00132   //Fill ProtoJet and put in TES by type doesn't work yet!! dunno why!
00133   template <class T1, class T2> inline
00134     StatusCode 
00135     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec, T2* proJ){
00136     MsgStream log( messageService(), name() ) ;
00137     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00138     typename std::vector<T1*>::const_iterator itr = vec.begin();
00139     for (; itr != vec.end(); ++itr) {
00140       proJ = new T2((*itr)->momentum());
00141       pjs->push_back(proJ);
00142     }
00143     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00144     //store protojets
00145     TesIoStat stat = m_tesIO -> store(pjs);
00146     message = stat ? "AtlfastProtoJet stored by type":
00147       "Failed to store AtlfastProtoJet type";
00148     log<<MSG::DEBUG<<message<<endreq;
00149     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00150   }
00151   
00152 } // end of namespace bracket
00153 #endif
00154 
00155 
00156 
00157 
00158 
00159 
00160 
00161 
00162 
00163 
00164 
00165 
00166 
00167 
00168 
00169 
00170 
00171 
00172 

Generated on Tue Mar 18 11:18:22 2003 for AtlfastAlgs by doxygen1.3-rc1