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

#include <TofMcHitCnv.h>

+ Inheritance diagram for TofMcHitCnv:

Public Member Functions

virtual ~TofMcHitCnv ()
 
- 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.
 
virtual StatusCode DataObjectToTObject (DataObject *dat, RootAddress *addr)=0
 Do the concrete conversion from TDS to ROOT.
 
virtual StatusCode TObjectToDataObject (DataObject *&dat)=0
 Do the concrete conversion from ROOT to TDS.
 
TObject * getReadObject () const
 get the object to be read
 
- Public Member Functions inherited from Converter< Ty1, Ty2 >
destinationoperator (const source &) const
 

Static Public Member Functions

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

Protected Member Functions

 TofMcHitCnv (ISvcLocator *svc)
 
virtual StatusCode DataObjectToTObject (DataObject *obj, RootAddress *addr)
 transformation to root
 
virtual StatusCode TObjectToDataObject (DataObject *&obj)
 transformation from root
 
- Protected Member Functions inherited from Converter< Ty1, Ty2 >
virtual destinationconvert (const source &) const =0
 

Friends

class CnvFactory< TofMcHitCnv >
 

Additional Inherited Members

- Public Types inherited from Converter< Ty1, Ty2 >
typedef Ty1 source
 
typedef Ty2 destination
 
- Protected Attributes inherited from RootEventBaseCnv
RootCnvSvcm_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

Definition at line 19 of file TofMcHitCnv.h.

Constructor & Destructor Documentation

◆ ~TofMcHitCnv()

virtual TofMcHitCnv::~TofMcHitCnv ( )
inlinevirtual

Definition at line 29 of file TofMcHitCnv.h.

29{ };

◆ TofMcHitCnv()

TofMcHitCnv::TofMcHitCnv ( ISvcLocator *  svc)
protected

Definition at line 25 of file TofMcHitCnv.cxx.

27{
28 // Here we associate this converter with the /Event path on the TDS.
29 MsgStream log(msgSvc(), "TofMcHitCnv");
30 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
31 m_rootBranchname ="m_tofMcHitCol";
32 //declareObject(EventModel::MC::TofMcHitCol, objType(), m_rootTreename, m_rootBranchname);
33 m_adresses.push_back(&m_tofMcHitCol);
34 m_tofMcHitCol=0;
35}
IMessageSvc * msgSvc()
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
static const CLID & classID()
Definition: TofMcHitCnv.h:24

Member Function Documentation

◆ classID()

static const CLID & TofMcHitCnv::classID ( )
inlinestatic

Definition at line 24 of file TofMcHitCnv.h.

25 {
26 return CLID_TofMcHitCol;
27 }
const CLID & CLID_TofMcHitCol
Definition: EventModel.cxx:214

◆ DataObjectToTObject()

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

transformation to root

Implements RootEventBaseCnv.

Definition at line 89 of file TofMcHitCnv.cxx.

89 {
90
91 MsgStream log(msgSvc(), "TofMcHitCnv");
92 log << MSG::DEBUG << "TofMcHitCnv::DataObjectToTObject" << endreq;
93 StatusCode sc=StatusCode::SUCCESS;
94
95 TofMcHitCol * tofMcHitCnvTds=dynamic_cast<TofMcHitCol *> (obj);
96 if (!tofMcHitCnvTds) {
97 log << MSG::ERROR << "Could not downcast to TofMcHitCol" << endreq;
98 return StatusCode::FAILURE;
99 }
100
101 DataObject *evt;
102 m_eds->findObject(EventModel::MC::Event,evt);
103 if (evt==NULL) {
104 log << MSG::ERROR << "Could not get McEvent in TDS " << endreq;
105 return StatusCode::FAILURE;
106 }
107 McEvent * devtTds=dynamic_cast<McEvent *> (evt);
108 if (!devtTds) {
109 log << MSG::ERROR << "TofMcHitCnv:Could not downcast to TDS McEvent" << endreq;
110 }
111 IOpaqueAddress *addr;
112
113 m_cnvSvc->getMcCnv()->createRep(evt,addr);
115
116 const TObjArray *m_tofMcHitCol = McEvt->getTofMcHitCol();
117 if (!m_tofMcHitCol) return sc;
118 McEvt->clearTofMcHitCol(); //necessary in case there is I/O at the same time since array is static
119 TofMcHitCol::const_iterator tofMcTds;
120
121 for (tofMcTds = tofMcHitCnvTds->begin(); tofMcTds != tofMcHitCnvTds->end(); tofMcTds++) {
122 UInt_t id = ((*tofMcTds)->identify()).get_value() ;
123 UInt_t trackIndex = (*tofMcTds) ->getTrackIndex();
124 Double_t xPosition = (*tofMcTds) ->getPositionX() ;
125 Double_t yPosition = (*tofMcTds) ->getPositionY() ;
126 Double_t zPosition = (*tofMcTds) ->getPositionZ() ;
127 Double_t px= (*tofMcTds) ->getPx() ;
128 Double_t py = (*tofMcTds) ->getPy() ;
129 Double_t pz = (*tofMcTds) ->getPz() ;
130 Double_t trackLength = (*tofMcTds) ->getTrackLength() ;
131 Double_t flightTime = (*tofMcTds) ->getFlightTime() ;
132
133 TTofMc *tofMcRoot = new TTofMc();
134 //m_common.m_tofMcHitMap[(*tofMcTds)] = tofMcRoot;
135
136 tofMcRoot->setId(id);
137 tofMcRoot->setTrackIndex(trackIndex);
138 tofMcRoot->setPositionX(xPosition);
139 tofMcRoot->setPositionY(yPosition);
140 tofMcRoot->setPositionZ(zPosition);
141 tofMcRoot->setPx(px);
142 tofMcRoot->setPy(py);
143 tofMcRoot->setPz(pz);
144 tofMcRoot->setTrackLength(trackLength);
145 tofMcRoot->setFlightTime(flightTime);
146
147 McEvt->addTofMc(tofMcRoot);
148 }
149
150 return StatusCode::SUCCESS;
151}
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: McCnv.h:35
Definition: McEvent.h:8
McCnv * getMcCnv()
Definition: RootCnvSvc.h:149
RootCnvSvc * m_cnvSvc
IDataProviderSvc * m_eds
pointer to eventdataservice
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void clearTofMcHitCol()
Definition: TMcEvent.h:47
void addTofMc(TTofMc *mcHit)
Tof.
Definition: TMcEvent.cxx:124
const TObjArray * getTofMcHitCol() const
Definition: TMcEvent.h:44
Definition: TTofMc.h:8
void setTrackIndex(UInt_t trackIndex)
Definition: TTofMc.h:47
void setId(UInt_t id)
Definition: TTofMc.h:46
void setPositionY(Double_t positionY)
Definition: TTofMc.h:49
void setTrackLength(Double_t trackLength)
Definition: TTofMc.h:54
void setPz(Double_t pz)
Definition: TTofMc.h:53
void setPy(Double_t py)
Definition: TTofMc.h:52
void setFlightTime(Double_t flightTime)
Definition: TTofMc.h:55
void setPx(Double_t px)
Definition: TTofMc.h:51
void setPositionZ(Double_t positionZ)
Definition: TTofMc.h:50
void setPositionX(Double_t positionX)
Definition: TTofMc.h:48
_EXTERN_ std::string Event
Definition: EventModel.h:39
ObjectVector< TofMcHit > TofMcHitCol
Definition: TofMcHit.h:100

◆ TObjectToDataObject()

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

transformation from root

Implements RootEventBaseCnv.

Definition at line 37 of file TofMcHitCnv.cxx.

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

Friends And Related Function Documentation

◆ CnvFactory< TofMcHitCnv >

friend class CnvFactory< TofMcHitCnv >
friend

Definition at line 9 of file TofMcHitCnv.h.


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