CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RecCgemKalHelixSegCnv.cxx
Go to the documentation of this file.
1#ifndef RecCgemKalHelixSegCnv_CXX
2#define RecCgemKalHelixSegCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
11
15
16#include "RootEventData/TRecCgemKalHelixSeg.h" // standard root object
18
22
23#include <vector>
24
25using namespace std;
26
27
29: RootEventBaseCnv(classID(), svc)
30{
31
32 // Here we associate this converter with the /Event path on the TDS.
33 MsgStream log(msgSvc(), "RecCgemKalHelixSegCnv");
34 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
35 //m_rootTreename ="Rec";
36 m_rootBranchname ="m_recCgemKalHelixSegCol";
37 //declareObject(EventModel::Recon::RecCgemKalHelixSegCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_recCgemKalHelixSegCol);
39 m_recCgemKalHelixSegCol=0;
40}
41
42StatusCode RecCgemKalHelixSegCnv::TObjectToDataObject(DataObject*& refpObject) {
43 // creation of TDS object from root object
44 MsgStream log(msgSvc(), "RecCgemKalHelixSegCnv");
45 log << MSG::DEBUG << "RecCgemKalHelixSegCnv::TObjectToDataObject" << endreq;
46
47 // create the TDS location for the RecCgemKalHelixSeg Collection
48 RecCgemKalHelixSegCol* recCgemKalHelixSegCol = new RecCgemKalHelixSegCol;
49 refpObject = recCgemKalHelixSegCol;
50
51 // now convert
52 if (!m_recCgemKalHelixSegCol) return StatusCode::SUCCESS;
53 TIter cgemHitIter(m_recCgemKalHelixSegCol);
54 TRecCgemKalHelixSeg *recCgemKalHelixSegRoot = 0;
55 while ((recCgemKalHelixSegRoot = (TRecCgemKalHelixSeg*)cgemHitIter.Next())) {
56 int trackId = recCgemKalHelixSegRoot->getTrackId();
57// unsigned int cgemIdMSB = recCgemKalHelixSegRoot->getCgemIdMSB();
58// unsigned int cgemIdLSB = recCgemKalHelixSegRoot->getCgemIdLSB();
59// Identifier64 cgemId(cgemIdMSB,cgemIdLSB);
60 Identifier cgemId(recCgemKalHelixSegRoot->getCgemId());
61 double tdc = recCgemKalHelixSegRoot->getTdc();
62 double adc = recCgemKalHelixSegRoot->getAdc();
63 double zhit = recCgemKalHelixSegRoot->getZhit();
64 double tof = recCgemKalHelixSegRoot->getTof();
65 double docaIncl = recCgemKalHelixSegRoot->getDocaIncl();
66 double docaExcl = recCgemKalHelixSegRoot->getDocaExcl();
67 double entra = recCgemKalHelixSegRoot->getEntra();
68 // int layerId = recCgemKalHelixSegRoot->getLayerId();
69 // double drIncl = recCgemKalHelixSegRoot->getDrIncl();
70 // double phi0Incl = recCgemKalHelixSegRoot->getFi0Incl();
71 // double kappaIncl = recCgemKalHelixSegRoot->getCpaIncl();
72 // double dzIncl = recCgemKalHelixSegRoot->getDzIncl();
73 // double tanlIncl = recCgemKalHelixSegRoot->getTanlIncl();
74 // double drExcl = recCgemKalHelixSegRoot->getDrExcl();
75 // double phi0Excl = recCgemKalHelixSegRoot->getFi0Excl();
76 // double kappaExcl = recCgemKalHelixSegRoot->getCpaExcl();
77 // double dzExcl = recCgemKalHelixSegRoot->getDzExcl();
78 // double tanlExcl = recCgemKalHelixSegRoot->getTanlExcl();
79 double helixIncl[5]; // errIncl[15];
80 double helixExcl[5]; // errExcl[15];
81 for(int i=0, k=0; i<5; i++){
82 helixIncl[i] = recCgemKalHelixSegRoot->getHelixIncl(i);
83 helixExcl[i] = recCgemKalHelixSegRoot->getHelixExcl(i);
84 // for(int j=0; j<=i; j++){
85 // errIncl[k] = recCgemKalHelixSegRoot->getErrorIncl(i,j);
86 // errExcl[k] = recCgemKalHelixSegRoot->getErrorExcl(i,j);
87 // }
88 }
89
90 RecCgemKalHelixSeg *recCgemKalHelixSeg= new RecCgemKalHelixSeg();
91 m_common.m_rootRecCgemKalHelixSegMap[recCgemKalHelixSegRoot] = recCgemKalHelixSeg;
92
93 recCgemKalHelixSeg->setTrackId( trackId );
94 recCgemKalHelixSeg->setCgemId( Identifier(cgemId) );
95 recCgemKalHelixSeg->setTdc( tdc );
96 recCgemKalHelixSeg->setAdc( adc );
97 recCgemKalHelixSeg->setZhit( zhit );
98 recCgemKalHelixSeg->setTof( tof );
99 recCgemKalHelixSeg->setDocaIncl( docaIncl );
100 recCgemKalHelixSeg->setDocaExcl( docaExcl );
101 recCgemKalHelixSeg->setEntra( entra );
102// recCgemKalHelixSeg->setLayerId( layerId );
103// recCgemKalHelixSeg->setDrIncl( drIncl );
104// recCgemKalHelixSeg->setFi0Incl( phi0Incl );
105// recCgemKalHelixSeg->setCpaIncl( kappaIncl );
106// recCgemKalHelixSeg->setDzIncl( dzIncl );
107// recCgemKalHelixSeg->setTanlIncl( tanlIncl );
108// recCgemKalHelixSeg->setDrExcl( drIncl );
109// recCgemKalHelixSeg->setFi0Excl( phi0Excl );
110// recCgemKalHelixSeg->setCpaExcl( kappaExcl );
111// recCgemKalHelixSeg->setDzExcl( dzExcl );
112// recCgemKalHelixSeg->setTanlExcl( tanlExcl );
113 recCgemKalHelixSeg->setHelixIncl( helixIncl );
114 recCgemKalHelixSeg->setHelixExcl( helixExcl );
115// recCgemKalHelixSeg->setErrorIncl( errIncl );
116// recCgemKalHelixSeg->setErrorExcl( errExcl );
117
118 recCgemKalHelixSegCol->push_back(recCgemKalHelixSeg);
119 }
120 return StatusCode::SUCCESS;
121}
122
123StatusCode RecCgemKalHelixSegCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
124
125 MsgStream log(msgSvc(), "RecCgemKalHelixSegCnv");
126 log << MSG::DEBUG << "RecCgemKalHelixSegCnv::DataObjectToTObject" << endreq;
127
128 RecCgemKalHelixSegCol * cgemHitColTds=dynamic_cast<RecCgemKalHelixSegCol *> (obj);
129 if (!cgemHitColTds) {
130 log << MSG::ERROR << "Could not downcast to RecCgemKalHelixSegCol" << endreq;
131 return StatusCode::FAILURE;
132 }
133
134 DataObject *evt;
135 m_eds->findObject(EventModel::Recon::Event,evt);
136 if (evt==NULL) {
137 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
138 return StatusCode::FAILURE;
139 }
140
141 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
142 if (!devtTds) {
143 log << MSG::ERROR << "RecCgemKalHelixSegCnv:Could not downcast to TDS ReconEvent" << endreq;
144 }
145
146 IOpaqueAddress *addr;
147
148 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
150
151 const TObjArray *m_recCgemKalHelixSegCol = recEvt->getRecCgemKalHelixSegCol();
152 if (!m_recCgemKalHelixSegCol) return StatusCode::SUCCESS;
153 recEvt->clearRecCgemKalHelixSegCol(); //necessary in case there is I/O at the same time since array is static
154
155 RecCgemKalHelixSegCol::const_iterator recCgemKalHelixSeg;
156 for (recCgemKalHelixSeg = cgemHitColTds->begin(); recCgemKalHelixSeg != cgemHitColTds->end(); recCgemKalHelixSeg++) {
157 Int_t trackId =(*recCgemKalHelixSeg)->getTrackId();
158// UInt_t cgemIdMSB = (*recCgemKalHelixSeg)->getCgemId().get_valueMSB();
159// UInt_t cgemIdLSB = (*recCgemKalHelixSeg)->getCgemId().get_valueLSB();
160 UInt_t cgemId = (*recCgemKalHelixSeg)->getCgemId().get_value();
161 Double_t tdc = (*recCgemKalHelixSeg)->getTdc();
162 Double_t adc = (*recCgemKalHelixSeg)->getAdc();
163 Double_t zhit = (*recCgemKalHelixSeg)->getZhit();
164 Double_t tof = (*recCgemKalHelixSeg)->getTof();
165 Double_t docaIncl = (*recCgemKalHelixSeg)->getDocaIncl();
166 Double_t docaExcl = (*recCgemKalHelixSeg)->getDocaExcl();
167 Double_t entra = (*recCgemKalHelixSeg)->getEntra();
168// Int_t layerId = (*recCgemKalHelixSeg)->getLayerId();
169// Double_t drIncl = (*recCgemKalHelixSeg)->getDrIncl();
170// Double_t phi0Incl =(*recCgemKalHelixSeg)->getFi0Incl();
171// Double_t kappaIncl = (*recCgemKalHelixSeg)->getCpaIncl();
172// Double_t dzIncl = (*recCgemKalHelixSeg)->getDzIncl();
173// Double_t tanlIncl = (*recCgemKalHelixSeg)->getTanlIncl();
174// Double_t drExcl = (*recCgemKalHelixSeg)->getDrExcl();
175// Double_t phi0Excl = (*recCgemKalHelixSeg)->getFi0Excl();
176// Double_t kappaExcl = (*recCgemKalHelixSeg)->getCpaExcl();
177// Double_t dzExcl = (*recCgemKalHelixSeg)->getDzExcl();
178// Double_t tanlExcl = (*recCgemKalHelixSeg)->getTanlExcl();
179 HepVector helixIncl_vct = (*recCgemKalHelixSeg)->getHelixIncl();
180 HepVector helixExcl_vct = (*recCgemKalHelixSeg)->getHelixExcl();
181// HepSymMatrix errIncl_mtx = (*recCgemKalHelixSeg)->getErrorIncl();
182// HepSymMatrix errExcl_mtx = (*recCgemKalHelixSeg)->getErrorExcl();
183
184 Double_t helixIncl[5], helixExcl[5]; //errIncl[5][5], errExcl[5][5];
185 for(Int_t i=0; i<5; i++){
186 helixIncl[i] = helixIncl_vct[i];
187 helixExcl[i] = helixExcl_vct[i];
188 }
189// for (Int_t i=0; i<5; i++){
190// for(Int_t j=0; j<5; j++){
191// errIncl[i][j] = errIncl_mtx[i][j];
192// errExcl[i][j] = errExcl_mtx[i][j];
193// }
194// }
195
196 TRecCgemKalHelixSeg *recCgemKalHelixSegRoot = new TRecCgemKalHelixSeg();
197 //m_common.m_recCgemKalHelixSegMap[(*recCgemKalHelixSeg)] = recCgemKalHelixSegRoot;
198
199 recCgemKalHelixSegRoot->setTrackId( trackId );
200// recCgemKalHelixSegRoot->setCgemIdMSB( cgemIdMSB );
201// recCgemKalHelixSegRoot->setCgemIdLSB( cgemIdLSB );
202 recCgemKalHelixSegRoot->setCgemId( cgemId );
203 recCgemKalHelixSegRoot->setTdc( tdc );
204 recCgemKalHelixSegRoot->setAdc( adc );
205 recCgemKalHelixSegRoot->setZhit( zhit );
206 recCgemKalHelixSegRoot->setTof( tof );
207 recCgemKalHelixSegRoot->setDocaIncl( docaIncl );
208 recCgemKalHelixSegRoot->setDocaExcl( docaExcl );
209 recCgemKalHelixSegRoot->setEntra( entra );
210// recCgemKalHelixSegRoot->setLayerId( layerId );
211// recCgemKalHelixSegRoot->setDrIncl( drIncl );
212// recCgemKalHelixSegRoot->setFi0Incl( phi0Incl );
213// recCgemKalHelixSegRoot->setCpaIncl( kappaIncl );
214// recCgemKalHelixSegRoot->setDzIncl( dzIncl );
215// recCgemKalHelixSegRoot->setTanlIncl( tanlIncl );
216// recCgemKalHelixSegRoot->setDrExcl( drIncl );
217// recCgemKalHelixSegRoot->setFi0Excl( phi0Excl );
218// recCgemKalHelixSegRoot->setCpaExcl( kappaExcl );
219// recCgemKalHelixSegRoot->setDzExcl( dzExcl );
220// recCgemKalHelixSegRoot->setTanlExcl( tanlExcl );
221 recCgemKalHelixSegRoot->setHelixIncl( helixIncl );
222 recCgemKalHelixSegRoot->setHelixExcl( helixExcl );
223// recCgemKalHelixSegRoot->setErrorIncl( errIncl );
224// recCgemKalHelixSegRoot->setErrorExcl( errExcl );
225
226 recEvt->addRecCgemKalHelixSeg(recCgemKalHelixSegRoot);
227 }
228 return StatusCode::SUCCESS;
229}
230#endif
ObjectVector< RecCgemKalHelixSeg > RecCgemKalHelixSegCol
IMessageSvc * msgSvc()
RecCgemKalHelixSegCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
void setTdc(double tdc)
void setCgemId(Identifier cgemid)
void setTof(double tof)
void setTrackId(int trackid)
void setHelixExcl(const HepVector &helix)
void setAdc(double adc)
void setDocaIncl(double doca)
void setDocaExcl(double doca)
void setZhit(double zhit)
void setEntra(double entra)
void setHelixIncl(const HepVector &helix)
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: RecTrackCnv.h:36
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
RecTrackCnv * getRecTrackCnv()
Definition: RootCnvSvc.h:166
Base class for all Root Converters.
std::vector< void * > m_adresses
each converter knows the corresponding adresses
RootCnvSvc * m_cnvSvc
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.
const Double_t getEntra(void) const
const Double_t getDocaIncl(void) const
const Int_t getTrackId(void) const
const Double_t getDocaExcl(void) const
void setZhit(Double_t zhit)
void setDocaIncl(Double_t docaincl)
void setHelixIncl(const Double_t helix[5])
void setEntra(Double_t entra)
const Double_t getHelixExcl(Int_t i) const
void setDocaExcl(Double_t docaexcl)
void setHelixExcl(const Double_t helix[5])
const Double_t getAdc(void) const
void setTof(Double_t tof)
const Double_t getHelixIncl(Int_t i) const
void setCgemId(UInt_t cgemid)
const Double_t getTof(void) const
const Double_t getTdc(void) const
const UInt_t getCgemId() const
void setTdc(Double_t tdc)
void setTrackId(Int_t trkid)
const Double_t getZhit(void) const
void setAdc(Double_t adc)
const TObjArray * getRecCgemKalHelixSegCol() const
void clearRecCgemKalHelixSegCol()
void addRecCgemKalHelixSeg(TRecCgemKalHelixSeg *Track)
static std::map< const TObject *, const RecCgemKalHelixSeg * > m_rootRecCgemKalHelixSegMap
Definition: commonData.h:305
_EXTERN_ std::string Event
Definition: EventModel.h:90