CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_RootCnvSvc-04-01-14/src/Rec/RecMdcHitCnv.cxx
Go to the documentation of this file.
1#ifndef RecMdcHitCnv_CXX
2#define RecMdcHitCnv_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/RecMdcHit.h"
14#include "Identifier/Identifier.h"
15
16#include "RootEventData/TRecMdcHit.h" // standard root object
17#include "RootEventData/TRecTrackEvent.h"
18
19#include "RootCnvSvc/Rec/RecTrackCnv.h"
20#include "RootCnvSvc/Rec/RecMdcHitCnv.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(), "RecMdcHitCnv");
34 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
35 //m_rootTreename ="Rec";
36 m_rootBranchname ="m_recMdcHitCol";
37 //declareObject(EventModel::Recon::RecMdcHitCol, objType(), m_rootTreename, m_rootBranchname);
38 m_adresses.push_back(&m_recMdcHitCol);
39 m_recMdcHitCol=0;
40}
41
42StatusCode RecMdcHitCnv::TObjectToDataObject(DataObject*& refpObject) {
43 // creation of TDS object from root object
44 MsgStream log(msgSvc(), "RecMdcHitCnv");
45 log << MSG::DEBUG << "RecMdcHitCnv::TObjectToDataObject" << endreq;
46
47 // create the TDS location for the RecMdcHit Collection
48 RecMdcHitCol* recMdcHitCol = new RecMdcHitCol;
49 refpObject = recMdcHitCol;
50
51 // now convert
52 if (!m_recMdcHitCol) return StatusCode::SUCCESS;
53 TIter mdcHitIter(m_recMdcHitCol);
54 TRecMdcHit *recMdcHitRoot = 0;
55 while ((recMdcHitRoot = (TRecMdcHit*)mdcHitIter.Next())) {
56 int id = recMdcHitRoot->getId();
57 int trackId = recMdcHitRoot->getTrkId();
58 double driftDistLeft = recMdcHitRoot->getDriftDistLeft();
59 double driftDistRight = recMdcHitRoot->getDriftDistRight();
60 double errDriftDistLeft = recMdcHitRoot->getErrDriftDistLeft();
61 double errDriftDistRight = recMdcHitRoot->getErrDriftDistRight();
62 double chisqAdd = recMdcHitRoot->getChisqAdd();
63 int flagLR = recMdcHitRoot->getFlagLR();
64 int stat = recMdcHitRoot->getStat();
65 long int mdcId(recMdcHitRoot->getMdcId());
66 double tdc = recMdcHitRoot->getTdc();
67 double adc = recMdcHitRoot->getAdc();
68 double driftT = recMdcHitRoot->getDriftT();
69 double doca = recMdcHitRoot->getDoca();
70 double entra = recMdcHitRoot->getEntra();
71 double zhit = recMdcHitRoot->getZhit();
72 double fltLen = recMdcHitRoot->getFltLen();
73
74 RecMdcHit *recMdcHit= new RecMdcHit();
75 m_common.m_rootRecMdcHitMap[recMdcHitRoot] = recMdcHit;
76
77 recMdcHit->setId( id );
78 recMdcHit->setTrkId( trackId );
79 recMdcHit->setDriftDistLeft( driftDistLeft );
80 recMdcHit->setDriftDistRight( driftDistRight );
81 recMdcHit->setErrDriftDistLeft( errDriftDistLeft );
82 recMdcHit->setErrDriftDistRight( errDriftDistRight );
83 recMdcHit->setChisqAdd( chisqAdd );
84 recMdcHit->setFlagLR( flagLR );
85 recMdcHit->setStat( stat );
86 recMdcHit->setMdcId( Identifier(mdcId) );
87 recMdcHit->setTdc( tdc );
88 recMdcHit->setAdc( adc );
89 recMdcHit->setDriftT( driftT );
90 recMdcHit->setDoca( doca );
91 recMdcHit->setEntra( entra );
92 recMdcHit->setZhit( zhit );
93 recMdcHit->setFltLen( fltLen );
94
95 recMdcHitCol->push_back(recMdcHit);
96 }
97 return StatusCode::SUCCESS;
98}
99
100StatusCode RecMdcHitCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
101
102 MsgStream log(msgSvc(), "RecMdcHitCnv");
103 log << MSG::DEBUG << "RecMdcHitCnv::DataObjectToTObject" << endreq;
104
105 RecMdcHitCol * mdcHitColTds=dynamic_cast<RecMdcHitCol *> (obj);
106 if (!mdcHitColTds) {
107 log << MSG::ERROR << "Could not downcast to RecMdcHitCol" << endreq;
108 return StatusCode::FAILURE;
109 }
110
111 DataObject *evt;
112 m_eds->findObject(EventModel::Recon::Event,evt);
113 if (evt==NULL) {
114 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
115 return StatusCode::FAILURE;
116 }
117
118 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
119 if (!devtTds) {
120 log << MSG::ERROR << "RecMdcHitCnv:Could not downcast to TDS ReconEvent" << endreq;
121 }
122
123 IOpaqueAddress *addr;
124
125 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
127
128 const TObjArray *m_recMdcHitCol = recEvt->getRecMdcHitCol();
129 if (!m_recMdcHitCol) return StatusCode::SUCCESS;
130 recEvt->clearRecMdcHitCol(); //necessary in case there is I/O at the same time since array is static
131
132 RecMdcHitCol::const_iterator recMdcHit;
133 for (recMdcHit = mdcHitColTds->begin(); recMdcHit != mdcHitColTds->end(); recMdcHit++) {
134 Bool_t isGrouped =(*recMdcHit)->isGrouped();
135 Int_t id =(*recMdcHit)->getId();
136 Int_t trackId =(*recMdcHit)->getTrkId();
137 Double_t driftDistLeft =(*recMdcHit)->getDriftDistLeft();
138 Double_t driftDistRight =(*recMdcHit)->getDriftDistRight();
139 Double_t errDriftDistLeft =(*recMdcHit)->getErrDriftDistLeft();
140 Double_t errDriftDistRight =(*recMdcHit)->getErrDriftDistRight();
141 Double_t chisqAdd =(*recMdcHit)->getChisqAdd();
142 Int_t flagLR =(*recMdcHit)->getFlagLR();
143 Int_t stat =(*recMdcHit)->getStat();
144 UInt_t mdcId =(*recMdcHit)->getMdcId().get_value();
145 Double_t tdc =(*recMdcHit)->getTdc();
146 Double_t adc =(*recMdcHit)->getAdc();
147 Double_t driftT =(*recMdcHit)->getDriftT();
148 Double_t doca =(*recMdcHit)->getDoca();
149 Double_t entra =(*recMdcHit)->getEntra();
150 Double_t zhit =(*recMdcHit)->getZhit();
151 Double_t fltLen =(*recMdcHit)->getFltLen();
152
153 TRecMdcHit *recMdcHitRoot = new TRecMdcHit();
154 //m_common.m_recMdcHitMap[(*recMdcHit)] = recMdcHitRoot;
155
156 recMdcHitRoot->setIsGrouped( isGrouped );
157 recMdcHitRoot->setId( id );
158 recMdcHitRoot->setTrkId( trackId );
159 recMdcHitRoot->setDriftDistLeft( driftDistLeft );
160 recMdcHitRoot->setDriftDistRight( driftDistRight );
161 recMdcHitRoot->setErrDriftDistLeft( errDriftDistLeft );
162 recMdcHitRoot->setErrDriftDistRight( errDriftDistRight );
163 log<<MSG::INFO<<" recMdcHitRoot.ddl: "<<recMdcHitRoot->getDriftDistLeft()
164 <<" recMdcHitRoot.erddl: "<<recMdcHitRoot->getErrDriftDistLeft()
165 <<endreq;
166 recMdcHitRoot->setChisqAdd( chisqAdd );
167 recMdcHitRoot->setFlagLR( flagLR );
168 recMdcHitRoot->setStat( stat );
169 recMdcHitRoot->setMdcId( mdcId );
170 recMdcHitRoot->setTdc( tdc );
171 recMdcHitRoot->setAdc( adc );
172 recMdcHitRoot->setDriftT( driftT );
173 recMdcHitRoot->setDoca( doca );
174 recMdcHitRoot->setEntra( entra );
175 recMdcHitRoot->setZhit( zhit );
176 recMdcHitRoot->setFltLen( fltLen );
177
178 recEvt->addRecMdcHit(recMdcHitRoot);
179 }
180 return StatusCode::SUCCESS;
181}
182#endif
ObjectVector< RecMdcHit > RecMdcHitCol
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to 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 addRecMdcHit(TRecMdcHit *Hit)
Add a Rec Mdc Hit into the Mdc data collection.
void clearRecMdcHitCol()
clear the whole array (necessary because of the consts-s)
const TObjArray * getRecMdcHitCol() const
retrieve the whole TObjArray of RecMdcHit Data
static std::map< const TObject *, const RecMdcHit * > m_rootRecMdcHitMap