1#ifndef RecExtTrackCnv_CXX
2#define RecExtTrackCnv_CXX 1
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
8#include "TClonesArray.h"
38 MsgStream log(
msgSvc(),
"RecExtTrackCnv");
50 MsgStream log(
msgSvc(),
"RecExtTrackCnv");
51 log << MSG::DEBUG <<
"RecExtTrackCnv::TObjectToDataObject" << endreq;
52 StatusCode sc=StatusCode::SUCCESS;
56 refpObject=extTrackTdsCol;
60 if (!m_extTrackCol)
return sc;
61 TIter extTrackIter(m_extTrackCol);
63 while ((extTrackRoot = (
TRecExtTrack*)extTrackIter.Next())) {
69 for(
int iPart=0; iPart<5; iPart++) {
78 Hep3Vector tof1p(p1x,p1y,p1z);
79 Hep3Vector tof1m(m1x,m1y,m1z);
84 double tof1= extTrackRoot->
GetTof1(iPart);
91 for (
int i = 0;i<6 ;i++ )
92 for (
int j= 0;j<6 ;j++ )
102 Hep3Vector tof2p(p2x,p2y,p2z);
103 Hep3Vector tof2m(m2x,m2y,m2z);
107 double tof2= extTrackRoot->
GetTof2(iPart);
108 double tof2path = extTrackRoot->
GetTof2Path(iPart);
113 HepSymMatrix e2m(6) ;
114 for (
int i = 0;i<6 ;i++ )
115 for (
int j= 0;j<6 ;j++ )
125 Hep3Vector Ep(pEx,pEy,pEz);
126 Hep3Vector Em(mEx,mEy,mEz);
132 HepSymMatrix eEm(6) ;
133 for(
int i=0;i<6 ;i++ )
134 for(
int j= 0;j<6 ;j++ )
136 double emcPath=extTrackRoot->
emcPath(iPart);
145 Hep3Vector Mp(pMx,pMy,pMz);
146 Hep3Vector Mm(mMx,mMy,mMz);
155 HepSymMatrix eMm(6) ;
156 for (
int i = 0;i<6 ;i++ )
157 for (
int j= 0;j<6 ;j++ )
162 int size = extTrackRoot->
GetSize(iPart);
172 HepSymMatrix matrix(6);
174 for(
int i =0;i<size;i++){
178 Hep3Vector p(px,py,pz);
182 Hep3Vector m(mx,my,mz);
189 std::vector<double> vecError = extTrackRoot->
GetErrorMatrix(i,iPart);
190 for(
int k =0;k<6;k++){
191 for(
int j =0; j<6;j++){
192 matrix[k][j] = vecError[k*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);
215 delete m_extTrackCol;
219 return StatusCode::SUCCESS;
226 MsgStream log(
msgSvc(),
"RecExtTrackCnv");
227 log << MSG::DEBUG <<
"RecExtTrackCnv::DataObjectToTObject" << endreq;
228 StatusCode sc=StatusCode::SUCCESS;
231 if (!extTrackColTds) {
232 log << MSG::ERROR <<
"Could not downcast to RecExtTrackCol" << endreq;
233 return StatusCode::FAILURE;
239 log << MSG::ERROR <<
"Could not get ReconEvent in TDS " << endreq;
240 return StatusCode::FAILURE;
245 log << MSG::ERROR <<
"RecExtTrackCnv:Could not downcast to TDS Rec Event" << endreq;
247 IOpaqueAddress *addr;
254 if (!m_extTrackCol)
return sc;
257 RecExtTrackCol::const_iterator extTrackTds;
259 for (extTrackTds = extTrackColTds->begin(); extTrackTds != extTrackColTds->end(); extTrackTds++) {
261 Int_t trackId = (*extTrackTds)->GetTrackId();
265 for(
int iPart=0; iPart<5; iPart++) {
267 Double_t p1x = (*extTrackTds)->tof1Position(iPart).x();
268 Double_t p1y = (*extTrackTds)->tof1Position(iPart).y();
269 Double_t p1z = (*extTrackTds)->tof1Position(iPart).z();
270 Double_t m1x = (*extTrackTds)->tof1Momentum(iPart).x();
271 Double_t m1y = (*extTrackTds)->tof1Momentum(iPart).y();
272 Double_t m1z = (*extTrackTds)->tof1Momentum(iPart).z();
274 TString v1s = (*extTrackTds)->tof1VolumeName(iPart) ;
275 Int_t v1n = (*extTrackTds)->tof1VolumeNumber(iPart) ;
276 Double_t tof1= (*extTrackTds)->tof1(iPart);
277 Double_t tof1p = (*extTrackTds)->tof1Path(iPart);
278 Double_t z1 = (*extTrackTds)->tof1PosSigmaAlongZ(iPart);
279 Double_t t1 = (*extTrackTds)->tof1PosSigmaAlongT(iPart);
280 Double_t x1 = (*extTrackTds)->tof1PosSigmaAlongX(iPart);
281 Double_t y1 = (*extTrackTds)->tof1PosSigmaAlongY(iPart);
283 HepSymMatrix e1mTds = (*extTrackTds)->tof1ErrorMatrix(iPart);
284 for (
int i = 0;i<6 ;i++ )
285 for (
int j= 0;j<6 ;j++ )
286 e1m[i][j] = e1mTds[i][j];
289 Double_t p2x = (*extTrackTds)->tof2Position(iPart).x();
290 Double_t p2y = (*extTrackTds)->tof2Position(iPart).y();
291 Double_t p2z = (*extTrackTds)->tof2Position(iPart).z();
292 Double_t m2x = (*extTrackTds)->tof2Momentum(iPart).x();
293 Double_t m2y = (*extTrackTds)->tof2Momentum(iPart).y();
294 Double_t m2z = (*extTrackTds)->tof2Momentum(iPart).z();
296 TString v2s = (*extTrackTds)->tof2VolumeName(iPart) ;
297 Int_t v2n = (*extTrackTds)->tof2VolumeNumber(iPart) ;
298 Double_t tof2= (*extTrackTds)->tof2(iPart);
299 Double_t tof2p = (*extTrackTds)->tof2Path(iPart);
300 Double_t z2 = (*extTrackTds)->tof2PosSigmaAlongZ(iPart);
301 Double_t t2 = (*extTrackTds)->tof2PosSigmaAlongT(iPart);
302 Double_t x2 = (*extTrackTds)->tof2PosSigmaAlongX(iPart);
303 Double_t y2 = (*extTrackTds)->tof2PosSigmaAlongY(iPart);
305 HepSymMatrix e2mTds = (*extTrackTds)->tof2ErrorMatrix(iPart);
306 for (
int i = 0;i<6 ;i++ )
307 for (
int j= 0;j<6 ;j++ )
308 e2m[i][j] = e2mTds[i][j];
310 Double_t pEx = (*extTrackTds)->emcPosition(iPart).x();
311 Double_t pEy = (*extTrackTds)->emcPosition(iPart).y();
312 Double_t pEz = (*extTrackTds)->emcPosition(iPart).z();
313 Double_t mEx = (*extTrackTds)->emcMomentum(iPart).x();
314 Double_t mEy = (*extTrackTds)->emcMomentum(iPart).y();
315 Double_t mEz = (*extTrackTds)->emcMomentum(iPart).z();
317 TString vEs = (*extTrackTds)->emcVolumeName(iPart) ;
318 Int_t vEn = (*extTrackTds)->emcVolumeNumber(iPart) ;
320 Double_t theta = (*extTrackTds)->emcPosSigmaAlongTheta(iPart);
321 Double_t phi = (*extTrackTds)->emcPosSigmaAlongPhi(iPart);
324 HepSymMatrix eEmTds = (*extTrackTds)->emcErrorMatrix(iPart);
325 for (
int i = 0;i<6 ;i++ )
326 for (
int j= 0;j<6 ;j++ )
327 eEm[i][j] = eEmTds[i][j];
328 Double_t emcPath=(*extTrackTds)->emcPath(iPart);
331 Double_t pMx = (*extTrackTds)->mucPosition(iPart).x();
332 Double_t pMy = (*extTrackTds)->mucPosition(iPart).y();
333 Double_t pMz = (*extTrackTds)->mucPosition(iPart).z();
334 Double_t mMx = (*extTrackTds)->mucMomentum(iPart).x();
335 Double_t mMy = (*extTrackTds)->mucMomentum(iPart).y();
336 Double_t mMz = (*extTrackTds)->mucMomentum(iPart).z();
338 TString vMs = (*extTrackTds)->mucVolumeName(iPart) ;
339 Int_t vMn = (*extTrackTds)->mucVolumeNumber(iPart) ;
341 Double_t zM = (*extTrackTds)->mucPosSigmaAlongZ(iPart);
342 Double_t tM = (*extTrackTds)->mucPosSigmaAlongT(iPart);
343 Double_t xM = (*extTrackTds)->mucPosSigmaAlongX(iPart);
344 Double_t yM = (*extTrackTds)->mucPosSigmaAlongY(iPart);
347 HepSymMatrix eMmTds = (*extTrackTds)->mucErrorMatrix(iPart);
348 for (
int i = 0;i<6 ;i++ )
349 for (
int j= 0;j<6 ;j++ )
350 eMm[i][j]= eMmTds[i][j];
353 ExtMucHitVec vecHit = (*extTrackTds)->GetExtMucHitVec(iPart);
354 Int_t size = vecHit.size();
361 extTrackRoot->
SetSize(size,iPart);
362 for(
int i=0;i<size;i++){
363 Double_t px = vecHit[i].GetPosition().x();
364 Double_t py = vecHit[i].GetPosition().y();
365 Double_t pz = vecHit[i].GetPosition().z();
366 Double_t mx = vecHit[i].GetMomentum().x();
367 Double_t my = vecHit[i].GetMomentum().y();
368 Double_t mz = vecHit[i].GetMomentum().z();
369 TString vs = vecHit[i].GetVolumeName();
370 Int_t vn = vecHit[i].GetVolumeNumber();
371 Double_t z = vecHit[i].GetPosSigmaAlongZ();
372 Double_t
t = vecHit[i].GetPosSigmaAlongT();
373 Double_t
x = vecHit[i].GetPosSigmaAlongX();
374 Double_t
y = vecHit[i].GetPosSigmaAlongY();
376 HepSymMatrix mTds = vecHit[i].GetErrorMatrix();
377 for (
int j = 0;j<6;j++)
379 m[j][k] = mTds[j][k];
381 extTrackRoot->
SetExtMucHit(px,py,pz,mx,my,mz,vs,vn,z,
t,
x,
y,m,iPart);
395 extTrackRoot->
SetTof1(tof1,iPart);
415 extTrackRoot->
SetTof2(tof2,iPart);
462 return StatusCode::SUCCESS;
vector< ExtMucHit > ExtMucHitVec
ObjectVector< RecExtTrack > RecExtTrackCol
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 SetParType(int aParType=2)
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)
void SetExtMucHit(Hep3Vector aPosition, Hep3Vector aMomentum, string aVolumeName, int aVolumeNumber, HepSymMatrix aErrorMatrix, double aZSigma=0., double aTSigma=0., double aXSigma=0., double aYSigma=0.)
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
RecExtTrackCnv(ISvcLocator *svc)
void AddExtMucHit(ExtMucHit aExtMucHit)
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.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
IDataProviderSvc * m_eds
pointer to eventdataservice
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.
Double_t GetTof2PosSigmaAlongX(const Int_t i=2) const
void SetTof2VolumeName(const TString Tof2VolumeName, const Int_t i=2)
void SetTof1VolumeNumber(const Int_t Tof1VolumeNumber, const Int_t i=2)
Double_t GetPositionX(Int_t i, const Int_t k=2) const
Double_t GetPositionZ(Int_t i, const Int_t k=2) const
Int_t GetTof2VolumeNumber(const Int_t i=2) const
Int_t GetSize(const Int_t i=2) const
void SetTof2PosSigmaAlongZ(const Double_t Tof2PosSigmaAlongZ, const Int_t i=2)
void SetTof1MomentumZ(const Double_t Tof1MomentumZ, const Int_t i=2)
Double_t GetTof1PosSigmaAlongY(const Int_t i=2) const
void SetExtMucHit(Double_t PositionX, Double_t PositionY, Double_t PositionZ, Double_t MomentumX, Double_t MomentumY, Double_t MomentumZ, TString VolumeName, Int_t VolumeNumber, Double_t PosSigmaAlongZ, Double_t PosSigmaAlongT, Double_t PosSigmaAlongX, Double_t PosSigmaAlongY, Double_t ErrorMatrix[6][6], const Int_t k=2)
Double_t GetTof1PositionY(const Int_t i=2) const
Double_t GetMucPositionZ(const Int_t i=2) const
void SetTof2(const Double_t Tof2, const Int_t i=2)
void SetSize(Int_t size, const Int_t i=2)
Int_t GetEmcVolumeNumber(const Int_t i=2) const
void SetEmcVolumeNumber(const Int_t EmcVolumeNumber, const Int_t i=2)
Int_t GetMucVolumeNumber(const Int_t i=2) const
TString GetVolumeName(Int_t i, const Int_t k=2) const
void SetTof1Path(const Double_t Tof1Path, const Int_t i=2)
void SetTof2PosSigmaAlongX(const Double_t Tof2PosSigmaAlongX, const Int_t i=2)
void SetTof1PosSigmaAlongY(const Double_t Tof1PosSigmaAlongY, const Int_t i=2)
void SetEmcMomentumX(const Double_t EmcMomentumX, const Int_t i=2)
Double_t GetTof2MomentumY(const Int_t i=2) const
Double_t GetMucMomentumX(const Int_t i=2) const
void SetTof2MomentumY(const Double_t Tof2MomentumY, const Int_t i=2)
void SetMucPositionZ(const Double_t MucPositionZ, const Int_t i=2)
Double_t GetTof1PositionX(const Int_t i=2) const
void SetTof2MomentumX(const Double_t Tof2MomentumX, const Int_t i=2)
void SetMucPositionX(const Double_t MucPositionX, const Int_t i=2)
Double_t GetMomentumX(Int_t i, const Int_t k=2) const
void SetMucPosSigmaAlongX(const Double_t MucPosSigmaAlongX, const Int_t i=2)
void SetMucVolumeName(const TString MucVolumeName, const Int_t i=2)
void SetTof2PosSigmaAlongY(const Double_t Tof2PosSigmaAlongY, const Int_t i=2)
void SetTof1MomentumX(const Double_t Tof1MomentumX, const Int_t i=2)
void SetTof1PositionZ(const Double_t Tof1PositionZ, const Int_t i=2)
Double_t GetMucMomentumZ(const Int_t i=2) const
vector< Double_t > GetErrorMatrix(Int_t i, const Int_t k=2) const
Double_t GetMucMomentumY(const Int_t i=2) const
void SetMucPosSigmaAlongY(const Double_t MucPosSigmaAlongY, const Int_t i=2)
Double_t GetTof1PositionZ(const Int_t i=2) const
Double_t GetMucPositionX(const Int_t i=2) const
void SetEmcMomentumY(const Double_t EmcMomentumY, const Int_t i=2)
void SetTof2ErrorMatrix(const Double_t Tof2ErrorMatrix[6][6], const Int_t k=2)
void SetTof2Path(const Double_t Tof2Path, const Int_t i=2)
Double_t GetTof2MomentumX(const Int_t i=2) const
Double_t GetTof1ErrorMatrix(Int_t i, Int_t j, const Int_t k=2) const
void SetMucMomentumY(const Double_t MucMomentumY, const Int_t i=2)
Double_t GetTof1PosSigmaAlongZ(const Int_t i=2) const
void SetMucPosSigmaAlongT(const Double_t MucPosSigmaAlongT, const Int_t i=2)
void SetTof1(const Double_t Tof1, const Int_t i=2)
Double_t GetTof2PositionX(const Int_t i=2) const
Double_t GetPosSigmaAlongY(Int_t i, const Int_t k=2) const
void SetMucMomentumZ(const Double_t MucMomentumZ, const Int_t i=2)
Double_t GetTof2PosSigmaAlongY(const Int_t i=2) const
Double_t GetPosSigmaAlongX(Int_t i, const Int_t k=2) const
void SetEmcErrorMatrix(const Double_t EmcErrorMatrix[6][6], const Int_t k=2)
Double_t GetPosSigmaAlongZ(Int_t i, const Int_t k=2) const
TString GetTof1VolumeName(const Int_t i=2) const
Double_t GetTof2PositionZ(const Int_t i=2) const
Double_t emcPath(const Int_t i=2) const
Int_t GetVolumeNumber(Int_t i, const Int_t k=2) const
void SetEmcMomentumZ(const Double_t EmcMomentumZ, const Int_t i=2)
void SetTof1ErrorMatrix(const Double_t Tof1ErrorMatrix[6][6], const Int_t k=2)
void SetTof1PosSigmaAlongX(const Double_t Tof1PosSigmaAlongX, const Int_t i=2)
Double_t GetTof2PosSigmaAlongZ(const Int_t i=2) const
void SetEmcPosSigmaAlongTheta(const Double_t EmcPosSigmaAlongTheta, const Int_t i=2)
void SetTrackId(const Int_t trackId)
Double_t GetEmcErrorMatrix(Int_t i, Int_t j, const Int_t k=2) const
Double_t GetPositionY(Int_t i, const Int_t k=2) const
void SetTof2PosSigmaAlongT(const Double_t Tof2PosSigmaAlongT, const Int_t i=2)
void SetTof1PosSigmaAlongT(const Double_t Tof1PosSigmaAlongT, const Int_t i=2)
void SetTof1MomentumY(const Double_t Tof1MomentumY, const Int_t i=2)
void SetEmcPositionX(const Double_t EmcPositionX, const Int_t i=2)
Double_t GetTof2PositionY(const Int_t i=2) const
void SetEmcPositionZ(const Double_t EmcPositionZ, const Int_t i=2)
Double_t GetMucPositionY(const Int_t i=2) const
Double_t GetTof1Path(const Int_t i=2) const
void SetMucPositionY(const Double_t MucPositionY, const Int_t i=2)
Double_t GetTof2ErrorMatrix(Int_t i, Int_t j, const Int_t k=2) const
void SetTof2MomentumZ(const Double_t Tof2MomentumZ, const Int_t i=2)
TString GetMucVolumeName(const Int_t i=2) const
Double_t GetTof1MomentumZ(const Int_t i=2) const
void SetMucErrorMatrix(const Double_t MucErrorMatrix[6][6], const Int_t k=2)
Double_t GetEmcPositionY(const Int_t i=2) const
Double_t GetEmcPositionX(const Int_t i=2) const
void SetEmcVolumeName(const TString EmcVolumeName, const Int_t i=2)
void SetTof2PositionY(const Double_t Tof2PositionY, const Int_t i=2)
Double_t GetEmcPositionZ(const Int_t i=2) const
Double_t GetTof1(const Int_t i=2) const
Double_t GetTof1PosSigmaAlongX(const Int_t i=2) const
Double_t GetTof2MomentumZ(const Int_t i=2) const
Double_t GetEmcPosSigmaAlongPhi(const Int_t i=2) const
Int_t GetTof1VolumeNumber(const Int_t i=2) const
Double_t GetTof1PosSigmaAlongT(const Int_t i=2) const
TString GetEmcVolumeName(const Int_t i=2) const
void SetTof1PosSigmaAlongZ(const Double_t Tof1PosSigmaAlongZ, const Int_t i=2)
Double_t GetEmcMomentumZ(const Int_t i=2) const
Double_t GetEmcMomentumX(const Int_t i=2) const
Double_t GetMomentumZ(Int_t i, const Int_t k=2) const
void SetMucPosSigmaAlongZ(const Double_t MucPosSigmaAlongZ, const Int_t i=2)
TString GetTof2VolumeName(const Int_t i=2) const
Double_t GetMomentumY(Int_t i, const Int_t k=2) const
Double_t GetEmcPosSigmaAlongTheta(const Int_t i=2) const
Double_t GetMucPosSigmaAlongX(const Int_t i=2) const
void SetTof1VolumeName(const TString Tof1VolumeName, const Int_t i=2)
void SetMucMomentumX(const Double_t MucMomentumX, const Int_t i=2)
Double_t GetMucErrorMatrix(Int_t i, Int_t j, const Int_t k=2) const
void SetTof1PositionX(const Double_t Tof1PositionX, const Int_t i=2)
void SetTof2PositionZ(const Double_t Tof2PositionZ, const Int_t i=2)
Double_t GetTof2Path(const Int_t i=2) const
Double_t GetTof1MomentumY(const Int_t i=2) const
Double_t GetMucPosSigmaAlongT(const Int_t i=2) const
void SetEmcPosSigmaAlongPhi(const Double_t EmcPosSigmaAlongPhi, const Int_t i=2)
Double_t GetTof2PosSigmaAlongT(const Int_t i=2) const
void SetTof2PositionX(const Double_t Tof2PositionX, const Int_t i=2)
void SetEmcPath(Double_t path, const Int_t i=2)
Double_t GetTof2(const Int_t i=2) const
void SetEmcPositionY(const Double_t EmcPositionY, const Int_t i=2)
void SetTof2VolumeNumber(const Int_t Tof2VolumeNumber, const Int_t i=2)
Double_t GetTof1MomentumX(const Int_t i=2) const
void SetMucVolumeNumber(const Int_t MucVolumeNumber, const Int_t i=2)
void SetTof1PositionY(const Double_t Tof1PositionY, const Int_t i=2)
Double_t GetEmcMomentumY(const Int_t i=2) const
Double_t GetPosSigmaAlongT(Int_t i, const Int_t k=2) const
Double_t GetMucPosSigmaAlongZ(const Int_t i=2) const
Double_t GetMucPosSigmaAlongY(const Int_t i=2) const
const TObjArray * getExtTrackCol() const
void addExtTrack(TRecExtTrack *Track)
Add a ExtTrack into the Ext Data collection.
static std::map< const TObject *, const DstExtTrack * > m_rootExtTrackMap
_EXTERN_ std::string Event