2#define MucMcHitCnv_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/MucMcHit.h"
13#include "RootEventData/TMucMc.h"
14#include "RootEventData/TMcEvent.h"
15#include "RootCnvSvc/Mc/McCnv.h"
16#include "RootCnvSvc/Mc/MucMcHitCnv.h"
17#include "RootCnvSvc/RootAddress.h"
29 MsgStream log(
msgSvc(),
"MucMcHitCnv");
40 MsgStream log(
msgSvc(),
"MucMcHitCnv");
41 log << MSG::DEBUG <<
"MucMcHitCnv::TObjectToDataObject" << endreq;
42 StatusCode sc=StatusCode::SUCCESS;
45 MucMcHitCol* mucMcTdsCol =
new MucMcHitCol;
46 refpObject=mucMcTdsCol;
50 if (!m_mucMcHitCol)
return sc;
51 TIter mucMcIter(m_mucMcHitCol);
53 while ((mucMcRoot = (
TMucMc*)mucMcIter.Next())) {
54 unsigned int id = mucMcRoot ->
getId();
59 double px= mucMcRoot ->
getPx() ;
60 double py = mucMcRoot ->
getPy() ;
61 double pz = mucMcRoot ->
getPz() ;
63 MucMcHit *mucMcTds =
new MucMcHit;
66 mucMcTds->setIdentifier(
id);
67 mucMcTds->setTrackIndex(trackIndex);
68 mucMcTds->setPositionX(xPosition);
69 mucMcTds->setPositionY(yPosition);
70 mucMcTds->setPositionZ(zPosition);
75 mucMcTdsCol->push_back(mucMcTds);
80 return StatusCode::SUCCESS;
85 MsgStream log(
msgSvc(),
"MucMcHitCnv");
86 log << MSG::DEBUG <<
"MucMcHitCnv::DataObjectToTObject" << endreq;
87 StatusCode sc=StatusCode::SUCCESS;
89 MucMcHitCol * mucMcHitCnvTds=
dynamic_cast<MucMcHitCol *
> (obj);
90 if (!mucMcHitCnvTds) {
91 log << MSG::ERROR <<
"Could not downcast to MucMcHitCol" << endreq;
92 return StatusCode::FAILURE;
98 log << MSG::ERROR <<
"Could not get McEvent in TDS " << endreq;
99 return StatusCode::FAILURE;
103 log << MSG::ERROR <<
"MucMcHitCnv:Could not downcast to TDS McEvent" << endreq;
105 IOpaqueAddress *addr;
111 if (!m_mucMcHitCol)
return sc;
113 MucMcHitCol::const_iterator mucMcTds;
115 for (mucMcTds = mucMcHitCnvTds->begin(); mucMcTds != mucMcHitCnvTds->end(); mucMcTds++) {
116 UInt_t
id = ((*mucMcTds)->identify()).get_value() ;
117 UInt_t trackIndex = (*mucMcTds) ->getTrackIndex();
118 Double_t xPosition = (*mucMcTds) ->getPositionX() ;
119 Double_t yPosition = (*mucMcTds) ->getPositionY() ;
120 Double_t zPosition = (*mucMcTds) ->getPositionZ() ;
121 Double_t px= (*mucMcTds) ->getPx() ;
122 Double_t py = (*mucMcTds) ->getPy() ;
123 Double_t pz = (*mucMcTds) ->getPz() ;
128 mucMcRoot->
setId(
id);
133 mucMcRoot->
setPx(px);
134 mucMcRoot->
setPy(py);
135 mucMcRoot->
setPz(pz);
140 return StatusCode::SUCCESS;
static TMcEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
MucMcHitCnv(ISvcLocator *svc)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
Definition of a Root address, derived from IOpaqueAddress.
Base class for all Root Converters.
IDataProviderSvc * m_eds
pointer to eventdataservice
std::vector< void * > m_adresses
each converter knows the corresponding adresses
std::string m_rootBranchname
root branchname (may be concatenated of severals)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
void addMucMc(TMucMc *mcHit)
Muc.
const TObjArray * getMucMcHitCol() const
UInt_t getTrackIndex() const
void setPositionX(Double_t positionX)
Double_t getPositionY() const
Double_t getPositionZ() const
void setTrackIndex(UInt_t trackIndex)
void setPositionY(Double_t positionY)
void setPositionZ(Double_t positionZ)
Double_t getPositionX() const
static std::map< const TObject *, const MucMcHit * > m_rootMucMcHitMap
_EXTERN_ std::string Event