2#include "GaudiKernel/MsgStream.h"
4#include "EventModel/EventModel.h"
5#include "EvtRecEvent/EvtRecObject.h"
6#include "EvtRecEvent/EvtRecVeeVertex.h"
8#include "RootEventData/TEvtRecObject.h"
9#include "RootEventData/TEvtRecVeeVertex.h"
11#include "RootCnvSvc/RootAddress.h"
12#include "RootCnvSvc/EvtRec/EvtRecCnv.h"
13#include "RootCnvSvc/EvtRec/EvtRecVeeVertexCnv.h"
15#include "CLHEP/Matrix/Vector.h"
16#include "CLHEP/Matrix/SymMatrix.h"
17using CLHEP::HepVector;
18using CLHEP::HepSymMatrix;
23 m_rootBranchname =
"m_evtRecVeeVertexCol";
24 m_adresses.push_back(&m_evtRecVeeVertexCol);
25 m_evtRecVeeVertexCol = 0;
30 MsgStream log(
msgSvc(),
"EvtRecVeeVertexCnv");
31 log << MSG::DEBUG <<
"EvtRecVeeVertexCnv::TObjectToDataObject" << endreq;
35 refpObject = evtRecVeeVertexCol;
37 if ( ! m_evtRecVeeVertexCol )
return StatusCode::SUCCESS;
39 IDataProviderSvc* dataSvc = 0;
40 StatusCode sc = serviceLocator()->getService(
"EventDataSvc",
41 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
42 if ( sc.isFailure() ) {
43 log << MSG::FATAL <<
"Could not get EventDataSvc in EvtRecVeeVertexCnv" << endreq;
48 if ( ! evtRecTrackCol) {
49 log << MSG::INFO <<
"Could not find EvtRecTrackCol" << endreq;
53 TIter evtRecVeeVertexIter(m_evtRecVeeVertexCol);
55 while ( (evtRecVeeVertexRoot = (
TEvtRecVeeVertex*)evtRecVeeVertexIter.Next() ) ) {
61 evtRecVeeVertex->
setChi2( evtRecVeeVertexRoot->
chi2() );
62 evtRecVeeVertex->
setNdof( evtRecVeeVertexRoot->
ndof() );
63 evtRecVeeVertex->
setMass( evtRecVeeVertexRoot->
mass() );
65 HepVector wTrackParameter(7, 0);
66 for (
int i = 0; i < 7; i++) {
67 wTrackParameter[i] = evtRecVeeVertexRoot->
w(i);
69 evtRecVeeVertex->
setW( wTrackParameter );
71 HepSymMatrix EwTrackParameter(7, 0);
73 for (
int j = 0; j < 7; j++) {
74 for (
int k = j; k < 7; k++) {
75 EwTrackParameter[j][k] = EwTrackParameter[k][j] = evtRecVeeVertexRoot->
Ew(i);
79 evtRecVeeVertex->
setEw( EwTrackParameter );
81 std::pair<int, int> pairId;
82 pairId.first = evtRecVeeVertexRoot->
pair(0);
83 pairId.second = evtRecVeeVertexRoot->
pair(1);
84 evtRecVeeVertex->
setPair( pairId );
87 int evtRecTrackId0 = evtRecVeeVertexRoot->
daughter(0);
88 if ( evtRecTrackId0 >= 0) {
90 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(evtRecTrackId0)), 0
93 int evtRecTrackId1 = evtRecVeeVertexRoot->
daughter(1);
94 if ( evtRecTrackId1 >= 0) {
96 dynamic_cast<EvtRecTrack*
>(evtRecTrackCol->containedObject(evtRecTrackId1)), 1
100 evtRecVeeVertexCol->push_back(evtRecVeeVertex);
103 delete m_evtRecVeeVertexCol;
104 m_evtRecVeeVertexCol = 0;
105 return StatusCode::SUCCESS;
109 MsgStream log(
msgSvc(),
"EvtRecVeeVertexCnv");
110 log << MSG::DEBUG <<
"EvtRecVeeVertexCnv::DataObjectToTObject" << endreq;
113 if ( ! evtRecVeeVertexCol ) {
114 log << MSG::ERROR <<
"Could not downcast to EvtRecVeeVertexCol" << endreq;
115 return StatusCode::FAILURE;
121 log << MSG::ERROR <<
"Could not get EvtRecObject in TDS" << endreq;
122 return StatusCode::FAILURE;
126 log << MSG::ERROR <<
"EvtRecVeeVertexCnv: Could not downcast to TDS EvtRecObject" << endreq;
129 IOpaqueAddress *addr;
134 if ( ! m_evtRecVeeVertexCol )
return StatusCode::SUCCESS;
136 IDataProviderSvc* dataSvc = 0;
137 StatusCode sc = serviceLocator()->getService(
"EventDataSvc",
138 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
139 if ( sc.isFailure() ) {
140 log << MSG::FATAL <<
"Could not get EventDataSvc in EvtRecVeeVertexCnv" << endreq;
144 EvtRecTrackCol::iterator evtRecTrackColbegin, evtRecTrackColend;
147 if ( ! evtRecTrackCol) {
148 log << MSG::INFO <<
"Could not find EvtRecTrackCol" << endreq;
151 evtRecTrackColbegin = evtRecTrackCol->begin();
152 evtRecTrackColend = evtRecTrackCol->end();
157 EvtRecVeeVertexCol::const_iterator evtRecVeeVertex = evtRecVeeVertexCol->begin();
159 for ( ; evtRecVeeVertex != evtRecVeeVertexCol->end(); evtRecVeeVertex++) {
169 double wTrackParameter[7];
170 for (
int i = 0; i < 7; i++) {
171 wTrackParameter[i] = ptr->
w()[i];
173 evtRecVeeVertexRoot->
setW( wTrackParameter );
174 double EwTrackParameter[28];
176 for (
int j = 0; j < 7; j++) {
177 for (
int k = j; k < 7; k++) {
178 EwTrackParameter[i] = ptr->
Ew()[j][k];
183 evtRecVeeVertexRoot->
setEw( EwTrackParameter );
185 pairId[0] = ptr->
pair(0);
186 pairId[1] = ptr->
pair(1);
187 evtRecVeeVertexRoot->
setPair( pairId );
192 if ( ptr->
daughter(0).target() != NULL && ptr->
daughter(1).target() != NULL ) {
193 assert(evtRecTrackColbegin != evtRecTrackColend);
194 EvtRecTrackCol::iterator it0 = find(evtRecTrackColbegin,
195 evtRecTrackColend, ptr->
daughter(0).target());
196 EvtRecTrackCol::iterator it1 = find(evtRecTrackColbegin,
197 evtRecTrackColend, ptr->
daughter(1).target());
198 assert(it0 != evtRecTrackColend);
199 assert(it1 != evtRecTrackColend);
200 daughterId[0] = it0 - evtRecTrackColbegin;
201 daughterId[1] = it1 - evtRecTrackColbegin;
207 return StatusCode::SUCCESS;
ObjectVector< EvtRecVeeVertex > EvtRecVeeVertexCol
static TEvtRecObject * getWriteObject()
EvtRecVeeVertexCnv(ISvcLocator *svc)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
const std::pair< int, int > & pair() const
void setVertexType(int vtxType)
void setChi2(double chi2)
SmartRef< EvtRecTrack > & daughter(int i)
void addDaughter(const SmartRef< EvtRecTrack > &track, int i)
void setEw(const HepSymMatrix &Ew)
void setMass(double mass)
void setNTracks(int nTracks)
void setVertexId(int vtxId)
void setPair(const std::pair< int, int > &pair)
const HepVector & w() const
const HepSymMatrix & Ew() const
void setW(const HepVector &w)
void setNCharge(int nCharge)
Definition of a Root address, derived from IOpaqueAddress.
EvtRecCnv * getEvtRecCnv()
Base class for all Root Converters.
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void clearEvtRecVeeVertexCol()
void addEvtRecVeeVertex(TEvtRecVeeVertex *veeVertex)
const TObjArray * getEvtRecVeeVertexCol() const
void setDaughter(Int_t daughter[2])
void setVertexId(Int_t vtxId)
Int_t pair(Int_t i) const
Double_t w(Int_t i) const
void setPair(Int_t pair[2])
Int_t daughter(Int_t i) const
void setVertexType(Int_t vtxType)
void setEw(Double_t Ew[28])
void setChi2(Double_t chi2)
Double_t Ew(Int_t i) const
void setNTracks(Int_t nTracks)
void setMass(Double_t mass)
void setNCharge(Int_t nCharge)
static std::map< const TObject *, const EvtRecVeeVertex * > m_rootEvtRecVeeVertexMap
_EXTERN_ std::string Event
_EXTERN_ std::string EvtRecTrackCol