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