BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
LumiDigiCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2#include "GaudiKernel/DataObject.h"
3#include "GaudiKernel/ObjectVector.h"
4
5#include "TClonesArray.h"
6
8#include "LumiDigi/LumiDigi.h"
13
14LumiDigiCnv::LumiDigiCnv(ISvcLocator* svc)
15 : RootEventBaseCnv(classID(), svc)
16{
17 m_rootBranchname = "m_lumiDigiCol";
18
19 m_adresses.push_back(&m_lumiDigiCol);
20 m_lumiDigiCol = 0;
21}
22
23StatusCode LumiDigiCnv::TObjectToDataObject(DataObject*& refpObject) {
24 // creation of TDS object from root object
25
26 MsgStream log(msgSvc(), "LumiDigiCnv");
27 log << MSG::DEBUG << "LumiDigiCnv::TObjectToDataObject" << endreq;
28 StatusCode sc = StatusCode::SUCCESS;
29
30 LumiDigiCol* lumiDigiTdsCol = new LumiDigiCol;
31 refpObject = lumiDigiTdsCol;
32
33 if ( !m_lumiDigiCol ) return sc;
34 TIter lumiDigiIter(m_lumiDigiCol);
35 TLumiDigi* lumiDigiRoot = 0;
36 while ((lumiDigiRoot = (TLumiDigi*)lumiDigiIter.Next())) {
37 LumiDigi* lumiDigiTds = new LumiDigi( lumiDigiRoot->getIntId() );
38 m_common.m_rootLumiDigiMap[lumiDigiRoot] = lumiDigiTds;
39
40 lumiDigiTds->setTimeChannel( lumiDigiRoot->getTimeChannel() );
41 lumiDigiTds->setChargeChannel( lumiDigiRoot->getChargeChannel() );
42 lumiDigiTds->setOverflow( lumiDigiRoot->getOverflow() );
43
44 lumiDigiTdsCol->push_back(lumiDigiTds);
45 }
46
47 delete m_lumiDigiCol;
48 m_lumiDigiCol = 0;
49 return sc;
50}
51
52StatusCode LumiDigiCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
53
54 MsgStream log(msgSvc(), "LumiDigiCnv");
55 log << MSG::DEBUG << "LumiDigiCnv::DataObjectToTObject" << endreq;
56 StatusCode sc = StatusCode::SUCCESS;
57
58 LumiDigiCol* lumiDigiColTds = dynamic_cast<LumiDigiCol*>(obj);
59 if ( !lumiDigiColTds ) {
60 log << MSG::ERROR << "Could not downcast to LumiDigiCol" << endreq;
61 return StatusCode::FAILURE;
62 }
63
64 DataObject* evt;
65 m_eds->findObject(EventModel::Digi::Event, evt);
66 if ( evt == NULL ) {
67 log << MSG::ERROR << "Could not get DigiEvent in TDS" << endreq;
68 return StatusCode::FAILURE;
69 }
70 DigiEvent* devtTds = dynamic_cast<DigiEvent*>(evt);
71 if ( !devtTds ) {
72 log << MSG::ERROR << "LumiDigiCnv: Could not downcast to TDS DigiEvent" << endreq;
73 }
74 IOpaqueAddress* addr;
75
76 m_cnvSvc->getDigiCnv()->createRep(evt, addr);
77
79
80 const TObjArray* m_lumiDigiCol = recEvt->getLumiDigiCol();
81 if ( !m_lumiDigiCol ) return sc;
82 recEvt->clearLumiDigiCol();
83 LumiDigiCol::const_iterator lumiDigiTds;
84
85 for (lumiDigiTds = lumiDigiColTds->begin(); lumiDigiTds != lumiDigiColTds->end(); ++lumiDigiTds) {
86 TLumiDigi* lumiDigiRoot = new TLumiDigi();
87
88 lumiDigiRoot->initialize((*lumiDigiTds)->getIntId(),
89 (*lumiDigiTds)->getTimeChannel(), (*lumiDigiTds)->getChargeChannel());
90 lumiDigiRoot->setOverflow( (*lumiDigiTds)->getOverflow() );
91
92 recEvt->addLumiDigi(lumiDigiRoot);
93 }
94
95 return sc;
96}
ObjectVector< LumiDigi > LumiDigiCol
Definition: LumiDigi.h:36
IMessageSvc * msgSvc()
static TDigiEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: DigiCnv.h:35
LumiDigiCnv(ISvcLocator *svc)
Definition: LumiDigiCnv.cxx:14
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition: LumiDigiCnv.cxx:23
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
Definition: LumiDigiCnv.cxx:52
void setOverflow(const unsigned int overflow)
Definition: LumiDigi.h:19
void setChargeChannel(const unsigned int chargeChannel)
Definition: RawData.cxx:30
void setTimeChannel(const unsigned int timeChannel)
Definition: RawData.cxx:25
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
DigiCnv * getDigiCnv()
Definition: RootCnvSvc.h:154
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.
void clearLumiDigiCol()
clear the whole array
Definition: TDigiEvent.h:89
void addLumiDigi(TLumiDigi *digi)
Add a LumiDigi into the MUC Data collection.
Definition: TDigiEvent.cxx:165
const TObjArray * getLumiDigiCol() const
retrieve the whole TObjArray of LumiDigi Data
Definition: TDigiEvent.h:80
UInt_t getOverflow() const
Definition: TLumiDigi.cxx:17
void setOverflow(const UInt_t overflow)
Definition: TLumiDigi.cxx:13
void initialize(UInt_t id, UInt_t time=0, UInt_t charge=0)
Definition: TRawData.cxx:34
UInt_t getIntId() const
Definition: TRawData.cxx:50
UInt_t getChargeChannel() const
Definition: TRawData.cxx:60
UInt_t getTimeChannel() const
Definition: TRawData.cxx:55
static std::map< const TObject *, const LumiDigi * > m_rootLumiDigiMap
Definition: commonData.h:137
_EXTERN_ std::string Event
Definition: EventModel.h:56