BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
RecEvTimeCnv.cxx
Go to the documentation of this file.
1#ifndef RecEvTimeCnv_CXX
2#define RecEvTimeCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
13
14//#include "RootEventData/TMucTrack.h" // standard root object
15#include "RootEventData/TRecEvTime.h" // standard root object
16//#include "RootEventData/TDstEvent.h"
18
22
23#include <vector>
24
25using namespace std;
26
27// Instantiation of a static factory class used by clients to create
28// instances of this service
29//static CnvFactory<RecEvTimeCnv> s_factory;
30//const ICnvFactory& RecEvTimeCnvFactory = s_factory;
31
33: RootEventBaseCnv(classID(), svc)
34{
35
36 // Here we associate this converter with the /Event path on the TDS.
37 MsgStream log(msgSvc(), "RecEvTimeCnv");
38 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
39 //m_rootTreename ="Rec";
40 m_rootBranchname ="m_recEvTimeCol";
41 // declareObject(EventModel::Recon::EvTimeCol, objType(), m_rootTreename, m_rootBranchname);
42 m_adresses.push_back(&m_recEvTimeCol);
43 m_recEvTimeCol=0;
44}
45
46StatusCode RecEvTimeCnv::TObjectToDataObject(DataObject*& refpObject) {
47 // creation of TDS object from root object
48MsgStream log(msgSvc(), "RecEvTimeCnv");
49 log << MSG::DEBUG << "RecEvTimeCnv::TObjectToDataObject" << endreq;
50 StatusCode sc=StatusCode::SUCCESS;
51
52 // create the TDS location for the MucTrack Collection
53 RecEsTimeCol* evTimeTdsCol = new RecEsTimeCol;
54 refpObject=evTimeTdsCol;
55 // now convert
56 if (!m_recEvTimeCol) return sc;
57 TIter evTimeIter(m_recEvTimeCol);
58 TRecEvTime *evTimeRoot = 0;
59 while ((evTimeRoot = (TRecEvTime*)evTimeIter.Next())) {
60 double estime=evTimeRoot->estime();
61 int status=evTimeRoot->status();
62 double quality=evTimeRoot->quality();
63 //double estime=evTimeRoot->getTest();
64 //int status=evTimeRoot->getStat();
65
66 RecEsTime *evTimeTds = new RecEsTime();
67 m_common.m_rootRecEvTimeMap[evTimeRoot] = evTimeTds;
68 evTimeTds->setTest( estime );
69 evTimeTds->setStat( status );
70 evTimeTds->setQuality( quality );
71 evTimeTdsCol->push_back(evTimeTds);
72 }
73 delete m_recEvTimeCol;
74 m_recEvTimeCol = 0;
75
76 return StatusCode::SUCCESS;
77}
78
79StatusCode RecEvTimeCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
80 MsgStream log(msgSvc(), "RecEvTimeCnv");
81 log << MSG::DEBUG << "RecEvTimeCnv::DataObjectToTObject" << endreq;
82 StatusCode sc=StatusCode::SUCCESS;
83
84 RecEsTimeCol * evTimeColTds=dynamic_cast<RecEsTimeCol *> (obj);
85 if (!evTimeColTds) {
86 log << MSG::ERROR << "Could not downcast to RecEsTimeCol" << endreq;
87 return StatusCode::FAILURE;
88 }
89
90 DataObject *evt;
91 m_eds->findObject(EventModel::Recon::Event,evt);
92 if (evt==NULL) {
93 log << MSG::ERROR << "Could not get RecEvent in TDS " << endreq;
94 return StatusCode::FAILURE;
95 }
96 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
97 if (!devtTds) {
98 log << MSG::ERROR << "RecEvTimeCnv:Could not downcast to TDS ReconEvent" << endreq;
99 }
100 IOpaqueAddress *addr;
101
102 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
104 const TObjArray *m_recEvTimeCol = recEvt->getEvTimeCol();
105 if (!m_recEvTimeCol) return sc;
106 recEvt->clearEvTimeCol(); //necessary in case there is I/O at the same time since array is static
107 RecEsTimeCol::const_iterator evTimeTds;
108 for (evTimeTds = evTimeColTds->begin(); evTimeTds != evTimeColTds->end(); evTimeTds++) {
109 //Double_t estime = (*evTimeTds)->estime();
110 //Int_t status = (*evTimeTds)->status();
111 Double_t estime = (*evTimeTds)->getTest();
112 Int_t status = (*evTimeTds)->getStat();
113 Double_t quality = (*evTimeTds)->getQuality();
114 TRecEvTime *evTimeRoot = new TRecEvTime();
115 //m_common.m_RecEvTimeMap[(*evTimeTds)] = evTimeRoot;
116
117 evTimeRoot->setTest( estime );
118 evTimeRoot->setStats( status );
119 evTimeRoot->setQuality( quality );
120
121 recEvt->addEvTime(evTimeRoot);
122 }
123
124 return StatusCode::SUCCESS;
125}
126#endif
ObjectVector< RecEsTime > RecEsTimeCol
Definition RecEsTime.h:53
IMessageSvc * msgSvc()
#define NULL
void setStat(int Stat)
Definition RecEsTime.h:37
void setTest(double Test)
Definition RecEsTime.h:36
void setQuality(double Quality)
Definition RecEsTime.h:38
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
RecEvTimeCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition RecTrackCnv.h:36
Definition of a Root address, derived from IOpaqueAddress.
Definition RootAddress.h:21
RecTrackCnv * getRecTrackCnv()
Definition RootCnvSvc.h:173
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
Double_t estime() const
Definition TRecEvTime.h:26
void setStats(Int_t status)
Definition TRecEvTime.h:30
void setQuality(Double_t quality)
Definition TRecEvTime.h:31
void setTest(Double_t estime)
Definition TRecEvTime.h:29
Int_t status() const
Definition TRecEvTime.h:25
Double_t quality() const
Definition TRecEvTime.h:27
const TObjArray * getEvTimeCol() const
void addEvTime(TRecEvTime *Track)
static std::map< const TObject *, const RecEsTime * > m_rootRecEvTimeMap
Definition commonData.h:248
_EXTERN_ std::string Event
Definition EventModel.h:84