BOSS 7.0.7
BESIII Offline Software System
Loading...
Searching...
No Matches
DstHltInfCnv.cxx
Go to the documentation of this file.
1#ifndef DstHltInfCnv_CXX
2#define DstHltInfCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6
7#include "TClonesArray.h"
8
10#include "Identifier/HltID.h"
11#include "HltEvent/HltEvent.h" //TDS object
12#include "HltEvent/DstHltInf.h" //TDS object
13#include "RootEventData/THltEvent.h" // standard root object
14#include "RootEventData/TDstHltInf.h" // standard root object
18
19
20// Instantiation of a static factory class used by clients to create
21// instances of this service
22
24 : RootEventBaseCnv(classID(), svc),
25 m_old(false)
26{
27 // Here we associate this converter with the /Event path on the TDS.
28 MsgStream log(msgSvc(), "DstHltInfCnv");
29 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
30 m_rootBranchname ="m_dstHltInf";
31 //declareObject(EventModel::MC::DstHltInf, objType(), m_rootTreename, m_rootBranchname);
32 m_adresses.push_back(&m_dstHltInf);
33 m_dstHltInf=0;
34}
35
36StatusCode DstHltInfCnv::TObjectToDataObject(DataObject*& refpObject) {
37 // creation of TDS object from root object
38
39 MsgStream log(msgSvc(), "DstHltInfCnv");
40 log << MSG::DEBUG << "DstHltInfCnv::TObjectToDataObject" << endreq;
41 StatusCode sc=StatusCode::SUCCESS;
42
43 // create the TDS location for the trigger data
44 DstHltInf* dstHltInfTds = new DstHltInf;
45 refpObject=dstHltInfTds;
46
47 // now convert
48 if(!m_dstHltInf) return sc;
49
50 int evt = m_dstHltInf->getEventType();
51 int alg = m_dstHltInf->getAlgProcess();
52 int cri = m_dstHltInf->getCriteriaTable();
53 int ver = m_dstHltInf->getVersion();
54 float etot = m_dstHltInf->getTotalEnergy();
55
56 dstHltInfTds->setEventType(evt);
57 dstHltInfTds->setAlgProcess(alg);
58 dstHltInfTds->setCriteriaTable(cri);
59 dstHltInfTds->setVersion(ver);
60 dstHltInfTds->setTotalEnergy(etot);
61
62 try{
63 uint32_t nsub= m_dstHltInf->getNumber();
64 uint32_t ncon= m_dstHltInf->getNCON();
65 uint32_t nmdc= nsub &0XFF;
66 uint32_t ntof=(nsub>>8 )&0XFF;
67 uint32_t nemc=(nsub>>16)&0XFF;
68 uint32_t nmuc= nsub>>24;
69 if(nmuc>HltID::getID_MUC_MAX()+1 || nemc>HltID::getID_EMC_MAX()+1
70 ||ntof>HltID::getID_TOF_MAX()+1 || nmdc>HltID::getID_MDC_MAX()+1){
71 throw exception();
72 }
73 dstHltInfTds->setNumber(nsub);
74 dstHltInfTds->setNCON(ncon);
75 }
76 catch(...){
77 //log << MSG::ERROR << "***********************************************************" << endreq;
78 //log << MSG::ERROR << "Input ROOT object is older version, please reconstrut again" << endreq;
79 //log << MSG::ERROR << " or check out old RootCnvSvc! (mailto: [email protected])" << endreq;
80 //log << MSG::WARNING << "***** Continuing run may cause a little memory leakage ****" << endreq;
81 //m_old=true;
82 }
83
84 delete m_dstHltInf;
85 m_dstHltInf = 0;
86
87 return StatusCode::SUCCESS;
88}
89
90StatusCode DstHltInfCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
91
92 MsgStream log(msgSvc(), "DstHltInfCnv");
93 log << MSG::DEBUG << "DstHltInfCnv::DataObjectToTObject" << endreq;
94 StatusCode sc=StatusCode::SUCCESS;
95
96 DstHltInf * dstHltInfCnvTds=dynamic_cast<DstHltInf*> (obj);
97 if (!dstHltInfCnvTds) {
98 log << MSG::ERROR << "Could not downcast to DstHltInf" << endreq;
99 return StatusCode::FAILURE;
100 }
101
102 DataObject *evt;
103 m_eds->findObject(EventModel::Hlt::Event,evt);
104 if (evt==NULL) {
105 log << MSG::ERROR << "Could not get DstHltInf in TDS " << endreq;
106 return StatusCode::FAILURE;
107 }
108
109 HltEvent* devtTds=dynamic_cast<HltEvent *> (evt);
110 if (!devtTds) {
111 log << MSG::ERROR << "DstHltInfCnv:Could not downcast to TDS DstHltInf" << endreq;
112 }
113
114 IOpaqueAddress *addr;
115 m_cnvSvc->getHltCnv()->createRep(evt,addr);
116
118
119 const TObject *tHltInf = hltInf->getDstHltInf();
120 if (!tHltInf) return sc;
121 hltInf->clearDstHltInf();
122
123 Int_t typ = dstHltInfCnvTds->getEventType();
124 Int_t alg = dstHltInfCnvTds->getAlgProcess();
125 Int_t cri = dstHltInfCnvTds->getCriteriaTable();
126 Int_t ver = dstHltInfCnvTds->getVersion();
127 Double_t etot = dstHltInfCnvTds->getTotalEnergy();
128 Int_t nsub = dstHltInfCnvTds->getNumber();
129 Int_t ncon = dstHltInfCnvTds->getNCON();
130
131 TDstHltInf *dstHltInfRoot = new TDstHltInf();
132
133 dstHltInfRoot->setEventType(typ);
134 dstHltInfRoot->setAlgProcess(alg);
135 dstHltInfRoot->setCriteriaTable(cri);
136 dstHltInfRoot->setVersion(ver);
137 dstHltInfRoot->setTotalEnergy(etot);
138 dstHltInfRoot->setNumber(nsub);
139 dstHltInfRoot->setNCON(ncon);
140
141 hltInf->addDstHltInf(dstHltInfRoot);
142
143 return StatusCode::SUCCESS;
144}
145#endif
IMessageSvc * msgSvc()
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
DstHltInfCnv(ISvcLocator *svc)
void setAlgProcess(const unsigned int i)
Definition: DstHltInf.h:31
void setCriteriaTable(const unsigned int i)
Definition: DstHltInf.h:32
float getTotalEnergy() const
Definition: DstHltInf.h:46
uint32_t getCriteriaTable() const
Definition: DstHltInf.h:44
void setNumber(const unsigned int i)
Definition: DstHltInf.h:35
uint32_t getNCON() const
Definition: DstHltInf.h:52
void setNCON(const unsigned int i)
Definition: DstHltInf.h:40
uint32_t getVersion() const
Definition: DstHltInf.h:45
uint32_t getNumber() const
Definition: DstHltInf.h:47
uint32_t getEventType() const
Definition: DstHltInf.h:42
uint32_t getAlgProcess() const
Definition: DstHltInf.h:43
void setEventType(const unsigned int i)
Definition: DstHltInf.h:30
void setTotalEnergy(const float etot)
Definition: DstHltInf.h:34
void setVersion(const unsigned int i)
Definition: DstHltInf.h:33
static THltEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: HltCnv.h:35
static unsigned int getID_MUC_MAX()
Definition: HltID.h:66
static unsigned int getID_EMC_MAX()
Definition: HltID.h:65
static unsigned int getID_MDC_MAX()
Definition: HltID.h:63
static unsigned int getID_TOF_MAX()
Definition: HltID.h:64
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
HltCnv * getHltCnv()
Definition: RootCnvSvc.h:158
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 setNCON(const Int_t i)
Definition: TDstHltInf.h:22
void setVersion(const Int_t i)
Definition: TDstHltInf.h:19
void setNumber(const Int_t i)
Definition: TDstHltInf.h:21
Int_t getAlgProcess() const
Definition: TDstHltInf.h:25
Int_t getVersion() const
Definition: TDstHltInf.h:27
void setTotalEnergy(const Double_t etot)
Definition: TDstHltInf.h:20
Double_t getTotalEnergy() const
Definition: TDstHltInf.h:28
Int_t getEventType() const
Definition: TDstHltInf.h:24
Int_t getNumber() const
Definition: TDstHltInf.h:29
void setEventType(const Int_t i)
Definition: TDstHltInf.h:16
Int_t getNCON() const
Definition: TDstHltInf.h:30
void setCriteriaTable(const Int_t i)
Definition: TDstHltInf.h:18
Int_t getCriteriaTable() const
Definition: TDstHltInf.h:26
void setAlgProcess(const Int_t i)
Definition: TDstHltInf.h:17
void addDstHltInf(TDstHltInf *dstHltInf)
Definition: THltEvent.cxx:82
const TDstHltInf * getDstHltInf() const
Definition: THltEvent.cxx:85
void clearDstHltInf()
Definition: THltEvent.h:40
_EXTERN_ std::string Event
Definition: EventModel.h:72