2#define TofMcHitCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
10#include "EventModel/EventModel.h"
11#include "McTruth/McEvent.h"
12#include "McTruth/TofMcHit.h"
13#include "RootEventData/TTofMc.h"
14#include "RootEventData/TMcEvent.h"
15#include "RootCnvSvc/Mc/McCnv.h"
16#include "RootCnvSvc/Mc/TofMcHitCnv.h"
17#include "RootCnvSvc/RootAddress.h"
29 MsgStream log(
msgSvc(),
"TofMcHitCnv");
31 m_rootBranchname =
"m_tofMcHitCol";
33 m_adresses.push_back(&m_tofMcHitCol);
40 MsgStream log(
msgSvc(),
"TofMcHitCnv");
41 log << MSG::DEBUG <<
"TofMcHitCnv::TObjectToDataObject" << endreq;
42 StatusCode sc=StatusCode::SUCCESS;
46 refpObject=tofMcTdsCol;
50 if (!m_tofMcHitCol)
return sc;
51 TIter tofMcIter(m_tofMcHitCol);
53 while ((tofMcRoot = (
TTofMc*)tofMcIter.Next())) {
54 unsigned int id = tofMcRoot ->
getId();
59 double px= tofMcRoot ->
getPx() ;
60 double py = tofMcRoot ->
getPy() ;
61 double pz = tofMcRoot ->
getPz() ;
66 TofMcHit *tofMcTds =
new TofMcHit;
69 tofMcTds->setIdentifier(
id);
70 tofMcTds->setTrackIndex(trackIndex);
71 tofMcTds->setPositionX(xPosition);
72 tofMcTds->setPositionY(yPosition);
73 tofMcTds->setPositionZ(zPosition);
77 tofMcTds->setTrackLength(trackLength);
78 tofMcTds->setFlightTime(flightTime);
81 tofMcTdsCol->push_back(tofMcTds);
86 return StatusCode::SUCCESS;
91 MsgStream log(
msgSvc(),
"TofMcHitCnv");
92 log << MSG::DEBUG <<
"TofMcHitCnv::DataObjectToTObject" << endreq;
93 StatusCode sc=StatusCode::SUCCESS;
96 if (!tofMcHitCnvTds) {
97 log << MSG::ERROR <<
"Could not downcast to TofMcHitCol" << endreq;
98 return StatusCode::FAILURE;
104 log << MSG::ERROR <<
"Could not get McEvent in TDS " << endreq;
105 return StatusCode::FAILURE;
109 log << MSG::ERROR <<
"TofMcHitCnv:Could not downcast to TDS McEvent" << endreq;
111 IOpaqueAddress *addr;
117 if (!m_tofMcHitCol)
return sc;
119 TofMcHitCol::const_iterator tofMcTds;
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() ;
136 tofMcRoot->
setId(
id);
141 tofMcRoot->
setPx(px);
142 tofMcRoot->
setPy(py);
143 tofMcRoot->
setPz(pz);
150 return StatusCode::SUCCESS;
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
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 addTofMc(TTofMc *mcHit)
Tof.
const TObjArray * getTofMcHitCol() const
void setTrackIndex(UInt_t trackIndex)
Double_t getPositionY() const
void setPositionY(Double_t positionY)
Double_t getPositionX() const
void setTrackLength(Double_t trackLength)
UInt_t getTrackIndex() const
void setFlightTime(Double_t flightTime)
void setPositionZ(Double_t positionZ)
Double_t getPositionZ() const
void setPositionX(Double_t positionX)
Double_t getFlightTime() const
Double_t getTrackLength() const
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
TofMcHitCnv(ISvcLocator *svc)
static std::map< const TObject *, const TofMcHit * > m_rootTofMcHitMap
_EXTERN_ std::string Event
ObjectVector< TofMcHit > TofMcHitCol