CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
RecCgemSegmentCnv.cxx
Go to the documentation of this file.
1#ifndef RECCGEMSEGMENTCNV_CXX
2#define RECCGEMSEGMENTCNV_CXX
3
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/DataObject.h"
6#include "GaudiKernel/ObjectVector.h"
7
8#include "TClonesArray.h"
9
11
14
17
21
22#include <vector>
23
24using namespace std;
25
27 :RootEventBaseCnv(classID(), svc)
28{
29
30 MsgStream log(msgSvc(),"RecCgemSegmentCnv");
31 log << MSG::INFO << " RecCgemSegmentCnv ------ " << endreq;
32 m_rootBranchname = "m_recCgemSegmentCol";
33 m_adresses.push_back(&m_recCgemSegmentCol);
34 m_recCgemSegmentCol = 0;
35}
36StatusCode RecCgemSegmentCnv::TObjectToDataObject(DataObject*& refpObject)
37{
38 MsgStream log(msgSvc(),"RecCgemSegmentCnv");
39 log << MSG::DEBUG << "RecCgemSegmentCnv::TObjectToDataObject" << endreq;
40
41
42 RecCgemSegmentCol* recCgemSegmentCol = new RecCgemSegmentCol;
43 refpObject = recCgemSegmentCol;
44
45
46 //convert//
47 if (!m_recCgemSegmentCol) return StatusCode::SUCCESS;
48 TIter cgemSegmentIter(m_recCgemSegmentCol);
49 TRecCgemSegment *recCgemSegmentRoot = 0;
50 while ((recCgemSegmentRoot = (TRecCgemSegment*)cgemSegmentIter.Next()))
51 {
52 int clusterid_1 = recCgemSegmentRoot->getclusterid_1();
53 int clusterid_2 = recCgemSegmentRoot->getclusterid_2();
54 int clusterid_3 = recCgemSegmentRoot->getclusterid_3();
55 int eventid = recCgemSegmentRoot->geteventid();
56 int match = recCgemSegmentRoot->getmatch();
57 int segmentid = recCgemSegmentRoot->getsegmentid();
58 double helix[5];
59 double helix_err[15];
60 for(int i = 0; i < 5; i++){
61 helix[i] = (recCgemSegmentRoot)->gethelix(i);
62 }
63 for(int i = 0; i < 15; i++){
64 helix_err[i] = (recCgemSegmentRoot)->gethelix_err(i);
65 }
66
67 RecCgemSegment* recCgemSegment = new RecCgemSegment();
68 m_common.m_rootRecCgemSegmentMap[recCgemSegmentRoot] = recCgemSegment;
69
70 recCgemSegment->setclusterid_1(clusterid_1);
71 recCgemSegment->setclusterid_2(clusterid_2);
72 recCgemSegment->setclusterid_3(clusterid_3);
73 recCgemSegment->seteventid(eventid);
74 recCgemSegment->setmatch(match);
75 recCgemSegment->setsegmentid(segmentid);
76 recCgemSegment->sethelix( helix );
77 recCgemSegment->sethelix_err( helix_err );
78
79 recCgemSegmentCol->push_back(recCgemSegment);
80 }
81 return StatusCode::SUCCESS;
82}
83StatusCode RecCgemSegmentCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr)
84{
85 MsgStream log(msgSvc(), "RecCgemSegmentCnv");
86 log << MSG::DEBUG << "RecCgemSegmentCnv::DataObjectToTObject" << endreq;
87
88 RecCgemSegmentCol * cgemSegmentColTds=dynamic_cast<RecCgemSegmentCol *> (obj);
89 if (!cgemSegmentColTds) {
90 log << MSG::ERROR << "Could not downcast to RecCgemSegmentCol" << endreq;
91 return StatusCode::FAILURE;
92 }
93
94 DataObject *evt;
95 m_eds->findObject(EventModel::Recon::Event,evt);
96 if (evt==NULL) {
97 log << MSG::ERROR << "Could not get ReconEvent in TDS " << endreq;
98 return StatusCode::FAILURE;
99 }
100
101 ReconEvent * devtTds=dynamic_cast<ReconEvent *> (evt);
102 if (!devtTds) {
103 log << MSG::ERROR << "RecCgemHitCnv:Could not downcast to TDS ReconEvent" << endreq;
104 }
105
106 IOpaqueAddress *addr;
107
108 m_cnvSvc->getRecTrackCnv()->createRep(evt,addr);
110// m_cnvSvc->getRecSegmentCnv()->createRep(evt,addr);
111// TRecTrackEvent *recEvt=m_cnvSvc->getRecSegmentCnv()->getWriteObject();
112
113 const TObjArray *m_recCgemSegmentCol = recEvt->getRecCgemSegmentCol();
114 if (!m_recCgemSegmentCol) return StatusCode::SUCCESS;
115 recEvt->clearRecCgemSegmentCol();
116
117 RecCgemSegmentCol::const_iterator recCgemSegment;
118 for (recCgemSegment = cgemSegmentColTds->begin(); recCgemSegment != cgemSegmentColTds->end(); recCgemSegment++)
119 {
120 Int_t eventid = (*recCgemSegment)->geteventid();
121 Int_t match = (*recCgemSegment)->getmatch();
122 Int_t segmentid = (*recCgemSegment)->getsegmentid();
123 Int_t clusterid_1 = (*recCgemSegment)->getclusterid_1();
124 Int_t clusterid_2 = (*recCgemSegment)->getclusterid_2();
125 Int_t clusterid_3 = (*recCgemSegment)->getclusterid_3();
126 Double_t helix[5];
127 Double_t helix_err[15];
128 for(int i = 0; i < 5; i++){
129 helix[i] = (*recCgemSegment)->gethelix(i);
130 }
131 for(int i = 0; i < 15; i++){
132 helix_err[i] = (*recCgemSegment)->gethelix_err(i);
133 }
134
135 TRecCgemSegment *recCgemSegmentRoot = new TRecCgemSegment();
136
137 recCgemSegmentRoot->seteventid(eventid);
138 recCgemSegmentRoot->setmatch(match);
139 recCgemSegmentRoot->setsegmentid(segmentid);
140 recCgemSegmentRoot->setclusterid_1(clusterid_1);
141 recCgemSegmentRoot->setclusterid_2(clusterid_2);
142 recCgemSegmentRoot->setclusterid_3(clusterid_3);
143 recCgemSegmentRoot->sethelix( helix );
144 recCgemSegmentRoot->sethelix_err( helix_err );
145
146 recEvt->addRecCgemSegment(recCgemSegmentRoot);
147 }
148 return StatusCode::SUCCESS;
149}
150#endif
ObjectVector< RecCgemSegment > RecCgemSegmentCol
IMessageSvc * msgSvc()
void setclusterid_2(const int clusterId_2)
void setmatch(const int match)
void setsegmentid(const int segmentId)
void setclusterid_1(const int clusterId_1)
void seteventid(const int eventId)
void setclusterid_3(const int clusterId_3)
void sethelix(double helix[5])
void sethelix_err(double helix_err[15])
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
Do the concrete conversion from TDS to ROOT.
virtual StatusCode TObjectToDataObject(DataObject *&obj)
Do the concrete conversion from ROOT to TDS.
RecCgemSegmentCnv(ISvcLocator *svc)
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.
Int_t geteventid(void) const
void setsegmentid(Int_t segmentid)
void sethelix_err(Double_t helix_err[15])
void seteventid(Int_t eventid)
void setmatch(Int_t match)
Int_t getclusterid_3(void) const
void sethelix(Double_t helix[5])
Int_t getmatch(void) const
void setclusterid_1(Int_t clusterid_1)
Int_t getsegmentid(void) const
Int_t getclusterid_2(void) const
void setclusterid_2(Int_t clusterid_2)
void setclusterid_3(Int_t clusterid_3)
Int_t getclusterid_1(void) const
void addRecCgemSegment(TRecCgemSegment *Segment)
Add a TkrSegment into the Cgem data collection.
const TObjArray * getRecCgemSegmentCol() const
retrieve the whole TObjArray of RecCgemSegment Data
void clearRecCgemSegmentCol()
clear the whole array (necessary because of the consts-s)
static std::map< const TObject *, const RecCgemSegment * > m_rootRecCgemSegmentMap
Definition: commonData.h:247
_EXTERN_ std::string Event
Definition: EventModel.h:90