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 "JetRec/Jet.h"   //definition used by inline funtions
00018 //Atlfast
00019 #include "AtlfastCode/TesIO.h" //needed for TesIOstat definition
00020 //Transient event store paths
00021 //*******************************
00022 // SET DEFAULTS
00023 //*******************************
00024 #define   DEFAULT_inputCellLocation      "/Event/AtlfastCells"
00025 #define   DEFAULT_inputClusterLocation      "/Event/AtlfastClusters"
00026 #define   DEFAULT_outputTowerPJKey     "/Event/AtlfastTowerProtoJets" 
00027 #define   DEFAULT_outputClusterPJKey     "/Event/AtlfastClusterProtoJets" 
00028 #define   DEFAULT_outputFinalStatePJKey     "/Event/AtlfastFinalStateProtoJets"
00029 #define   DEFAULT_outputTowerJetKey     "/Event/AtlfastTowerJets" 
00030 #define   DEFAULT_outputClusterJetKey     "/Event/AtlfastClusterJets" 
00031 #define   DEFAULT_outputFinalStateJetKey     "/Event/AtlfastFinalStateJets"
00032 #define   DEFAULT_towerPJConstruct true
00033 #define   DEFAULT_clusterPJConstruct true
00034 #define   DEFAULT_finalStatePJConstruct true
00035 #define   DEFAULT_finalStatePJConstruct true
00036 #define   DEFAULT_towerPJSmearOn false
00037 #define   DEFAULT_clusterPJSmearOn false
00038  
00039 class ISvcLocator;
00040 
00041 namespace Atlfast {
00042   class ISmearer;
00043   class AtlfastProtoJet;
00044 
00053   class AtlfastProtoJetMaker : public Algorithm {
00054 
00055   public:
00056     //Gaudi style constructor and execution methods
00058     AtlfastProtoJetMaker(const std::string& name, ISvcLocator* pSvcLocator);
00060     ~AtlfastProtoJetMaker();
00061     
00063     StatusCode          initialize();
00065     StatusCode          execute();
00067     //    StatusCode          finalize() {return StatusCode::SUCCESS;}
00068     StatusCode          finalize();
00069 
00070   private:
00071     //Paths in the transient event store to get/put things
00072     //Currently set in member variables to be overwritten
00073     //by job options service
00075     std::string m_inputCellLocation; 
00076     std::string m_inputClusterLocation;
00078     std::string m_outputTowerPJKey;
00079     std::string m_outputClusterPJKey;
00080     std::string m_outputFinalStatePJKey;
00082     std::string m_outputTowerJetKey;
00083     std::string m_outputClusterJetKey;
00084     std::string m_outputFinalStateJetKey;
00086     TesIO* m_tesIO;
00087     bool m_towerPJConstruct;
00088     bool m_clusterPJConstruct;
00089     bool m_finalStatePJConstruct;
00090     bool m_towerPJSmearOn;
00091     bool m_clusterPJSmearOn;
00092   //--------------------------------------------
00093   // Smearer helper class
00094   // which knows all about how to do smearing
00095   // for my PJs
00096   //---------------------------------------------
00097     ISmearer* m_smearer;
00098 
00099   //Methods for filling PJs-----------------------
00100     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00101                                                            T2*,
00102                                                            const std::string&,
00103                                                            const std::string&);
00104     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00105                                                            T2*,
00106                                                            const std::string&,
00107                                                            const std::string&,
00108                                                            bool);
00109     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00110                                                            T2*);
00111   };
00112 //***********************************************************************
00113   //Fill ProtoJet and put in TES by key NO SMEARING available
00114   template <class T1, class T2> inline
00115     StatusCode 
00116     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00117                                         T2* proJ, 
00118                                         const std::string& PJoutputLocation, 
00119                                         const std::string& JoutputLocation){
00120     bool smear = false;
00121     return this->FillProtoJets(vec,
00122                                proJ,
00123                                PJoutputLocation, 
00124                                JoutputLocation, 
00125                                smear);
00126   }//----------------------------------------------------------------------
00127   //Fill ProtoJet and put in TES by key SMEARING available
00128   template <class T1, class T2> inline
00129     StatusCode 
00130     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00131                                         T2* proJ, 
00132                                         const std::string& PJoutputLocation, 
00133                                         const std::string& JoutputLocation,
00134                                         bool smear){
00135     MsgStream log( messageService(), name() ) ;
00136     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00137     ObjectVector< ::Jet >* jets = new ObjectVector< ::Jet >;
00138     typename std::vector<T1*>::const_iterator itr = vec.begin();
00139     HepLorentzVector hepvec;
00140     ::Jet* jet;
00141     for (; itr != vec.end(); ++itr) {
00142       hepvec = (*itr)->momentum();
00143       if(smear){
00144         hepvec = m_smearer->smear(hepvec);
00145       } 
00146       proJ = new T2(hepvec);
00147       pjs->push_back(proJ);
00148       jet = new ::Jet();
00149       jet->add(*proJ,1.);
00150       jets->push_back(jet);
00151     }
00152     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00153     //store protojets
00154     TesIoStat stat = m_tesIO -> store(pjs, PJoutputLocation);
00155     std::string message;
00156     message = stat ? "AtlfastProtoJet stored by key":
00157       "Failed to store AtlfastProtoJet by key";
00158     log<<MSG::DEBUG<<message<<endreq;
00159     if (!stat) {return StatusCode::FAILURE;}
00160     //store JetRec Jets
00161     stat = m_tesIO -> store(jets, JoutputLocation);
00162     message = stat ?  "JetRec Jet stored by key":
00163       "Failed to store JetRec Jet by key";
00164     log<<MSG::DEBUG<<message<<endreq;
00165     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00166   }//-------------------------------------------------------------------------
00167   //Fill ProtoJet and put in TES by type doesn't work yet!! dunno why!
00168   template <class T1, class T2> inline
00169     StatusCode 
00170     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec, T2* proJ){
00171     MsgStream log( messageService(), name() ) ;
00172     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00173     typename std::vector<T1*>::const_iterator itr = vec.begin();
00174     for (; itr != vec.end(); ++itr) {
00175       proJ = new T2((*itr)->momentum());
00176       pjs->push_back(proJ);
00177     }
00178     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00179     //store protojets
00180     TesIoStat stat = m_tesIO -> store(pjs);
00181     message = stat ? "AtlfastProtoJet stored by type":
00182       "Failed to store AtlfastProtoJet type";
00183     log<<MSG::DEBUG<<message<<endreq;
00184     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00185   }
00186   
00187 } // end of namespace bracket
00188 #endif
00189 
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 

Generated on Thu Feb 21 14:30:45 2002 for Atlfast by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001