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