1#include "GaudiKernel/SmartIF.h"
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/AlgFactory.h"
4#include "GaudiKernel/ISvcLocator.h"
5#include "GaudiKernel/IDataManagerSvc.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "GaudiKernel/IDataProviderSvc.h"
8#include "GaudiKernel/PropertyMgr.h"
18DTag::DTag(
const std::string& name, ISvcLocator* pSvcLocator) :
19 Algorithm(name, pSvcLocator) {
21 declareProperty(
"NeutralDReconstruction", m_recD0 =
true);
22 declareProperty(
"ChargedDReconstruction", m_recDp =
true);
23 declareProperty(
"DsReconstruction", m_recDs =
true);
24 declareProperty(
"LambdaCReconstruction", m_recLc =
true);
31 MsgStream log(
msgSvc(), name());
33 log << MSG::INFO <<
"creating DTag sub Algorithm" << endreq;
41 sc = createSubAlgorithm(
"NeutralDReconstruction",
"NeutralDReconstruction", m_NeutralDReconstruction);
43 log << MSG::ERROR <<
"Error while creating D0Reconstruction" << endreq;
44 return StatusCode::FAILURE;
49 sc = createSubAlgorithm(
"ChargedDReconstruction",
"ChargedDReconstruction", m_ChargedDReconstruction);
51 log << MSG::ERROR <<
"Error while creating D+Reconstruction" << endreq;
52 return StatusCode::FAILURE;
57 sc = createSubAlgorithm(
"DsReconstruction",
"DsReconstruction", m_DsReconstruction);
59 log << MSG::ERROR <<
"Error while creating DsReconstruction" << endreq;
60 return StatusCode::FAILURE;
66 sc = createSubAlgorithm(
"LambdaCReconstruction",
"LambdaCReconstruction", m_LambdaCReconstruction);
68 log << MSG::ERROR <<
"Error while creating LcReconstruction" << endreq;
69 return StatusCode::FAILURE;
73 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
74 return StatusCode::SUCCESS;
78StatusCode DTag::registerParent(MsgStream& log) {
79 DataObject *aEvtRecEvent;
80 eventSvc()->findObject(
"/Event/EvtRec",aEvtRecEvent);
81 if (aEvtRecEvent ==
NULL) {
83 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec",aEvtRecEvent);
84 if (sc != StatusCode::SUCCESS) {
85 log << MSG::FATAL <<
"Could not register EvtRecEvent" <<endreq;
86 return StatusCode::FAILURE;
89 return StatusCode::SUCCESS;
92StatusCode DTag::clearEvtRecDTagCol(MsgStream& log) {
93 StatusCode sc = registerParent(log);
94 if (sc != StatusCode::SUCCESS) {
98 DataObject* aEvtRecDTagCol;
99 eventSvc()->findObject(
"/Event/EvtRec/EvtRecDTagCol",aEvtRecDTagCol);
100 if (aEvtRecDTagCol !=
NULL) {
102 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
103 dataManSvc->clearSubTree(
"/Event/EvtRec/EvtRecDTagCol");
104 eventSvc()->unregisterObject(
"/Event/EvtRec/EvtRecDTagCol");
108 if( evtRecDTagCol !=
NULL){
110 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
111 dataManSvc->clearSubTree(
"/Event/EvtRec/EvtRecDTagCol");
112 eventSvc()->unregisterObject(
"/Event/EvtRec/EvtRecDTagCol");
115 return StatusCode::SUCCESS;
118void DTag::registerEvtRecDTagCol(MsgStream& log) {
120 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
122 if (sc != StatusCode::SUCCESS) {
123 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
134 if( evtRecDTagCol !=
NULL ){
135 if ( evtRecDTagCol->size()>0 ) {
136 cout <<
"************************************************"<<endl;
137 cout <<
"EvtRecDTagCol already exists in this file!" << endl;
138 cout <<
" Please run this program on a raw dst file!" << endl;
139 cout <<
" *** This job is now being killed. ***" << endl;
140 cout <<
"************************************************"<<endl;
141 return StatusCode::FAILURE;
146 MsgStream log(
msgSvc(), name());
147 StatusCode sc = clearEvtRecDTagCol(log);
148 if (sc != StatusCode::SUCCESS) {
152 DataObject* aEvtRecDTagCol;
153 eventSvc()->findObject(
"/Event/EvtRec/EvtRecDTagCol", aEvtRecDTagCol);
154 if (aEvtRecDTagCol ==
NULL) {
155 registerEvtRecDTagCol(log);
158 std::vector<Algorithm*>::const_iterator it = subAlgorithms()->begin();
159 std::vector<Algorithm*>::const_iterator end = subAlgorithms()->end();
160 for(; it != end; it++) {
161 sc = (*it)->execute();
163 log <<
"Error executing selection " << (*it)->name() << endreq;
168 return StatusCode::SUCCESS;
174 MsgStream log(
msgSvc(), name());
175 log << MSG::INFO <<
"in finalize()" << endmsg;
176 return StatusCode::SUCCESS;
ObjectVector< EvtRecDTag > EvtRecDTagCol
DTag(const std::string &name, ISvcLocator *pSvcLocator)
_EXTERN_ std::string EvtRecDTagCol