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