2#define MdcMcHitCnv_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/MdcMcHit.h"
13#include "RootEventData/TMdcMc.h"
14#include "RootEventData/TMcEvent.h"
15#include "RootCnvSvc/Mc/McCnv.h"
16#include "RootCnvSvc/Mc/MdcMcHitCnv.h"
17#include "RootCnvSvc/RootAddress.h"
29 MsgStream log(
msgSvc(),
"MdcMcHitCnv");
31 m_rootBranchname =
"m_mdcMcHitCol";
33 m_adresses.push_back(&m_mdcMcHitCol);
40 MsgStream log(
msgSvc(),
"MdcMcHitCnv");
41 log << MSG::DEBUG <<
"MdcMcHitCnv::TObjectToDataObject" << endreq;
42 StatusCode sc=StatusCode::SUCCESS;
46 refpObject=mdcMcTdsCol;
50 if (!m_mdcMcHitCol)
return sc;
51 TIter mdcMcIter(m_mdcMcHitCol);
53 while ((mdcMcRoot = (
TMdcMc*)mdcMcIter.Next())) {
54 unsigned int id = mdcMcRoot ->
getId();
63 MdcMcHit *mdcMcTds =
new MdcMcHit;
66 mdcMcTds->setIdentifier(
id);
67 mdcMcTds->setTrackIndex(trackIndex);
68 mdcMcTds->setPositionX(xPosition);
69 mdcMcTds->setPositionY(yPosition);
70 mdcMcTds->setPositionZ(zPosition);
71 mdcMcTds->setDriftDistance(driftDistance);
72 mdcMcTds->setDepositEnergy(depositEnergy);
73 mdcMcTds->setPositionFlag(positionFlag);
75 mdcMcTdsCol->push_back(mdcMcTds);
80 return StatusCode::SUCCESS;
85 MsgStream log(
msgSvc(),
"MdcMcHitCnv");
86 log << MSG::DEBUG <<
"MdcMcHitCnv::DataObjectToTObject" << endreq;
87 StatusCode sc=StatusCode::SUCCESS;
90 if (!mdcMcHitCnvTds) {
91 log << MSG::ERROR <<
"Could not downcast to MdcMcHitCol" << endreq;
92 return StatusCode::FAILURE;
98 log << MSG::ERROR <<
"Could not get McEvent in TDS " << endreq;
99 return StatusCode::FAILURE;
103 log << MSG::ERROR <<
"MdcMcHitCnv:Could not downcast to TDS McEvent" << endreq;
105 IOpaqueAddress *addr;
111 if (!m_mdcMcHitCol)
return sc;
113 MdcMcHitCol::const_iterator mdcMcTds;
115 for (mdcMcTds = mdcMcHitCnvTds->begin(); mdcMcTds != mdcMcHitCnvTds->end(); mdcMcTds++) {
116 UInt_t
id = ((*mdcMcTds)->identify()).get_value() ;
117 UInt_t trackIndex = (*mdcMcTds) ->getTrackIndex();
118 Double_t xPosition = (*mdcMcTds) ->getPositionX() ;
119 Double_t yPosition = (*mdcMcTds) ->getPositionY() ;
120 Double_t zPosition = (*mdcMcTds) ->getPositionZ() ;
121 Double_t driftDistance= (*mdcMcTds) ->getDriftDistance();
122 Double_t depositEnergy = (*mdcMcTds) ->getDepositEnergy() ;
123 Int_t positionFlag = (*mdcMcTds) ->getPositionFlag();
128 mdcMcRoot->
setId(
id);
140 return StatusCode::SUCCESS;
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
MdcMcHitCnv(ISvcLocator *svc)
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 addMdcMc(TMdcMc *mcHit)
Mdc.
const TObjArray * getMdcMcHitCol() const
Double_t getDepositEnergy() const
Double_t getPositionZ() const
void setPositionZ(Double_t positionZ)
Double_t getDriftDistance() const
void setTrackIndex(UInt_t trackIndex)
UInt_t getTrackIndex() const
void setDepositEnergy(Double_t depositEnergy)
Int_t getPositionFlag() const
Double_t getPositionX() const
void setPositionX(Double_t positionX)
void setPositionFlag(Int_t posFlag)
Double_t getPositionY() const
void setPositionY(Double_t positionY)
void setDriftDistance(Double_t driftDistance)
static std::map< const TObject *, const MdcMcHit * > m_rootMdcMcHitMap
_EXTERN_ std::string Event
ObjectVector< MdcMcHit > MdcMcHitCol