1#ifndef RecMdcDedxHitCnv_CXX
2#define RecMdcDedxHitCnv_CXX 1
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/DataObject.h"
5#include "GaudiKernel/ObjectVector.h"
6#include "TClonesArray.h"
7#include "EventModel/EventModel.h"
8#include "ReconEvent/ReconEvent.h"
9#include "MdcRecEvent/RecMdcDedxHit.h"
10#include "Identifier/Identifier.h"
12#include "RootEventData/TRecMdcDedxHit.h"
13#include "RootEventData/TRecTrackEvent.h"
15#include "RootCnvSvc/Rec/RecTrackCnv.h"
16#include "RootCnvSvc/Rec/RecMdcDedxHitCnv.h"
17#include "RootCnvSvc/RootAddress.h"
33 MsgStream log(
msgSvc(),
"RecMdcDedxHitCnv");
44 MsgStream log(
msgSvc(),
"RecMdcDedxHitCnv");
45 log << MSG::DEBUG <<
"RecMdcDedxHitCnv::TObjectToDataObject" << endreq;
46 StatusCode sc=StatusCode::SUCCESS;
49 refpObject=recMdcDedxHitCol;
52 IDataProviderSvc* dataSvc = 0;
53 sc = serviceLocator()->getService(
"EventDataSvc",
54 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
55 if ( sc.isFailure() ) {
56 log << MSG::FATAL <<
"Could not get EventDataSvc in RecMdcDedxHitCnv" << endreq;
64 log << MSG::INFO <<
"Could not find RecMdcHitCol" << endreq;
69 if (!mdcKalHelixSegCol) {
70 log << MSG::INFO <<
"Could not find RecMdcKalHelixSegCol" << endreq;
76 if (!m_recMdcDedxHitCol)
return sc;
77 TIter dedxIter(m_recMdcDedxHitCol);
80 int trackId = recMdcDedxHitRoot->
trkId();
82 int flagLR = recMdcDedxHitRoot->
flagLR();
84 long int mdcId(recMdcDedxHitRoot->
mdcId());
86 double pathlength = recMdcDedxHitRoot->
pathLength();
88 double dedx = recMdcDedxHitRoot->
getDedx();
91 log << MSG::DEBUG<<
"TObjectToDataObject: check Reconstrunction of dE/dx Hit root::"<<
" trackId: "<<trackId<<
" flagLR: "<<flagLR<<
" pathlength: "<<pathlength<<
" dedx: "<<dedx<<endreq;
101 int mdcHitId = recMdcDedxHitRoot->
mdcHitId();
103 if ( mdcHitId >= 0 ) {
104 recMdcDedxHit->
setMdcHit(
dynamic_cast<RecMdcHit*
>(mdcHitCol->containedObject(mdcHitId)));
108 if ( mdcKalHelixSegId >= 0 ) {
112 recMdcDedxHitCol->push_back(recMdcDedxHit);
117 delete m_recMdcDedxHitCol;
118 m_recMdcDedxHitCol = 0;
120 return StatusCode::SUCCESS;
125 MsgStream log(
msgSvc(),
"RecMdcDedxHitCnv");
126 log << MSG::DEBUG <<
"RecMdcDedxHitCnv::DataObjectToTObject" << endreq;
127 StatusCode sc=StatusCode::SUCCESS;
130 if (!recMdcDedxHitCol) {
131 log << MSG::ERROR <<
"Could not downcast to RecMdcDedxHitCol" << endreq;
132 return StatusCode::FAILURE;
138 log << MSG::ERROR <<
"Could not get RecEvent in TDS " << endreq;
139 return StatusCode::FAILURE;
143 log << MSG::ERROR <<
"RecMdcDedxHitCnv:Could not downcast to TDS RecEvent" << endreq;
145 IOpaqueAddress *addr;
149 if (!m_recMdcDedxHitCol)
return sc;
154 RecMdcHitCol::iterator recMdcHitColbegin, recMdcHitColend;
155 RecMdcKalHelixSegCol::iterator recMdcKalHelixSegColbegin, recMdcKalHelixSegColend;
157 IDataProviderSvc* dataSvc = 0;
158 sc = serviceLocator()->getService(
"EventDataSvc",
159 IDataProviderSvc::interfaceID(), (IInterface*&)dataSvc);
160 if ( sc.isFailure() ) {
161 log << MSG::FATAL <<
"Could not get EventDataSvc in RecMdcDedxHitCnv" << endreq;
168 log << MSG::ERROR <<
"Could not downcast to RecMdcHitCol" << endreq;
169 return StatusCode::FAILURE;
172 recMdcHitColbegin = recMdcHitCol->begin();
173 recMdcHitColend = recMdcHitCol->end();
177 if (!recMdcKalHelixSegCol) {
178 log << MSG::ERROR <<
"Could not downcast to RecMdcKalHelixSegCol" << endreq;
179 return StatusCode::FAILURE;
182 recMdcKalHelixSegColbegin = recMdcKalHelixSegCol->begin();
183 recMdcKalHelixSegColend = recMdcKalHelixSegCol->end();
188 RecMdcDedxHitCol::const_iterator recMdcDedxHit;
189 for (recMdcDedxHit = recMdcDedxHitCol->begin(); recMdcDedxHit != recMdcDedxHitCol->end(); recMdcDedxHit++) {
190 int trackId = (*recMdcDedxHit)->getTrkId();
191 int flagLR = (*recMdcDedxHit)->getFlagLR();
192 UInt_t mdcId =(*recMdcDedxHit)->getMdcId().get_value();
193 double pathlength = (*recMdcDedxHit)->getPathLength();
194 double dedx = (*recMdcDedxHit)->getDedx();
196 log << MSG::DEBUG<<
"DataObjectToTObject: check Reconstrunction of dE/dx Hit::"<<
" trackId: "<<trackId<<
" flagLR: "<<flagLR<<
" pathlength: "<<pathlength<<
" dedx: "<<dedx<<endreq;
199 recMdcDedxHitRoot->
setTrkId(trackId);
201 recMdcDedxHitRoot->
setMdcId( mdcId );
203 recMdcDedxHitRoot->
setDedx(dedx);
217 if ( (*recMdcDedxHit)->isMdcHitValid() ) {
218 RecMdcHitCol::iterator it = find(recMdcHitColbegin, recMdcHitColend, (*recMdcDedxHit)->getMdcHit());
219 recMdcDedxHitRoot->
setMdcHitId( it - recMdcHitColbegin );
225 if ( (*recMdcDedxHit)->isMdcKalHelixSegValid() ) {
226 RecMdcKalHelixSegCol::iterator it = find(recMdcKalHelixSegColbegin, recMdcKalHelixSegColend, (*recMdcDedxHit)->getMdcKalHelixSeg());
237 return StatusCode::SUCCESS;
ObjectVector< RecMdcDedxHit > RecMdcDedxHitCol
RecMdcDedxHitCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
void setMdcId(Identifier mdcid)
void setDedx(double dedx)
void setMdcKalHelixSeg(const RecMdcKalHelixSeg *mdcKalHelixSeg)
void setMdcHit(const RecMdcHit *mdcHit)
void setPathLength(double pathlength)
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
RecTrackCnv * getRecTrackCnv()
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.
const Double_t getDedx(void) const
void setDedx(double dedx)
void setMdcId(UInt_t mdcid)
const Int_t mdcKalHelixSegId()
const Int_t trkId(void) const
void setMdcHitId(const int mdcHitId)
const Int_t flagLR(void) const
void setMdcKalHelixSegId(const int mdcKalHelixSegId)
void setTrkId(Int_t trkid)
const Double_t pathLength(void) const
const UInt_t mdcId() const
void setPathLength(double pathlength)
const TObjArray * getRecMdcDedxHitCol() const
retrieve the whole TObjArray of Dedx Data
void clearRecMdcDedxHitCol()
clear the whole array
void addRecMdcDedxHit(TRecMdcDedxHit *Track)
Add a Dedx into the TOF Data collection.
static std::map< const TObject *, const RecMdcDedxHit * > m_rootRecMdcDedxHitMap
_EXTERN_ std::string RecMdcKalHelixSegCol
_EXTERN_ std::string Event
_EXTERN_ std::string RecMdcHitCol