CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_RootCnvSvc-04-01-14/src/Rec/RecMdcKalHelixSegCnv.cxx
Go to the documentation of this file.
1#ifndef RecMdcKalHelixSegCnv_CXX
2#define RecMdcKalHelixSegCnv_CXX 1
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
10#include "EventModel/EventModel.h"
11
12#include "ReconEvent/ReconEvent.h"
13#include "MdcRecEvent/RecMdcKalHelixSeg.h"
14#include "Identifier/Identifier.h"
15
16#include "RootEventData/TRecMdcKalHelixSeg.h" // standard root object
17#include "RootEventData/TRecTrackEvent.h"
18
19#include "RootCnvSvc/Rec/RecTrackCnv.h"
20#include "RootCnvSvc/Rec/RecMdcKalHelixSegCnv.h"
21#include "RootCnvSvc/RootAddress.h"
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(), "RecMdcKalHelixSegCnv");
34 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
35 //m_rootTreename ="Rec";
36 m_rootBranchname ="m_recMdcKalHelixSegCol";
37 //declareObject(EventModel::Recon::RecMdcKalHelixSegCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_recMdcKalHelixSegCol);
39 m_recMdcKalHelixSegCol=0;
40}
41
42StatusCode RecMdcKalHelixSegCnv::TObjectToDataObject(DataObject*& refpObject) {
43 // creation of TDS object from root object
44 MsgStream log(msgSvc(), "RecMdcKalHelixSegCnv");
45 log << MSG::DEBUG << "RecMdcKalHelixSegCnv::TObjectToDataObject" << endreq;
46
47 // create the TDS location for the RecMdcKalHelixSeg Collection
48 RecMdcKalHelixSegCol* recMdcKalHelixSegCol = new RecMdcKalHelixSegCol;
49 refpObject = recMdcKalHelixSegCol;
50
51 // now convert
52 if (!m_recMdcKalHelixSegCol) return StatusCode::SUCCESS;
53 TIter mdcHitIter(m_recMdcKalHelixSegCol);
54 TRecMdcKalHelixSeg *recMdcKalHelixSegRoot = 0;
55 int nSeg=0;
56 while ((recMdcKalHelixSegRoot = (TRecMdcKalHelixSeg*)mdcHitIter.Next())) {
57 int trackId = recMdcKalHelixSegRoot->getTrackId();
58 int flagLR = recMdcKalHelixSegRoot->getFlagLR();
59 Identifier mdcId(recMdcKalHelixSegRoot->getMdcId());
60 double tdc = recMdcKalHelixSegRoot->getTdc();
61 double adc = recMdcKalHelixSegRoot->getAdc();
62 double zhit = recMdcKalHelixSegRoot->getZhit();
63 double tof = recMdcKalHelixSegRoot->getTof();
64 double docaIncl = recMdcKalHelixSegRoot->getDocaIncl();
65 double docaExcl = recMdcKalHelixSegRoot->getDocaExcl();
66 double driftDist= recMdcKalHelixSegRoot->getDD();
67 double entra = recMdcKalHelixSegRoot->getEntra();
68 double driftT = recMdcKalHelixSegRoot->getDT();
69 // int layerId = recMdcKalHelixSegRoot->getLayerId();
70 // double drIncl = recMdcKalHelixSegRoot->getDrIncl();
71 // double phi0Incl = recMdcKalHelixSegRoot->getFi0Incl();
72 // double kappaIncl = recMdcKalHelixSegRoot->getCpaIncl();
73 // double dzIncl = recMdcKalHelixSegRoot->getDzIncl();
74 // double tanlIncl = recMdcKalHelixSegRoot->getTanlIncl();
75 // double drExcl = recMdcKalHelixSegRoot->getDrExcl();
76 // double phi0Excl = recMdcKalHelixSegRoot->getFi0Excl();
77 // double kappaExcl = recMdcKalHelixSegRoot->getCpaExcl();
78 // double dzExcl = recMdcKalHelixSegRoot->getDzExcl();
79 // double tanlExcl = recMdcKalHelixSegRoot->getTanlExcl();
80 double helixIncl[5]; // errIncl[15];
81 double helixExcl[5]; // errExcl[15];
82 for(int i=0, k=0; i<5; i++){
83 helixIncl[i] = recMdcKalHelixSegRoot->getHelixIncl(i);
84 helixExcl[i] = recMdcKalHelixSegRoot->getHelixExcl(i);
85 // for(int j=0; j<=i; j++){
86 // errIncl[k] = recMdcKalHelixSegRoot->getErrorIncl(i,j);
87 // errExcl[k] = recMdcKalHelixSegRoot->getErrorExcl(i,j);
88 // }
89 }
90
91 RecMdcKalHelixSeg *recMdcKalHelixSeg= new RecMdcKalHelixSeg();
92 m_common.m_rootRecMdcKalHelixSegMap[recMdcKalHelixSegRoot] = recMdcKalHelixSeg;
93
94 recMdcKalHelixSeg->setTrackId( trackId );
95 recMdcKalHelixSeg->setFlagLR( flagLR );
96 recMdcKalHelixSeg->setMdcId( Identifier(mdcId) );
97 recMdcKalHelixSeg->setTdc( tdc );
98 recMdcKalHelixSeg->setAdc( adc );
99 recMdcKalHelixSeg->setZhit( zhit );
100 recMdcKalHelixSeg->setTof( tof );
101 recMdcKalHelixSeg->setDocaIncl( docaIncl );
102 recMdcKalHelixSeg->setDocaExcl( docaExcl );
103 recMdcKalHelixSeg->setDD( driftDist );
104 recMdcKalHelixSeg->setEntra( entra );
105 recMdcKalHelixSeg->setDT( driftT );
106 // recMdcKalHelixSeg->setLayerId( layerId );
107 // recMdcKalHelixSeg->setDrIncl( drIncl );
108 // recMdcKalHelixSeg->setFi0Incl( phi0Incl );
109 // recMdcKalHelixSeg->setCpaIncl( kappaIncl );
110 // recMdcKalHelixSeg->setDzIncl( dzIncl );
111 // recMdcKalHelixSeg->setTanlIncl( tanlIncl );
112 // recMdcKalHelixSeg->setDrExcl( drIncl );
113 // recMdcKalHelixSeg->setFi0Excl( phi0Excl );
114 // recMdcKalHelixSeg->setCpaExcl( kappaExcl );
115 // recMdcKalHelixSeg->setDzExcl( dzExcl );
116 // recMdcKalHelixSeg->setTanlExcl( tanlExcl );
117 recMdcKalHelixSeg->setHelixIncl( helixIncl );
118 recMdcKalHelixSeg->setHelixExcl( helixExcl );
119 // recMdcKalHelixSeg->setErrorIncl( errIncl );
120 // recMdcKalHelixSeg->setErrorExcl( errExcl );
121
122 recMdcKalHelixSegCol->push_back(recMdcKalHelixSeg);
123 nSeg++;
124 }
125 //cout<<"rec -> Tds, nSeg = "<<nSeg<<", recMdcKalHelixSegCol.size="<<recMdcKalHelixSegCol->size()<<endl;
126 return StatusCode::SUCCESS;
127}
128
129StatusCode RecMdcKalHelixSegCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
130
131 MsgStream log(msgSvc(), "RecMdcKalHelixSegCnv");
132 log << MSG::DEBUG << "RecMdcKalHelixSegCnv::DataObjectToTObject" << endreq;
133
134 RecMdcKalHelixSegCol * mdcHitColTds=dynamic_cast<RecMdcKalHelixSegCol *> (obj);
135 if (!mdcHitColTds) {
136 log << MSG::ERROR << "Could not downcast to RecMdcKalHelixSegCol" << endreq;
137 return StatusCode::FAILURE;
138 }
139
140 DataObject *evt;
141 m_eds->findObject(EventModel::Recon::Event,evt);
142 if (evt==NULL) {
143 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
144 return StatusCode::FAILURE;
145 }
146
147 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
148 if (!devtTds) {
149 log << MSG::ERROR << "RecMdcKalHelixSegCnv:Could not downcast to TDS ReconEvent" << endreq;
150 }
151
152 IOpaqueAddress *addr;
153
154 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
156
157 const TObjArray *m_recMdcKalHelixSegCol = recEvt->getRecMdcKalHelixSegCol();
158 if (!m_recMdcKalHelixSegCol) return StatusCode::SUCCESS;
159 recEvt->clearRecMdcKalHelixSegCol(); //necessary in case there is I/O at the same time since array is static
160
161 RecMdcKalHelixSegCol::const_iterator recMdcKalHelixSeg;
162 int nSeg=0;
163 for (recMdcKalHelixSeg = mdcHitColTds->begin(); recMdcKalHelixSeg != mdcHitColTds->end(); recMdcKalHelixSeg++) {
164 Int_t trackId =(*recMdcKalHelixSeg)->getTrackId();
165 Int_t flagLR = (*recMdcKalHelixSeg)->getFlagLR();
166 UInt_t mdcId = (*recMdcKalHelixSeg)->getMdcId().get_value();
167 Double_t tdc = (*recMdcKalHelixSeg)->getTdc();
168 Double_t adc = (*recMdcKalHelixSeg)->getAdc();
169 Double_t zhit = (*recMdcKalHelixSeg)->getZhit();
170 Double_t tof = (*recMdcKalHelixSeg)->getTof();
171 Double_t docaIncl = (*recMdcKalHelixSeg)->getDocaIncl();
172 Double_t docaExcl = (*recMdcKalHelixSeg)->getDocaExcl();
173 Double_t driftDist= (*recMdcKalHelixSeg)->getDD();
174 Double_t entra = (*recMdcKalHelixSeg)->getEntra();
175 Double_t driftT = (*recMdcKalHelixSeg)->getDT();
176 // Int_t layerId = (*recMdcKalHelixSeg)->getLayerId();
177 // Double_t drIncl = (*recMdcKalHelixSeg)->getDrIncl();
178 // Double_t phi0Incl =(*recMdcKalHelixSeg)->getFi0Incl();
179 // Double_t kappaIncl = (*recMdcKalHelixSeg)->getCpaIncl();
180 // Double_t dzIncl = (*recMdcKalHelixSeg)->getDzIncl();
181 // Double_t tanlIncl = (*recMdcKalHelixSeg)->getTanlIncl();
182 // Double_t drExcl = (*recMdcKalHelixSeg)->getDrExcl();
183 // Double_t phi0Excl = (*recMdcKalHelixSeg)->getFi0Excl();
184 // Double_t kappaExcl = (*recMdcKalHelixSeg)->getCpaExcl();
185 // Double_t dzExcl = (*recMdcKalHelixSeg)->getDzExcl();
186 // Double_t tanlExcl = (*recMdcKalHelixSeg)->getTanlExcl();
187 HepVector helixIncl_vct = (*recMdcKalHelixSeg)->getHelixIncl();
188 HepVector helixExcl_vct = (*recMdcKalHelixSeg)->getHelixExcl();
189 // HepSymMatrix errIncl_mtx = (*recMdcKalHelixSeg)->getErrorIncl();
190 // HepSymMatrix errExcl_mtx = (*recMdcKalHelixSeg)->getErrorExcl();
191
192 Double_t helixIncl[5], helixExcl[5]; //errIncl[5][5], errExcl[5][5];
193 for(Int_t i=0; i<5; i++){
194 helixIncl[i] = helixIncl_vct[i];
195 helixExcl[i] = helixExcl_vct[i];
196 }
197 // for (Int_t i=0; i<5; i++){
198 // for(Int_t j=0; j<5; j++){
199 // errIncl[i][j] = errIncl_mtx[i][j];
200 // errExcl[i][j] = errExcl_mtx[i][j];
201 // }
202 // }
203
204 TRecMdcKalHelixSeg *recMdcKalHelixSegRoot = new TRecMdcKalHelixSeg();
205 //m_common.m_recMdcKalHelixSegMap[(*recMdcKalHelixSeg)] = recMdcKalHelixSegRoot;
206
207 recMdcKalHelixSegRoot->setTrackId( trackId );
208 recMdcKalHelixSegRoot->setFlagLR( flagLR );
209 recMdcKalHelixSegRoot->setMdcId( Identifier(mdcId) );
210 recMdcKalHelixSegRoot->setTdc( tdc );
211 recMdcKalHelixSegRoot->setAdc( adc );
212 recMdcKalHelixSegRoot->setZhit( zhit );
213 recMdcKalHelixSegRoot->setTof( tof );
214 recMdcKalHelixSegRoot->setDocaIncl( docaIncl );
215 recMdcKalHelixSegRoot->setDocaExcl( docaExcl );
216 recMdcKalHelixSegRoot->setDD( driftDist );
217 recMdcKalHelixSegRoot->setEntra( entra );
218 recMdcKalHelixSegRoot->setDT( driftT );
219 // recMdcKalHelixSegRoot->setLayerId( layerId );
220 // recMdcKalHelixSegRoot->setDrIncl( drIncl );
221 // recMdcKalHelixSegRoot->setFi0Incl( phi0Incl );
222 // recMdcKalHelixSegRoot->setCpaIncl( kappaIncl );
223 // recMdcKalHelixSegRoot->setDzIncl( dzIncl );
224 // recMdcKalHelixSegRoot->setTanlIncl( tanlIncl );
225 // recMdcKalHelixSegRoot->setDrExcl( drIncl );
226 // recMdcKalHelixSegRoot->setFi0Excl( phi0Excl );
227 // recMdcKalHelixSegRoot->setCpaExcl( kappaExcl );
228 // recMdcKalHelixSegRoot->setDzExcl( dzExcl );
229 // recMdcKalHelixSegRoot->setTanlExcl( tanlExcl );
230 recMdcKalHelixSegRoot->setHelixIncl( helixIncl );
231 recMdcKalHelixSegRoot->setHelixExcl( helixExcl );
232 // recMdcKalHelixSegRoot->setErrorIncl( errIncl );
233 // recMdcKalHelixSegRoot->setErrorExcl( errExcl );
234
235 log<<MSG::INFO<<" recMdcKalHelixSegRoot.dd: "<<recMdcKalHelixSegRoot->getDD()
236 <<" recMdcKalHelixSegRoot.entra: "<<recMdcKalHelixSegRoot->getEntra()
237 <<endreq;
238
239 recEvt->addRecMdcKalHelixSeg(recMdcKalHelixSegRoot);
240 nSeg++;
241 }
242 //cout<<"writing nSeg = "<<nSeg<<endl;
243 return StatusCode::SUCCESS;
244}
245#endif
ObjectVector< RecMdcKalHelixSeg > RecMdcKalHelixSegCol
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
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 addRecMdcKalHelixSeg(TRecMdcKalHelixSeg *Track)
static std::map< const TObject *, const RecMdcKalHelixSeg * > m_rootRecMdcKalHelixSegMap