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_notInit;  
00088     bool m_towerPJConstruct;
00089     bool m_clusterPJConstruct;
00090     bool m_finalStatePJConstruct;
00091     bool m_towerPJSmearOn;
00092     bool m_clusterPJSmearOn;
00093   //--------------------------------------------
00094   // Smearer helper class
00095   // which knows all about how to do smearing
00096   // for my PJs
00097   //---------------------------------------------
00098     ISmearer* m_smearer;
00099 
00100   //Methods for filling PJs-----------------------
00101     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00102                                                            T2*,
00103                                                            const std::string&,
00104                                                            const std::string&);
00105     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00106                                                            T2*,
00107                                                            const std::string&,
00108                                                            const std::string&,
00109                                                            bool);
00110     template <class T1, class T2> StatusCode FillProtoJets(const std::vector<T1*>&,
00111                                                            T2*);
00112   };
00113 //***********************************************************************
00114   //Fill ProtoJet and put in TES by key NO SMEARING available
00115   template <class T1, class T2> inline
00116     StatusCode 
00117     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00118                                         T2* proJ, 
00119                                         const std::string& PJoutputLocation, 
00120                                         const std::string& JoutputLocation){
00121     bool smear = false;
00122     return this->FillProtoJets(vec,
00123                                proJ,
00124                                PJoutputLocation, 
00125                                JoutputLocation, 
00126                                smear);
00127   }//----------------------------------------------------------------------
00128   //Fill ProtoJet and put in TES by key SMEARING available
00129   template <class T1, class T2> inline
00130     StatusCode 
00131     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec,
00132                                         T2* proJ, 
00133                                         const std::string& PJoutputLocation, 
00134                                         const std::string& JoutputLocation,
00135                                         bool smear){
00136     MsgStream log( messageService(), name() ) ;
00137     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00138     ObjectVector< ::Jet >* jets = new ObjectVector< ::Jet >;
00139     typename std::vector<T1*>::const_iterator itr = vec.begin();
00140     HepLorentzVector hepvec;
00141     ::Jet* jet;
00142     for (; itr != vec.end(); ++itr) {
00143       hepvec = (*itr)->momentum();
00144       if(smear){
00145         hepvec = m_smearer->smear(hepvec);
00146       } 
00147       proJ = new T2(hepvec);
00148       pjs->push_back(proJ);
00149       jet = new ::Jet();
00150       jet->add(*proJ,1.);
00151       jets->push_back(jet);
00152     }
00153     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00154     //store protojets
00155     TesIoStat stat = m_tesIO -> store(pjs, PJoutputLocation);
00156     std::string message;
00157     message = stat ? "AtlfastProtoJet stored by key":
00158       "Failed to store AtlfastProtoJet by key";
00159     log<<MSG::DEBUG<<message<<endreq;
00160     if (!stat) {return StatusCode::FAILURE;}
00161     //store JetRec Jets
00162     stat = m_tesIO -> store(pjs, JoutputLocation);
00163     message = stat ?  "JetRec Jet stored by key":
00164       "Failed to store JetRec Jet by key";
00165     log<<MSG::DEBUG<<message<<endreq;
00166     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00167   }//-------------------------------------------------------------------------
00168   //Fill ProtoJet and put in TES by type doesn't work yet!! dunno why!
00169   template <class T1, class T2> inline
00170     StatusCode 
00171     AtlfastProtoJetMaker::FillProtoJets(const std::vector<T1*>& vec, T2* proJ){
00172     MsgStream log( messageService(), name() ) ;
00173     ObjectVector<ProtoJet>* pjs = new ObjectVector<ProtoJet>;
00174     typename std::vector<T1*>::const_iterator itr = vec.begin();
00175     for (; itr != vec.end(); ++itr) {
00176       proJ = new T2((*itr)->momentum());
00177       pjs->push_back(proJ);
00178     }
00179     log << MSG::DEBUG << "Size of vector"<<pjs->size() << endreq;
00180     //store protojets
00181     TesIoStat stat = m_tesIO -> store(pjs);
00182     message = stat ? "AtlfastProtoJet stored by type":
00183       "Failed to store AtlfastProtoJet type";
00184     log<<MSG::DEBUG<<message<<endreq;
00185     return (stat)? StatusCode::SUCCESS:StatusCode::FAILURE;
00186   }
00187   
00188 } // end of namespace bracket
00189 #endif
00190 
00191 
00192 
00193 
00194 
00195 
00196 
00197 
00198 
00199 
00200 
00201 
00202 
00203 
00204 
00205 
00206 
00207 
00208 

Generated on Mon Feb 4 15:54:23 2002 for Atlfast by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001