/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/VeeVertexAlg/VeeVertexAlg-00-00-05/src/VeeVertex.cxx

Go to the documentation of this file.
00001 #include "GaudiKernel/MsgStream.h"
00002 #include "GaudiKernel/AlgFactory.h"
00003 #include "GaudiKernel/ISvcLocator.h"
00004 #include "GaudiKernel/IDataManagerSvc.h"
00005 #include "GaudiKernel/SmartDataPtr.h"
00006 #include "GaudiKernel/IDataProviderSvc.h"
00007 #include "GaudiKernel/PropertyMgr.h"
00008 #include "EventModel/EventModel.h"
00009 #include "EventModel/Event.h"
00010 #include "EvtRecEvent/EvtRecVeeVertex.h"
00011 #include "EvtRecEvent/EvtRecEvent.h"
00012 #include "VeeVertexAlg/VeeVertex.h"
00013 #include <vector>
00014 //**************************************************************************************
00015 VeeVertex::VeeVertex(const std::string& name, ISvcLocator* pSvcLocator) :
00016   Algorithm(name, pSvcLocator) {
00017   //Declare the properties
00018   declareProperty("KShortReconstruction", m_recKShort = true);
00019   declareProperty("LambdaReconstruction", m_recLambda = true);
00020   declareProperty("GammaConversionReconstruction", m_recGC = true);
00021 }
00022 
00023 // ***********************************************************************************
00024 StatusCode VeeVertex::initialize() {
00025 
00026   MsgStream log(msgSvc(), name());
00027   
00028   log << MSG::INFO << "creating VeeVertex sub Algorithm" << endreq;
00029 
00030   StatusCode sc;
00031   
00032   if(m_recKShort) { 
00033     sc = createSubAlgorithm("KShortReconstruction", "KShortReconstruction", m_KShortReconstruction);
00034     if(sc.isFailure()) {
00035       log << MSG::ERROR << "Error while creating KShortReconstruction" << endreq;
00036       return StatusCode::FAILURE;
00037     }
00038   }
00039   if(m_recLambda) { 
00040     sc = createSubAlgorithm("LambdaReconstruction", "LambdaReconstruction", m_LambdaReconstruction);
00041     if(sc.isFailure()) {
00042       log << MSG::ERROR << "Error while creating LambdaReconstruction" << endreq;
00043       return StatusCode::FAILURE;
00044     }
00045   }
00046   if(m_recGC) { 
00047     sc = createSubAlgorithm("GammaConversionReconstruction", "GammaConversionReconstruction", m_gcReconstruction);
00048     if(sc.isFailure()) {
00049       log << MSG::ERROR << "Error while creating GammaConversionReconstruction" << endreq;
00050       return StatusCode::FAILURE;
00051     }
00052   }
00053 
00054   log << MSG::INFO << "successfully return from initialize()" <<endmsg;
00055   return StatusCode::SUCCESS;
00056 
00057 }
00058 
00059 StatusCode VeeVertex::registerParent(MsgStream& log) {
00060   DataObject *aEvtRecEvent;
00061   eventSvc()->findObject("/Event/EvtRec",aEvtRecEvent);
00062   if (aEvtRecEvent == NULL) {
00063     aEvtRecEvent = new EvtRecEvent();
00064     StatusCode sc = eventSvc()->registerObject("/Event/EvtRec",aEvtRecEvent);
00065     if (sc != StatusCode::SUCCESS) {
00066       log << MSG::FATAL << "Could not register EvtRecEvent" <<endreq;
00067       return StatusCode::FAILURE;
00068     }
00069   }
00070   return StatusCode::SUCCESS;
00071 }
00072 
00073 StatusCode VeeVertex::clearEvtRecVeeVertexCol(MsgStream& log) {
00074   StatusCode sc = registerParent(log);
00075   if (sc != StatusCode::SUCCESS) {
00076     return sc;
00077   }
00078   
00079   DataObject* aEvtRecVeeVertexCol;
00080   eventSvc()->findObject("/Event/EvtRec/EvtRecVeeVertexCol",aEvtRecVeeVertexCol);
00081   if (aEvtRecVeeVertexCol != NULL) {
00082     SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
00083     dataManSvc->clearSubTree("/Event/EvtRec/EvtRecVeeVertexCol");
00084     eventSvc()->unregisterObject("/Event/EvtRec/EvtRecVeeVertexCol");
00085   } 
00086   return StatusCode::SUCCESS;
00087 }
00088 
00089 void VeeVertex::registerEvtRecVeeVertexCol(MsgStream& log) {
00090   EvtRecVeeVertexCol* aNewEvtRecVeeVertexCol = new EvtRecVeeVertexCol;
00091   StatusCode sc = eventSvc()->registerObject("/Event/EvtRec/EvtRecVeeVertexCol",
00092                                              aNewEvtRecVeeVertexCol);
00093   if (sc != StatusCode::SUCCESS) {
00094     log << MSG::FATAL << "Could not register EvtRecVeeVertexCol in TDS!" << endreq;
00095   }
00096 }
00097 
00098 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00099 StatusCode VeeVertex::execute() {
00100   MsgStream log(msgSvc(), name());
00101 
00102   StatusCode sc = clearEvtRecVeeVertexCol(log);
00103   if (sc != StatusCode::SUCCESS) {
00104     return sc;
00105   }
00106   
00107   std::vector<Algorithm*>::const_iterator it  = subAlgorithms()->begin();
00108   std::vector<Algorithm*>::const_iterator end = subAlgorithms()->end();
00109   for(; it != end; it++) {
00110     sc = (*it)->execute();
00111     if(sc.isFailure()) {
00112       log << "Error executing selection "  << (*it)->name() << endreq;
00113     }
00114   }
00115 
00116   DataObject* aEvtRecVeeVertexCol;
00117   eventSvc()->findObject("/Event/EvtRec/EvtRecVeeVertexCol", aEvtRecVeeVertexCol);
00118   if (aEvtRecVeeVertexCol == NULL) {
00119     registerEvtRecVeeVertexCol(log);
00120   }
00121 
00122   return StatusCode::SUCCESS;
00123 }
00124 
00125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
00126 StatusCode VeeVertex::finalize() {
00127 
00128   MsgStream log(msgSvc(), name());
00129   log << MSG::INFO << "in finalize()" << endmsg;
00130   return StatusCode::SUCCESS;
00131 }
00132 

Generated on Tue Nov 29 23:14:22 2016 for BOSS_7.0.2 by  doxygen 1.4.7