CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
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
11#include "DstEvent/DstEvent.h" //TDS object
12#include "DstEvent/DstCgemSegment.h" //TDS object
14#include "RootEventData/TCgemSegment.h" // standard root object
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
IMessageSvc * msgSvc()
CgemSegmentCnv(ISvcLocator *svc)
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
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])
static TDstEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
Definition: DstCnv.h:36
Definition of a Root address, derived from IOpaqueAddress.
Definition: RootAddress.h:21
std::string getTreename() const
Definition: RootAddress.h:27
DstCnv * getDstCnv()
Definition: RootCnvSvc.h:148
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.
Double_t gethelix(Int_t i) const
Definition: TCgemSegment.h:22
void sethelix(Double_t helix[5])
void setclusterid_3(Int_t clusterid_3)
Definition: TCgemSegment.h:28
void setmatch(Int_t match)
Definition: TCgemSegment.h:30
void setsegmentid(Int_t segmentid)
Definition: TCgemSegment.h:31
void setclusterid_1(Int_t clusterid_1)
Definition: TCgemSegment.h:26
Int_t getclusterid_1(void) const
Definition: TCgemSegment.h:16
Int_t geteventid(void) const
Definition: TCgemSegment.h:19
void setclusterid_2(Int_t clusterid_2)
Definition: TCgemSegment.h:27
Double_t gethelix_err(Int_t i) const
Definition: TCgemSegment.h:23
Int_t getmatch(void) const
Definition: TCgemSegment.h:20
Int_t getclusterid_3(void) const
Definition: TCgemSegment.h:18
Int_t getclusterid_2(void) const
Definition: TCgemSegment.h:17
Int_t getsegmentid(void) const
Definition: TCgemSegment.h:21
void seteventid(Int_t eventid)
Definition: TCgemSegment.h:29
void sethelix_err(Double_t helix_err[15])
const TObjArray * getCgemSegmentCol() const
retrieve the whole TObjArray of CgemSegment Data
Definition: TDstEvent.h:64
void clearCgemSegmentCol()
clear the whole array (necessary because of the consts-s)
Definition: TDstEvent.h:73
void addCgemSegment(TCgemSegment *Segment)
Add a segment into the Cgem data collection.
Definition: TDstEvent.cxx:184
static std::map< const TObject *, const DstCgemSegment * > m_rootCgemSegmentMap
Definition: commonData.h:175
_EXTERN_ std::string Event
Definition: EventModel.h:146