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

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