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);
30 MsgStream log(
msgSvc(), name());
32 log << MSG::INFO <<
"creating DTag sub Algorithm" << endreq;
40 sc = createSubAlgorithm(
"NeutralDReconstruction",
"NeutralDReconstruction", m_NeutralDReconstruction);
42 log << MSG::ERROR <<
"Error while creating D0Reconstruction" << endreq;
43 return StatusCode::FAILURE;
48 sc = createSubAlgorithm(
"ChargedDReconstruction",
"ChargedDReconstruction", m_ChargedDReconstruction);
50 log << MSG::ERROR <<
"Error while creating D+Reconstruction" << endreq;
51 return StatusCode::FAILURE;
56 sc = createSubAlgorithm(
"DsReconstruction",
"DsReconstruction", m_DsReconstruction);
58 log << MSG::ERROR <<
"Error while creating DsReconstruction" << endreq;
59 return StatusCode::FAILURE;
63 log << MSG::INFO <<
"successfully return from initialize()" <<endmsg;
64 return StatusCode::SUCCESS;
68StatusCode DTag::registerParent(MsgStream& log) {
69 DataObject *aEvtRecEvent;
70 eventSvc()->findObject(
"/Event/EvtRec",aEvtRecEvent);
71 if (aEvtRecEvent == NULL) {
73 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec",aEvtRecEvent);
74 if (sc != StatusCode::SUCCESS) {
75 log << MSG::FATAL <<
"Could not register EvtRecEvent" <<endreq;
76 return StatusCode::FAILURE;
79 return StatusCode::SUCCESS;
82StatusCode DTag::clearEvtRecDTagCol(MsgStream& log) {
83 StatusCode sc = registerParent(log);
84 if (sc != StatusCode::SUCCESS) {
88 DataObject* aEvtRecDTagCol;
89 eventSvc()->findObject(
"/Event/EvtRec/EvtRecDTagCol",aEvtRecDTagCol);
90 if (aEvtRecDTagCol != NULL) {
92 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
93 dataManSvc->clearSubTree(
"/Event/EvtRec/EvtRecDTagCol");
94 eventSvc()->unregisterObject(
"/Event/EvtRec/EvtRecDTagCol");
98 if( evtRecDTagCol != NULL){
100 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
101 dataManSvc->clearSubTree(
"/Event/EvtRec/EvtRecDTagCol");
102 eventSvc()->unregisterObject(
"/Event/EvtRec/EvtRecDTagCol");
105 return StatusCode::SUCCESS;
108void DTag::registerEvtRecDTagCol(MsgStream& log) {
110 StatusCode sc = eventSvc()->registerObject(
"/Event/EvtRec/EvtRecDTagCol",
112 if (sc != StatusCode::SUCCESS) {
113 log << MSG::FATAL <<
"Could not register EvtRecDTagCol in TDS!" << endreq;
124 if( evtRecDTagCol != NULL ){
125 if ( evtRecDTagCol->size()>0 ) {
126 cout <<
"************************************************"<<endl;
127 cout <<
"EvtRecDTagCol already exists in this file!" << endl;
128 cout <<
" Please run this program on a raw dst file!" << endl;
129 cout <<
" *** This job is now being killed. ***" << endl;
130 cout <<
"************************************************"<<endl;
131 return StatusCode::FAILURE;
136 MsgStream log(
msgSvc(), name());
137 StatusCode sc = clearEvtRecDTagCol(log);
138 if (sc != StatusCode::SUCCESS) {
142 DataObject* aEvtRecDTagCol;
143 eventSvc()->findObject(
"/Event/EvtRec/EvtRecDTagCol", aEvtRecDTagCol);
144 if (aEvtRecDTagCol == NULL) {
145 registerEvtRecDTagCol(log);
148 std::vector<Algorithm*>::const_iterator it = subAlgorithms()->begin();
149 std::vector<Algorithm*>::const_iterator end = subAlgorithms()->end();
150 for(; it != end; it++) {
151 sc = (*it)->execute();
153 log <<
"Error executing selection " << (*it)->name() << endreq;
158 return StatusCode::SUCCESS;
164 MsgStream log(
msgSvc(), name());
165 log << MSG::INFO <<
"in finalize()" << endmsg;
166 return StatusCode::SUCCESS;
ObjectVector< EvtRecDTag > EvtRecDTagCol
DTag(const std::string &name, ISvcLocator *pSvcLocator)
_EXTERN_ std::string EvtRecDTagCol