2#define ExtTrackCnv_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"
12#include "DstEvent/DstEvent.h"
13#include "DstEvent/DstExtTrack.h"
15#include "RootEventData/TExtTrack.h"
16#include "RootEventData/TDstEvent.h"
18#include "RootCnvSvc/Dst/DstCnv.h"
19#include "RootCnvSvc/Dst/ExtTrackCnv.h"
20#include "RootCnvSvc/RootAddress.h"
22#include "CLHEP/Matrix/Vector.h"
23#include "CLHEP/Matrix/SymMatrix.h"
24#include "CLHEP/Vector/ThreeVector.h"
30using CLHEP::Hep3Vector;
31using CLHEP::HepSymMatrix;
42 MsgStream log(
msgSvc(),
"ExtTrackCnv");
53 MsgStream log(
msgSvc(),
"ExtTrackCnv");
54 log << MSG::DEBUG <<
"ExtTrackCnv::TObjectToDataObject" << endreq;
55 StatusCode sc=StatusCode::SUCCESS;
59 refpObject=extTrackTdsCol;
63 if (!m_extTrackCol)
return sc;
64 TIter extTrackIter(m_extTrackCol);
66 while ((extTrackRoot = (
TExtTrack*)extTrackIter.Next())) {
76 Hep3Vector tof1p(p1x,p1y,p1z);
77 Hep3Vector tof1m(m1x,m1y,m1z);
82 double tof1= extTrackRoot->
GetTof1();
89 for (
int i = 0;i<6 ;i++ )
90 for (
int j= 0;j<6 ;j++ )
100 Hep3Vector tof2p(p2x,p2y,p2z);
101 Hep3Vector tof2m(m2x,m2y,m2z);
105 double tof2= extTrackRoot->
GetTof2();
111 HepSymMatrix e2m(6) ;
112 for (
int i = 0;i<6 ;i++ )
113 for (
int j= 0;j<6 ;j++ )
123 Hep3Vector Ep(pEx,pEy,pEz);
124 Hep3Vector Em(mEx,mEy,mEz);
130 HepSymMatrix eEm(6) ;
131 for(
int i=0;i<6 ;i++ )
132 for(
int j= 0;j<6 ;j++ )
134 double emcPath=extTrackRoot->
emcPath();
143 Hep3Vector Mp(pMx,pMy,pMz);
144 Hep3Vector Mm(mMx,mMy,mMz);
153 HepSymMatrix eMm(6) ;
154 for (
int i = 0;i<6 ;i++ )
155 for (
int j= 0;j<6 ;j++ )
200 extTrackTds->
SetTof1Data( tof1p, tof1m, v1s, v1n , tof1, tof1path, e1m, z1, t1, x1, y1 );
201 extTrackTds->
SetTof2Data( tof2p, tof2m, v2s, v2n , tof2, tof2path, e2m, z2, t2, x2, y2 );
202 extTrackTds->
SetEmcData( Ep, Em, vEs, vEn , theta, phi , eEm);
204 extTrackTds->
SetMucData( Mp, Mm, vMs, vMn , eMm, zM, tM, xM, yM );
206 extTrackTdsCol->push_back(extTrackTds);
213 delete m_extTrackCol;
215 return StatusCode::SUCCESS;
220 MsgStream log(
msgSvc(),
"ExtTrackCnv");
221 log << MSG::DEBUG <<
"ExtTrackCnv::DataObjectToTObject" << endreq;
222 StatusCode sc=StatusCode::SUCCESS;
225 if (!extTrackColTds) {
226 log << MSG::ERROR <<
"Could not downcast to DstExtTrackCol" << endreq;
227 return StatusCode::FAILURE;
233 log << MSG::ERROR <<
"Could not get ReconEvent in TDS " << endreq;
234 return StatusCode::FAILURE;
239 log << MSG::ERROR <<
"ExtTrackCnv:Could not downcast to TDS Dst Event" << endreq;
241 IOpaqueAddress *addr;
248 if (!m_extTrackCol)
return sc;
251 DstExtTrackCol::const_iterator extTrackTds;
253 for (extTrackTds = extTrackColTds->begin(); extTrackTds != extTrackColTds->end(); extTrackTds++) {
255 Int_t trackId = (*extTrackTds)->GetTrackId();
257 Double_t p1x = (*extTrackTds)->tof1Position().x();
258 Double_t p1y = (*extTrackTds)->tof1Position().y();
259 Double_t p1z = (*extTrackTds)->tof1Position().z();
260 Double_t m1x = (*extTrackTds)->tof1Momentum().x();
261 Double_t m1y = (*extTrackTds)->tof1Momentum().y();
262 Double_t m1z = (*extTrackTds)->tof1Momentum().z();
264 TString v1s = (*extTrackTds)->tof1VolumeName() ;
265 Int_t v1n = (*extTrackTds)->tof1VolumeNumber() ;
266 Double_t tof1= (*extTrackTds)->tof1();
267 Double_t tof1p = (*extTrackTds)->tof1Path();
268 Double_t z1 = (*extTrackTds)->tof1PosSigmaAlongZ();
269 Double_t t1 = (*extTrackTds)->tof1PosSigmaAlongT();
270 Double_t x1 = (*extTrackTds)->tof1PosSigmaAlongX();
271 Double_t y1 = (*extTrackTds)->tof1PosSigmaAlongY();
273 HepSymMatrix e1mTds = (*extTrackTds)->tof1ErrorMatrix();
274 for (
int i = 0;i<6 ;i++ )
275 for (
int j= 0;j<6 ;j++ )
276 e1m[i][j] = e1mTds[i][j];
279 Double_t p2x = (*extTrackTds)->tof2Position().x();
280 Double_t p2y = (*extTrackTds)->tof2Position().y();
281 Double_t p2z = (*extTrackTds)->tof2Position().z();
282 Double_t m2x = (*extTrackTds)->tof2Momentum().x();
283 Double_t m2y = (*extTrackTds)->tof2Momentum().y();
284 Double_t m2z = (*extTrackTds)->tof2Momentum().z();
286 TString v2s = (*extTrackTds)->tof2VolumeName() ;
287 Int_t v2n = (*extTrackTds)->tof2VolumeNumber() ;
288 Double_t tof2= (*extTrackTds)->tof2();
289 Double_t tof2p = (*extTrackTds)->tof2Path();
290 Double_t z2 = (*extTrackTds)->tof2PosSigmaAlongZ();
291 Double_t t2 = (*extTrackTds)->tof2PosSigmaAlongT();
292 Double_t x2 = (*extTrackTds)->tof2PosSigmaAlongX();
293 Double_t y2 = (*extTrackTds)->tof2PosSigmaAlongY();
295 HepSymMatrix e2mTds = (*extTrackTds)->tof2ErrorMatrix();
296 for (
int i = 0;i<6 ;i++ )
297 for (
int j= 0;j<6 ;j++ )
298 e2m[i][j] = e2mTds[i][j];
300 Double_t pEx = (*extTrackTds)->emcPosition().x();
301 Double_t pEy = (*extTrackTds)->emcPosition().y();
302 Double_t pEz = (*extTrackTds)->emcPosition().z();
303 Double_t mEx = (*extTrackTds)->emcMomentum().x();
304 Double_t mEy = (*extTrackTds)->emcMomentum().y();
305 Double_t mEz = (*extTrackTds)->emcMomentum().z();
307 TString vEs = (*extTrackTds)->emcVolumeName() ;
308 Int_t vEn = (*extTrackTds)->emcVolumeNumber() ;
310 Double_t theta = (*extTrackTds)->emcPosSigmaAlongTheta();
311 Double_t phi = (*extTrackTds)->emcPosSigmaAlongPhi();
314 HepSymMatrix eEmTds = (*extTrackTds)->emcErrorMatrix();
315 for (
int i = 0;i<6 ;i++ )
316 for (
int j= 0;j<6 ;j++ )
317 eEm[i][j] = eEmTds[i][j];
318 Double_t emcPath=(*extTrackTds)->emcPath();
321 Double_t pMx = (*extTrackTds)->mucPosition().x();
322 Double_t pMy = (*extTrackTds)->mucPosition().y();
323 Double_t pMz = (*extTrackTds)->mucPosition().z();
324 Double_t mMx = (*extTrackTds)->mucMomentum().x();
325 Double_t mMy = (*extTrackTds)->mucMomentum().y();
326 Double_t mMz = (*extTrackTds)->mucMomentum().z();
328 TString vMs = (*extTrackTds)->mucVolumeName() ;
329 Int_t vMn = (*extTrackTds)->mucVolumeNumber() ;
331 Double_t zM = (*extTrackTds)->mucPosSigmaAlongZ();
332 Double_t tM = (*extTrackTds)->mucPosSigmaAlongT();
333 Double_t xM = (*extTrackTds)->mucPosSigmaAlongX();
334 Double_t yM = (*extTrackTds)->mucPosSigmaAlongY();
337 HepSymMatrix eMmTds = (*extTrackTds)->mucErrorMatrix();
338 for (
int i = 0;i<6 ;i++ )
339 for (
int j= 0;j<6 ;j++ )
340 eMm[i][j]= eMmTds[i][j];
453 return StatusCode::SUCCESS;
ObjectVector< DstExtTrack > DstExtTrackCol
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
void SetTof1Data(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, double aTof, double aPath, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
void SetTrackId(int trackId)
void SetEmcData(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, double aThetaSigma, double aPhiSigma, HepSymMatrix aErrorMatrix)
void SetTof2Data(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, double aTof, double aPath, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
void SetMucData(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
void SetEmcPath(double path)
ExtTrackCnv(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 addExtTrack(TExtTrack *Track)
Add a ExtTrack into the Ext Data collection.
void clearExtTrackCol()
clear the whole array
const TObjArray * getExtTrackCol() const
retrieve the whole TObjArray of Ext Data
Double_t GetTof1PosSigmaAlongZ() const
void SetTof2MomentumY(const Double_t Tof2MomentumY)
Double_t GetMucPositionX() const
Double_t GetMucPosSigmaAlongT() const
Double_t GetMucPositionY() const
void SetTof2(const Double_t Tof2)
Double_t GetTof1Path() const
Double_t GetTof1PosSigmaAlongY() const
void SetTof1PosSigmaAlongZ(const Double_t Tof1PosSigmaAlongZ)
void SetTof1PosSigmaAlongX(const Double_t Tof1PosSigmaAlongX)
Double_t GetEmcPositionX() const
void SetTof2MomentumX(const Double_t Tof2MomentumX)
Double_t GetEmcPositionZ() const
void SetEmcMomentumY(const Double_t EmcMomentumY)
Double_t GetMucPosSigmaAlongZ() const
void SetMucMomentumY(const Double_t MucMomentumY)
void SetMucVolumeName(const TString MucVolumeName)
void SetTof1MomentumX(const Double_t Tof1MomentumX)
Int_t GetTof1VolumeNumber() const
void SetEmcVolumeNumber(const Int_t EmcVolumeNumber)
Int_t GetMucVolumeNumber() const
void SetTof1VolumeNumber(const Int_t Tof1VolumeNumber)
void SetTof1PositionY(const Double_t Tof1PositionY)
Int_t GetEmcVolumeNumber() const
Double_t GetTof2PositionZ() const
Double_t GetEmcMomentumX() const
void SetTof1PosSigmaAlongY(const Double_t Tof1PosSigmaAlongY)
Double_t GetTof2MomentumY() const
Double_t GetTof2PosSigmaAlongT() const
Double_t GetMucMomentumZ() const
void SetEmcErrorMatrix(const Double_t EmcErrorMatrix[6][6])
Double_t GetTof2PosSigmaAlongZ() const
void SetEmcPositionX(const Double_t EmcPositionX)
void SetMucVolumeNumber(const Int_t MucVolumeNumber)
void SetMucErrorMatrix(const Double_t MucErrorMatrix[6][6])
void SetTof1PosSigmaAlongT(const Double_t Tof1PosSigmaAlongT)
void SetMucPosSigmaAlongX(const Double_t MucPosSigmaAlongX)
Int_t GetTof2VolumeNumber() const
void SetEmcMomentumZ(const Double_t EmcMomentumZ)
void SetTof1Path(const Double_t Tof1Path)
void SetEmcMomentumX(const Double_t EmcMomentumX)
Double_t GetTof1PositionY() const
void SetTof2VolumeName(const TString Tof2VolumeName)
void SetTof1(const Double_t Tof1)
void SetTof2PosSigmaAlongY(const Double_t Tof2PosSigmaAlongY)
void SetMucPosSigmaAlongY(const Double_t MucPosSigmaAlongY)
void SetTof2ErrorMatrix(const Double_t Tof2ErrorMatrix[6][6])
void SetMucPositionX(const Double_t MucPositionX)
Double_t GetEmcMomentumY() const
Double_t GetTof1MomentumX() const
Double_t GetTof2Path() const
Double_t GetEmcPositionY() const
Double_t GetEmcPosSigmaAlongPhi() const
TString GetTof1VolumeName() const
void SetTof2Path(const Double_t Tof2Path)
void SetTof2PosSigmaAlongZ(const Double_t Tof2PosSigmaAlongZ)
void SetMucPosSigmaAlongT(const Double_t MucPosSigmaAlongT)
void SetMucMomentumZ(const Double_t MucMomentumZ)
Double_t GetMucMomentumX() const
Double_t GetEmcErrorMatrix(Int_t i, Int_t j) const
Double_t GetTof1ErrorMatrix(Int_t i, Int_t j) const
Double_t GetTof2PosSigmaAlongX() const
void SetTof1PositionZ(const Double_t Tof1PositionZ)
void SetMucPosSigmaAlongZ(const Double_t MucPosSigmaAlongZ)
Double_t GetEmcMomentumZ() const
void SetTof2PosSigmaAlongX(const Double_t Tof2PosSigmaAlongX)
Double_t GetTof2MomentumX() const
void SetTrackId(const Int_t trackId)
Double_t GetEmcPosSigmaAlongTheta() const
Double_t GetTof2PositionY() const
TString GetTof2VolumeName() const
Double_t GetTof1PosSigmaAlongX() const
void SetEmcPositionZ(const Double_t EmcPositionZ)
Double_t GetMucPosSigmaAlongX() const
void SetTof2PositionZ(const Double_t Tof2PositionZ)
void SetTof1PositionX(const Double_t Tof1PositionX)
void SetTof2PosSigmaAlongT(const Double_t Tof2PosSigmaAlongT)
Double_t GetMucMomentumY() const
Double_t GetTof2MomentumZ() const
void SetTof2VolumeNumber(const Int_t Tof2VolumeNumber)
void SetEmcVolumeName(const TString EmcVolumeName)
TString GetEmcVolumeName() const
void SetTof1MomentumY(const Double_t Tof1MomentumY)
void SetTof2PositionY(const Double_t Tof2PositionY)
void SetMucMomentumX(const Double_t MucMomentumX)
void SetMucPositionZ(const Double_t MucPositionZ)
Double_t GetTof2ErrorMatrix(Int_t i, Int_t j) const
void SetEmcPath(Double_t path)
Double_t GetMucErrorMatrix(Int_t i, Int_t j) const
TString GetMucVolumeName() const
Double_t GetTof1MomentumZ() const
Double_t GetTof2PositionX() const
void SetTof1ErrorMatrix(const Double_t Tof1ErrorMatrix[6][6])
void SetTof2MomentumZ(const Double_t Tof2MomentumZ)
Double_t GetTof1PosSigmaAlongT() const
Double_t GetTof1MomentumY() const
void SetTof1MomentumZ(const Double_t Tof1MomentumZ)
Double_t GetMucPosSigmaAlongY() const
void SetEmcPosSigmaAlongTheta(const Double_t EmcPosSigmaAlongTheta)
void SetTof2PositionX(const Double_t Tof2PositionX)
void SetTof1VolumeName(const TString Tof1VolumeName)
Double_t GetTof1PositionX() const
Double_t GetTof1PositionZ() const
void SetEmcPositionY(const Double_t EmcPositionY)
void SetMucPositionY(const Double_t MucPositionY)
void SetEmcPosSigmaAlongPhi(const Double_t EmcPosSigmaAlongPhi)
Double_t GetTof2PosSigmaAlongY() const
Double_t GetMucPositionZ() const
static std::map< const TObject *, const DstExtTrack * > m_rootExtTrackMap
_EXTERN_ std::string Event