CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_RootCnvSvc-04-01-14/src/Dst/CgemSegmentCnv.cxx
Go to the documentation of this file.
1#ifndef CgemSegmentCnv_CXX
2#define CgemSegmentCnv_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#include "DstEvent/DstEvent.h" //TDS object
12#include "DstEvent/DstCgemSegment.h" //TDS object
13#include "CgemRecEvent/RecCgemSegment.h"
14#include "RootEventData/TCgemSegment.h" // standard root object
15#include "RootEventData/TDstEvent.h"
16#include "RootCnvSvc/Dst/DstCnv.h"
17#include "RootCnvSvc/Dst/CgemSegmentCnv.h"
18#include "RootCnvSvc/RootAddress.h"
19#include <vector>
20
21using namespace std;
22
23
25: RootEventBaseCnv(classID(), svc)
26{
27 // Here we associate this converter with the /Event path on the TDS.
28 MsgStream log(msgSvc(), "CgemSegmentCnv");
29 m_rootBranchname ="m_cgemSegmentCol";
30 m_adresses.push_back(&m_cgemSegmentCol);
31 m_cgemSegmentCol=0;
32}
33
34StatusCode CgemSegmentCnv::TObjectToDataObject(DataObject*& refpObject) {
35 // creation of TDS object from root object
36 MsgStream log(msgSvc(), "CgemSegmentCnv");
37//myModify
38 log << MSG::INFO << "My Message::CgemSegmentCnv::TObjectToDataObject()"<<endreq;
39
40 log << MSG::DEBUG << "CgemSegmentCnv::TObjectToDataObject" << endreq;
41 StatusCode sc=StatusCode::SUCCESS;
42
43 // create the TDS location for the CgemSegment Collection
44 DstCgemSegmentCol* cgemSegmentTdsCol = new DstCgemSegmentCol;
45 refpObject=cgemSegmentTdsCol;
46
47 // now convert
48 if (!m_cgemSegmentCol) return sc;
49 TIter cgemSegmentIter(m_cgemSegmentCol);
50 TCgemSegment *cgemSegmentRoot = 0;
51 while ((cgemSegmentRoot = (TCgemSegment*)cgemSegmentIter.Next())) {
52
53 int segmentId = cgemSegmentRoot->getsegmentid();
54 int eventId = cgemSegmentRoot->geteventid();
55 int match = cgemSegmentRoot->getmatch();
56 int clusterId_1 = cgemSegmentRoot->getclusterid_1();
57 int clusterId_2 = cgemSegmentRoot->getclusterid_2();
58 int clusterId_3 = cgemSegmentRoot->getclusterid_3();
59 double helix[5];
60 double helix_err[15];
61 for(int i = 0; i < 5; i++){
62 helix[i] = cgemSegmentRoot->gethelix(i);
63 }
64 for(int i = 0; i < 15; i++){
65 helix_err[i] = cgemSegmentRoot->gethelix_err(i);
66 }
67
68
69 log << MSG::INFO << "My Message::CgemSegmentCnv::TObjectToDataObject::charge:"<<endreq;
70
71 DstCgemSegment *cgemSegmentTds = new DstCgemSegment();
72 m_common.m_rootCgemSegmentMap[cgemSegmentRoot] = cgemSegmentTds;
73
74 cgemSegmentTds->setsegmentid( segmentId );
75 cgemSegmentTds->seteventid( eventId );
76 cgemSegmentTds->setmatch( match );
77 cgemSegmentTds->setclusterid_1( clusterId_1 );
78 cgemSegmentTds->setclusterid_2( clusterId_2 );
79 cgemSegmentTds->setclusterid_3( clusterId_3 );
80 cgemSegmentTds->sethelix( helix );
81 cgemSegmentTds->sethelix_err( helix_err );
82
83 cgemSegmentTdsCol->push_back(cgemSegmentTds);
84
85 }
86 delete m_cgemSegmentCol;
87 m_cgemSegmentCol = 0;
88//myModify
89 log << MSG::INFO << "My Message::CgemSegmentCnv::TObjectToDataObject()-finished"<<endreq;
90
91 return StatusCode::SUCCESS;
92}
93
94StatusCode CgemSegmentCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
95
96 MsgStream log(msgSvc(), "CgemSegmentCnv");
97//myModify
98 log << MSG::INFO << "My Message::CgemSegmentCnv::DataObjectToTObject("<<rootaddr->getTreename()<<")"<<endreq;
99
100 log << MSG::DEBUG << "CgemSegmentCnv::DataObjectToTObject" << endreq;
101 StatusCode sc=StatusCode::SUCCESS;
102
103 DstCgemSegmentCol * cgemSegmentColTds=dynamic_cast<DstCgemSegmentCol *> (obj);
104 if (!cgemSegmentColTds) {
105 log << MSG::ERROR << "Could not downcast to CgemSegmentCol" << endreq;
106//myModify
107 log << MSG::INFO << "My Message::CgemSegmentCnv::DataObjectToTObject("<<rootaddr->getTreename()<<")-finished"<<endreq;
108
109 return StatusCode::FAILURE;
110 }
111
112 DataObject *evt;
113 m_eds->findObject(EventModel::Dst::Event,evt);
114 if (evt==NULL) {
115 log << MSG::ERROR << "Could not get DstEvent in TDS " << endreq;
116//myModify
117 log << MSG::INFO << "My Message::CgemSegmentCnv::DataObjectToTObject("<<rootaddr->getTreename()<<")-finished"<<endreq;
118
119 return StatusCode::FAILURE;
120 }
121 DstEvent * devtTds=dynamic_cast<DstEvent *> (evt);
122 if (!devtTds) {
123 log << MSG::ERROR << "CgemSegmentCnv:Could not downcast to TDS DstEvent" << endreq;
124 }
125 IOpaqueAddress *addr;
126
127//myModify
128 log << MSG::INFO << "My Message::CgemSegmentCnv::DataObjectToTObject("<<rootaddr->getTreename()<<")::DstCnv"<<endreq;
129
130 m_cnvSvc->getDstCnv()->createRep(evt,addr);
132
133 const TObjArray *m_cgemSegmentCol = recEvt->getCgemSegmentCol();
134 if (!m_cgemSegmentCol) return sc;
135 recEvt->clearCgemSegmentCol(); //necessary in case there is I/O at the same time since array is static
136 DstCgemSegmentCol::const_iterator cgemSegmentTds;
137
138 for (cgemSegmentTds = cgemSegmentColTds->begin(); cgemSegmentTds != cgemSegmentColTds->end(); cgemSegmentTds++) {
139 Int_t segmentId = (*cgemSegmentTds)->getsegmentid();
140 Int_t eventId = (*cgemSegmentTds)->geteventid();
141 Int_t match = (*cgemSegmentTds)->getmatch();
142 Int_t clusterId_1 = (*cgemSegmentTds)->getclusterid_1();
143 Int_t clusterId_2 = (*cgemSegmentTds)->getclusterid_2();
144 Int_t clusterId_3 = (*cgemSegmentTds)->getclusterid_3();
145 Double_t helix[5];
146 Double_t helix_err[15];
147 for(int i = 0; i < 5; i++){
148 helix[i] = (*cgemSegmentTds)->gethelix(i);
149 }
150 for(int i = 0; i < 15; i++){
151 helix_err[i] = (*cgemSegmentTds)->gethelix_err(i);
152 }
153
154 TCgemSegment *cgemSegmentRoot = new TCgemSegment();
155
156 cgemSegmentRoot->setsegmentid( segmentId );
157 cgemSegmentRoot->seteventid( eventId );
158 cgemSegmentRoot->setmatch( match );
159 cgemSegmentRoot->setclusterid_1( clusterId_1 );
160 cgemSegmentRoot->setclusterid_2( clusterId_2 );
161 cgemSegmentRoot->setclusterid_3( clusterId_3 );
162 cgemSegmentRoot->sethelix( helix );
163 cgemSegmentRoot->sethelix_err( helix_err );
164
165 recEvt->addCgemSegment(cgemSegmentRoot);
166 }
167
168//myModify
169 log << MSG::INFO << "My Message::CgemSegmentCnv::DataObjectToTObject("<<rootaddr->getTreename()<<")-finished"<<endreq;
170
171 return StatusCode::SUCCESS;
172}
173#endif
ObjectVector< DstCgemSegment > DstCgemSegmentCol
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
void sethelix(double helix[5])
void sethelix_err(double helix_err[15])
static TDstEvent * 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 sethelix_err(Double_t helix_err[15])
const TObjArray * getCgemSegmentCol() const
retrieve the whole TObjArray of CgemSegment Data
void clearCgemSegmentCol()
clear the whole array (necessary because of the consts-s)
void addCgemSegment(TCgemSegment *Segment)
Add a segment into the Cgem data collection.
static std::map< const TObject *, const DstCgemSegment * > m_rootCgemSegmentMap