CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
RootCnvSvc-04-01-15/src/Rec/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
10#include "EventModel/EventModel.h"
11
12#include "ReconEvent/ReconEvent.h"
13#include "CgemRecEvent/RecCgemSegment.h"
14
15#include "RootEventData/TRecCgemSegment.h"
16#include "RootEventData/TRecTrackEvent.h"
17
18#include "RootCnvSvc/Rec/RecTrackCnv.h"
19#include "RootCnvSvc/Rec/RecCgemSegmentCnv.h"
20#include "RootCnvSvc/RootAddress.h"
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
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.
static TRecTrackEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition of a Root address, derived from IOpaqueAddress.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
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