BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TofMcHitCnv Class Reference

#include <TofMcHitCnv.h>

Inheritance diagram for TofMcHitCnv:

Public Member Functions

virtual ~TofMcHitCnv ()
 TofMcHitCnv (ISvcLocator *svc)
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
virtual ~TofMcHitCnv ()
 TofMcHitCnv (ISvcLocator *svc)
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
virtual ~TofMcHitCnv ()
 TofMcHitCnv (ISvcLocator *svc)
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
Public Member Functions inherited from RootEventBaseCnv
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
virtual ~RootEventBaseCnv ()
virtual long repSvcType () const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
TObject * getReadObject () const
 get the object to be read
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
virtual ~RootEventBaseCnv ()
virtual long repSvcType () const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
TObject * getReadObject () const
 get the object to be read
 RootEventBaseCnv (const CLID &clid, ISvcLocator *svc)
virtual ~RootEventBaseCnv ()
virtual long repSvcType () const
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void declareObject (const std::string &fullPath, const CLID &clid, const std::string &treename, const std::string &branchname)
 Store TDS path to link a particular converter to an object on the TDS.
virtual StatusCode createObj (IOpaqueAddress *addr, DataObject *&dat)
 Convert the persistent object to transient.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Resolve the references of the converted object.
TObject * getReadObject () const
 get the object to be read
Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
destinationoperator (const source &) const
destinationoperator (const source &) const

Static Public Member Functions

static const CLID & classID ()
static const CLID & classID ()
static const CLID & classID ()
Static Public Member Functions inherited from RootEventBaseCnv
static const unsigned char storageType ()
 Storage type and class ID.
static const unsigned char storageType ()
 Storage type and class ID.
static const unsigned char storageType ()
 Storage type and class ID.

Friends

class CnvFactory< TofMcHitCnv >

Additional Inherited Members

Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
typedef Ty1 source
typedef Ty2 destination
Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
virtual destinationconvert (const source &) const =0
Protected Attributes inherited from RootEventBaseCnv
IRootCnvSvcm_cnvSvc
std::vector< RootCnvSvc::Leafm_leaves
RootInterfacem_rootInterface
 pointer to the RootInterface
IDataProviderSvc * m_eds
 pointer to eventdataservice
int m_branchNr
 the branchNr of this converter for writing
int m_branchNrDst
int m_branchNrMc
int m_branchNrRecon
int m_branchNrEvtRec
int m_branchNrEvtHeader
int m_branchNrEvtNavigator
TObject * m_objRead
 the object that was read
CLID CLID_top
 the CLID of the upper converter if any
TArrayS * m_branchNumbers
 array with number of branches for reading
std::string m_rootBranchname
 root branchname (may be concatenated of severals)
std::string m_rootTreename
 each converter knows it's treename
std::string m_currentFileName
std::vector< void * > m_adresses
 each converter knows the corresponding adresses
RootEvtSelectorm_evtsel

Detailed Description

Constructor & Destructor Documentation

◆ ~TofMcHitCnv() [1/3]

virtual TofMcHitCnv::~TofMcHitCnv ( )
inlinevirtual

Definition at line 26 of file Event/RootCnvSvc/include/RootCnvSvc/Mc/TofMcHitCnv.h.

26{};

◆ TofMcHitCnv() [1/3]

TofMcHitCnv::TofMcHitCnv ( ISvcLocator * svc)

Definition at line 24 of file TofMcHitCnv.cxx.

24 : RootEventBaseCnv( classID(), svc ) {
25 // Here we associate this converter with the /Event path on the TDS.
26 MsgStream log( msgSvc(), "TofMcHitCnv" );
27 // log << MSG::DEBUG << "Constructor called for " << objType() << endmsg;
28 m_rootBranchname = "m_tofMcHitCol";
29 // declareObject(EventModel::MC::TofMcHitCol, objType(), m_rootTreename, m_rootBranchname);
30 m_adresses.push_back( &m_tofMcHitCol );
31 m_tofMcHitCol = 0;
32}
IMessageSvc * msgSvc()
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)

◆ ~TofMcHitCnv() [2/3]

virtual TofMcHitCnv::~TofMcHitCnv ( )
inlinevirtual

◆ TofMcHitCnv() [2/3]

TofMcHitCnv::TofMcHitCnv ( ISvcLocator * svc)

◆ ~TofMcHitCnv() [3/3]

virtual TofMcHitCnv::~TofMcHitCnv ( )
inlinevirtual

◆ TofMcHitCnv() [3/3]

TofMcHitCnv::TofMcHitCnv ( ISvcLocator * svc)

Member Function Documentation

◆ classID() [1/3]

const CLID & TofMcHitCnv::classID ( )
inlinestatic

Definition at line 24 of file Event/RootCnvSvc/include/RootCnvSvc/Mc/TofMcHitCnv.h.

24{ return CLID_TofMcHitCol; }
const CLID & CLID_TofMcHitCol

Referenced by RootCnvSvc::createConverter(), and TofMcHitCnv().

◆ classID() [2/3]

const CLID & TofMcHitCnv::classID ( )
inlinestatic

◆ classID() [3/3]

const CLID & TofMcHitCnv::classID ( )
inlinestatic

◆ DataObjectToTObject() [1/3]

StatusCode TofMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
virtual

transformation to root

Implements RootEventBaseCnv.

Definition at line 84 of file TofMcHitCnv.cxx.

84 {
85
86 MsgStream log( msgSvc(), "TofMcHitCnv" );
87 log << MSG::DEBUG << "TofMcHitCnv::DataObjectToTObject" << endmsg;
88 StatusCode sc = StatusCode::SUCCESS;
89
90 TofMcHitCol* tofMcHitCnvTds = dynamic_cast<TofMcHitCol*>( obj );
91 if ( !tofMcHitCnvTds )
92 {
93 log << MSG::ERROR << "Could not downcast to TofMcHitCol" << endmsg;
94 return StatusCode::FAILURE;
95 }
96
97 DataObject* evt;
98 m_eds->findObject( EventModel::MC::Event, evt );
99 if ( evt == NULL )
100 {
101 log << MSG::ERROR << "Could not get McEvent in TDS " << endmsg;
102 return StatusCode::FAILURE;
103 }
104 McEvent* devtTds = dynamic_cast<McEvent*>( evt );
105 if ( !devtTds )
106 { log << MSG::ERROR << "TofMcHitCnv:Could not downcast to TDS McEvent" << endmsg; }
107 IOpaqueAddress* addr;
108
109 m_cnvSvc->getMcCnv()->createRep( evt, addr );
110 TMcEvent* McEvt = m_cnvSvc->getMcCnv()->getWriteObject();
111
112 const TObjArray* m_tofMcHitCol = McEvt->getTofMcHitCol();
113 if ( !m_tofMcHitCol ) return sc;
114 McEvt->clearTofMcHitCol(); // necessary in case there is I/O at the same time since array is
115 // static
116 TofMcHitCol::const_iterator tofMcTds;
117
118 for ( tofMcTds = tofMcHitCnvTds->begin(); tofMcTds != tofMcHitCnvTds->end(); tofMcTds++ )
119 {
120 UInt_t id = ( ( *tofMcTds )->identify() ).get_value();
121 UInt_t trackIndex = ( *tofMcTds )->getTrackIndex();
122 Double_t xPosition = ( *tofMcTds )->getPositionX();
123 Double_t yPosition = ( *tofMcTds )->getPositionY();
124 Double_t zPosition = ( *tofMcTds )->getPositionZ();
125 Double_t px = ( *tofMcTds )->getPx();
126 Double_t py = ( *tofMcTds )->getPy();
127 Double_t pz = ( *tofMcTds )->getPz();
128 Double_t trackLength = ( *tofMcTds )->getTrackLength();
129 Double_t flightTime = ( *tofMcTds )->getFlightTime();
130
131 TTofMc* tofMcRoot = new TTofMc();
132 // m_common.m_tofMcHitMap[(*tofMcTds)] = tofMcRoot;
133
134 tofMcRoot->setId( id );
135 tofMcRoot->setTrackIndex( trackIndex );
136 tofMcRoot->setPositionX( xPosition );
137 tofMcRoot->setPositionY( yPosition );
138 tofMcRoot->setPositionZ( zPosition );
139 tofMcRoot->setPx( px );
140 tofMcRoot->setPy( py );
141 tofMcRoot->setPz( pz );
142 tofMcRoot->setTrackLength( trackLength );
143 tofMcRoot->setFlightTime( flightTime );
144
145 McEvt->addTofMc( tofMcRoot );
146 }
147
148 return StatusCode::SUCCESS;
149}
ObjectVector< TofMcHit > TofMcHitCol
IDataProviderSvc * m_eds
pointer to eventdataservice
void addTofMc(TTofMc *mcHit)
Tof.
Definition TMcEvent.cxx:99
void setTrackLength(Double_t trackLength)
void setFlightTime(Double_t flightTime)

◆ DataObjectToTObject() [2/3]

virtual StatusCode TofMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
virtual

transformation to root

Implements RootEventBaseCnv.

◆ DataObjectToTObject() [3/3]

virtual StatusCode TofMcHitCnv::DataObjectToTObject ( DataObject * obj,
RootAddress * addr )
virtual

transformation to root

Implements RootEventBaseCnv.

◆ TObjectToDataObject() [1/3]

StatusCode TofMcHitCnv::TObjectToDataObject ( DataObject *& obj)
virtual

transformation from root

Implements RootEventBaseCnv.

Definition at line 34 of file TofMcHitCnv.cxx.

34 {
35 // creation of TDS object from root object
36
37 MsgStream log( msgSvc(), "TofMcHitCnv" );
38 log << MSG::DEBUG << "TofMcHitCnv::TObjectToDataObject" << endmsg;
39 StatusCode sc = StatusCode::SUCCESS;
40
41 // create the TDS location for the MdcMc Collection
42 TofMcHitCol* tofMcTdsCol = new TofMcHitCol;
43 refpObject = tofMcTdsCol;
44
45 // now convert
46 if ( !m_tofMcHitCol ) return sc;
47 TIter tofMcIter( m_tofMcHitCol );
48 TTofMc* tofMcRoot = 0;
49 while ( ( tofMcRoot = (TTofMc*)tofMcIter.Next() ) )
50 {
51 unsigned int id = tofMcRoot->getId();
52 unsigned int trackIndex = tofMcRoot->getTrackIndex();
53 double xPosition = tofMcRoot->getPositionX();
54 double yPosition = tofMcRoot->getPositionY();
55 double zPosition = tofMcRoot->getPositionZ();
56 double px = tofMcRoot->getPx();
57 double py = tofMcRoot->getPy();
58 double pz = tofMcRoot->getPz();
59 double trackLength = tofMcRoot->getTrackLength();
60 double flightTime = tofMcRoot->getFlightTime();
61
62 TofMcHit* tofMcTds = new TofMcHit;
63 m_common.m_rootTofMcHitMap[tofMcRoot] = tofMcTds;
64
65 tofMcTds->setIdentifier( id );
66 tofMcTds->setTrackIndex( trackIndex );
67 tofMcTds->setPositionX( xPosition );
68 tofMcTds->setPositionY( yPosition );
69 tofMcTds->setPositionZ( zPosition );
70 tofMcTds->setPx( px );
71 tofMcTds->setPy( py );
72 tofMcTds->setPz( pz );
73 tofMcTds->setTrackLength( trackLength );
74 tofMcTds->setFlightTime( flightTime );
75
76 tofMcTdsCol->push_back( tofMcTds );
77 }
78 // m_tofMcHitCol->Delete(); // wensp add 2005/12/30
79 delete m_tofMcHitCol;
80 m_tofMcHitCol = 0;
81 return StatusCode::SUCCESS;
82}
void setTrackIndex(unsigned int trackIndex)
void setPositionX(double positionX)
void setIdentifier(unsigned int id)
void setFlightTime(double flightTime)
void setTrackLength(double trackLength)
void setPositionZ(double positionZ)
void setPositionY(double positionY)

◆ TObjectToDataObject() [2/3]

virtual StatusCode TofMcHitCnv::TObjectToDataObject ( DataObject *& obj)
virtual

transformation from root

Implements RootEventBaseCnv.

◆ TObjectToDataObject() [3/3]

virtual StatusCode TofMcHitCnv::TObjectToDataObject ( DataObject *& obj)
virtual

transformation from root

Implements RootEventBaseCnv.

◆ CnvFactory< TofMcHitCnv >

friend class CnvFactory< TofMcHitCnv >
friend

The documentation for this class was generated from the following files: