BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtRecPrimaryVertexCnv.cxx
Go to the documentation of this file.
1#include "GaudiKernel/MsgStream.h"
2
6
9
13
14#include "CLHEP/Matrix/Vector.h"
15#include "CLHEP/Matrix/SymMatrix.h"
16using CLHEP::HepVector;
17using CLHEP::HepSymMatrix;
18
20 : RootEventBaseCnv(classID(), svc)
21{
22 m_rootBranchname = "m_evtRecPrimaryVertex";
23 m_adresses.push_back(&m_evtRecPrimaryVertex);
24 m_evtRecPrimaryVertex = 0;
25}
26
27StatusCode EvtRecPrimaryVertexCnv::TObjectToDataObject(DataObject*& refpObject) {
28 MsgStream log(msgSvc(), "EvtRecPrimaryVertexCnv");
29 log << MSG::DEBUG << "EvtRecPrimaryVertexCnv::TObjectToDataObject" << endreq;
30
31 // create the TDS location for the EvtRecPrimaryVertex
32 EvtRecPrimaryVertex* evtRecPrimaryVertex = new EvtRecPrimaryVertex;
33 refpObject = evtRecPrimaryVertex;
34
35 if ( ! m_evtRecPrimaryVertex ) return StatusCode::SUCCESS;
36 // convert
37 evtRecPrimaryVertex->setIsValid (m_evtRecPrimaryVertex->isValid() );
38 evtRecPrimaryVertex->setNTracks (m_evtRecPrimaryVertex->nTracks() );
39 evtRecPrimaryVertex->setTrackIdList (m_evtRecPrimaryVertex->trackIdList() );
40 evtRecPrimaryVertex->setChi2 (m_evtRecPrimaryVertex->chi2() );
41 evtRecPrimaryVertex->setNdof (m_evtRecPrimaryVertex->ndof() );
42 evtRecPrimaryVertex->setFitMethod (m_evtRecPrimaryVertex->fitMethod() );
43
44 HepVector vtx(3, 0);
45 for (Int_t i = 0; i < 3; i++) {
46 vtx[i] = m_evtRecPrimaryVertex->vertex(i);
47 }
48
49 HepSymMatrix Evtx(3, 0);
50 Evtx[0][0] = m_evtRecPrimaryVertex->errorVertex(0);
51 Evtx[0][1] = Evtx[1][0] = m_evtRecPrimaryVertex->errorVertex(1);
52 Evtx[0][2] = Evtx[2][0] = m_evtRecPrimaryVertex->errorVertex(2);
53 Evtx[1][1] = m_evtRecPrimaryVertex->errorVertex(3);
54 Evtx[1][2] = Evtx[2][1] = m_evtRecPrimaryVertex->errorVertex(4);
55 Evtx[2][2] = m_evtRecPrimaryVertex->errorVertex(5);
56
57 evtRecPrimaryVertex->setVertex (vtx);
58 evtRecPrimaryVertex->setErrorVertex (Evtx);
59
60 delete m_evtRecPrimaryVertex;
61 m_evtRecPrimaryVertex = 0;
62 return StatusCode::SUCCESS;
63}
64
65StatusCode EvtRecPrimaryVertexCnv::DataObjectToTObject(DataObject* obj, RootAddress* rootaddr) {
66
67 MsgStream log(msgSvc(), "EvtRecPrimaryVertexCnv");
68 log << MSG::DEBUG << "EvtRecPrimaryVertexCnv::DataObjectToTObject" << endreq;
69
70 EvtRecPrimaryVertex* evtRecPrimaryVertex = dynamic_cast<EvtRecPrimaryVertex*> (obj);
71 if ( ! evtRecPrimaryVertex ) {
72 log << MSG::ERROR << "Could not downcast to EvtRecPrimaryVertex" << endreq;
73 return StatusCode::FAILURE;
74 }
75
76 DataObject* evt = NULL;
77 StatusCode sc = m_eds->findObject(EventModel::EvtRec::Event, evt);
78 if ( sc.isFailure() ) {
79 log << MSG::ERROR << "Could not get EvtRecObject in TDS" << endreq;
80 return StatusCode::FAILURE;
81 }
82
83 EvtRecObject* devtTds = dynamic_cast<EvtRecObject*> (evt);
84 if ( ! devtTds ) {
85 log << MSG::ERROR << "EvtRecPrimaryVertexCnv: Could not downcast to TDS EvtRecObject" << endreq;
86 }
87
88 IOpaqueAddress* addr;
89 m_cnvSvc->getEvtRecCnv()->createRep(evt, addr);
91
92 //recEvt->clearEvtRecPrimaryVertex();
93
94 TEvtRecPrimaryVertex* m_evtRecPrimaryVertex = const_cast<TEvtRecPrimaryVertex*>( recEvt->getEvtRecPrimaryVertex() );
95
96 m_evtRecPrimaryVertex->setIsValid (evtRecPrimaryVertex->isValid() );
97 m_evtRecPrimaryVertex->setNTracks (evtRecPrimaryVertex->nTracks() );
98 m_evtRecPrimaryVertex->setTrackIdList (evtRecPrimaryVertex->trackIdList() );
99 m_evtRecPrimaryVertex->setChi2 (evtRecPrimaryVertex->chi2() );
100 m_evtRecPrimaryVertex->setNdof (evtRecPrimaryVertex->ndof() );
101 m_evtRecPrimaryVertex->setFitMethod (evtRecPrimaryVertex->fitMethod() );
102
103 Double_t vtx[3];
104 for (Int_t i = 0; i < 3; i++) {
105 vtx[i] = evtRecPrimaryVertex->vertex()[i];
106 }
107 Double_t Evtx[6];
108 Evtx[0] = evtRecPrimaryVertex->errorVertex()[0][0];
109 Evtx[1] = evtRecPrimaryVertex->errorVertex()[0][1];
110 Evtx[2] = evtRecPrimaryVertex->errorVertex()[0][2];
111 Evtx[3] = evtRecPrimaryVertex->errorVertex()[1][1];
112 Evtx[4] = evtRecPrimaryVertex->errorVertex()[1][2];
113 Evtx[5] = evtRecPrimaryVertex->errorVertex()[2][2];
114 m_evtRecPrimaryVertex->setVertex (vtx);
115 m_evtRecPrimaryVertex->setErrorVertex (Evtx);
116
117 return StatusCode::SUCCESS;
118}
IMessageSvc * msgSvc()
#define NULL
static TEvtRecObject * getWriteObject()
Definition: EvtRecCnv.h:26
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
EvtRecPrimaryVertexCnv(ISvcLocator *svc)
void setTrackIdList(const std::vector< int > &trackIdList)
void setVertex(const HepVector &vtx)
const HepVector & vertex() const
void setFitMethod(int fitMethod)
const std::vector< int > & trackIdList() const
void setErrorVertex(const HepSymMatrix &Evtx)
void setChi2(double chi2)
const HepSymMatrix & errorVertex() const
void setNTracks(int nTracks)
void setIsValid(bool isValid)
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
EvtRecCnv * getEvtRecCnv()
Definition: RootCnvSvc.h:159
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.
const TEvtRecPrimaryVertex * getEvtRecPrimaryVertex() const
Definition: TEvtRecObject.h:39
Double_t errorVertex(Int_t i) const
void setChi2(Double_t chi2)
void setTrackIdList(const std::vector< Int_t > &trackIdList)
Double_t vertex(Int_t i) const
void setNdof(Int_t ndof)
const std::vector< Int_t > & trackIdList() const
void setErrorVertex(Double_t Evtx[6])
void setIsValid(Bool_t isValid)
void setFitMethod(Int_t fitMethod)
void setVertex(Double_t vtx[3])
void setNTracks(Int_t nTracks)
_EXTERN_ std::string Event
Definition: EventModel.h:115