BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
VeeVertex.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/AlgFactory.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/IDataManagerSvc.h"
5#include "GaudiKernel/SmartDataPtr.h"
6#include "GaudiKernel/IDataProviderSvc.h"
7#include "GaudiKernel/PropertyMgr.h"
9#include "EventModel/Event.h"
13#include <vector>
14//**************************************************************************************
15VeeVertex::VeeVertex(const std::string& name, ISvcLocator* pSvcLocator) :
16 Algorithm(name, pSvcLocator) {
17 //Declare the properties
18 declareProperty("KShortReconstruction", m_recKShort = true);
19 declareProperty("LambdaReconstruction", m_recLambda = true);
20 declareProperty("GammaConversionReconstruction", m_recGC = true);
21}
22
23// ***********************************************************************************
25
26 MsgStream log(msgSvc(), name());
27
28 log << MSG::INFO << "creating VeeVertex sub Algorithm" << endreq;
29
30 StatusCode sc;
31
32 if(m_recKShort) {
33 sc = createSubAlgorithm("KShortReconstruction", "KShortReconstruction", m_KShortReconstruction);
34 if(sc.isFailure()) {
35 log << MSG::ERROR << "Error while creating KShortReconstruction" << endreq;
36 return StatusCode::FAILURE;
37 }
38 }
39 if(m_recLambda) {
40 sc = createSubAlgorithm("LambdaReconstruction", "LambdaReconstruction", m_LambdaReconstruction);
41 if(sc.isFailure()) {
42 log << MSG::ERROR << "Error while creating LambdaReconstruction" << endreq;
43 return StatusCode::FAILURE;
44 }
45 }
46 if(m_recGC) {
47 sc = createSubAlgorithm("GammaConversionReconstruction", "GammaConversionReconstruction", m_gcReconstruction);
48 if(sc.isFailure()) {
49 log << MSG::ERROR << "Error while creating GammaConversionReconstruction" << endreq;
50 return StatusCode::FAILURE;
51 }
52 }
53
54 log << MSG::INFO << "successfully return from initialize()" <<endmsg;
55 return StatusCode::SUCCESS;
56
57}
58
59StatusCode VeeVertex::registerParent(MsgStream& log) {
60 DataObject *aEvtRecEvent;
61 eventSvc()->findObject("/Event/EvtRec",aEvtRecEvent);
62 if (aEvtRecEvent == NULL) {
63 aEvtRecEvent = new EvtRecEvent();
64 StatusCode sc = eventSvc()->registerObject("/Event/EvtRec",aEvtRecEvent);
65 if (sc != StatusCode::SUCCESS) {
66 log << MSG::FATAL << "Could not register EvtRecEvent" <<endreq;
67 return StatusCode::FAILURE;
68 }
69 }
70 return StatusCode::SUCCESS;
71}
72
73StatusCode VeeVertex::clearEvtRecVeeVertexCol(MsgStream& log) {
74 StatusCode sc = registerParent(log);
75 if (sc != StatusCode::SUCCESS) {
76 return sc;
77 }
78
79 DataObject* aEvtRecVeeVertexCol;
80 eventSvc()->findObject("/Event/EvtRec/EvtRecVeeVertexCol",aEvtRecVeeVertexCol);
81 if (aEvtRecVeeVertexCol != NULL) {
82 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
83 dataManSvc->clearSubTree("/Event/EvtRec/EvtRecVeeVertexCol");
84 eventSvc()->unregisterObject("/Event/EvtRec/EvtRecVeeVertexCol");
85 }
86 return StatusCode::SUCCESS;
87}
88
89void VeeVertex::registerEvtRecVeeVertexCol(MsgStream& log) {
90 EvtRecVeeVertexCol* aNewEvtRecVeeVertexCol = new EvtRecVeeVertexCol;
91 StatusCode sc = eventSvc()->registerObject("/Event/EvtRec/EvtRecVeeVertexCol",
92 aNewEvtRecVeeVertexCol);
93 if (sc != StatusCode::SUCCESS) {
94 log << MSG::FATAL << "Could not register EvtRecVeeVertexCol in TDS!" << endreq;
95 }
96}
97
98// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
99StatusCode VeeVertex::execute() {
100 MsgStream log(msgSvc(), name());
101
102 StatusCode sc = clearEvtRecVeeVertexCol(log);
103 if (sc != StatusCode::SUCCESS) {
104 return sc;
105 }
106
107 std::vector<Algorithm*>::const_iterator it = subAlgorithms()->begin();
108 std::vector<Algorithm*>::const_iterator end = subAlgorithms()->end();
109 for(; it != end; it++) {
110 sc = (*it)->execute();
111 if(sc.isFailure()) {
112 log << "Error executing selection " << (*it)->name() << endreq;
113 }
114 }
115
116 DataObject* aEvtRecVeeVertexCol;
117 eventSvc()->findObject("/Event/EvtRec/EvtRecVeeVertexCol", aEvtRecVeeVertexCol);
118 if (aEvtRecVeeVertexCol == NULL) {
119 registerEvtRecVeeVertexCol(log);
120 }
121
122 return StatusCode::SUCCESS;
123}
124
125// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
127
128 MsgStream log(msgSvc(), name());
129 log << MSG::INFO << "in finalize()" << endmsg;
130 return StatusCode::SUCCESS;
131}
132
ObjectVector< EvtRecVeeVertex > EvtRecVeeVertexCol
IMessageSvc * msgSvc()
#define NULL
VeeVertex(const std::string &name, ISvcLocator *pSvcLocator)
Definition: VeeVertex.cxx:15
StatusCode execute()
Definition: VeeVertex.cxx:99
StatusCode finalize()
Definition: VeeVertex.cxx:126
StatusCode initialize()
Definition: VeeVertex.cxx:24