CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_RootCnvSvc-04-01-14/src/Digi/CgemDigiCnv.cxx
Go to the documentation of this file.
1#ifndef CgemDigiCnv_CXX
2#define CgemDigiCnv_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 "RawEvent/DigiEvent.h" //TDS object
12#include "CgemRawEvent/CgemDigi.h" //TDS object
13#include "RootEventData/TCgemDigi.h" // standard root object
14#include "RootEventData/TDigiEvent.h"
15#include "RootCnvSvc/Digi/DigiCnv.h"
16#include "RootCnvSvc/Digi/CgemDigiCnv.h"
17#include "RootCnvSvc/RootAddress.h"
18
19
20// Instantiation of a static factory class used by clients to create
21// instances of this service
22//static CnvFactory<CgemDigiCnv> s_factory;
23//const ICnvFactory& CgemDigiCnvFactory = s_factory;
24
25CgemDigiCnv::CgemDigiCnv(ISvcLocator* svc)
26: RootEventBaseCnv(classID(), svc)
27{
28 // Here we associate this converter with the /Event path on the TDS.
29 MsgStream log(msgSvc(), "CgemDigiCnv");
30//myModify
31 log << MSG::INFO << "My Message::CgemDigiCnv:RootEventBaseCnv" << endreq;
32
33 //log << MSG::DEBUG << "Constructor called for " << objType() << endreq;
34 m_rootBranchname ="m_cgemDigiCol";
35 //declareObject(EventModel::Digi::CgemDigiCol, objType(), m_rootTreename, m_rootBranchname);
36 m_adresses.push_back(&m_cgemDigiCol);
37 m_cgemDigiCol=0;
38
39//myModify
40 log << MSG::INFO << "My Message::CgemDigiCnv:RootEventBaseCnv-finished" << endreq;
41
42}
43
44StatusCode CgemDigiCnv::TObjectToDataObject(DataObject*& refpObject) {
45 // creation of TDS object from root object
46
47 MsgStream log(msgSvc(), "CgemDigiCnv");
48//myModify
49 log << MSG::INFO << "My Message::CgemDigiCnv::TObjectToDataObject()" << endreq;
50
51 log << MSG::DEBUG << "CgemDigiCnv::TObjectToDataObject" << endreq;
52 StatusCode sc=StatusCode::SUCCESS;
53
54 // create the TDS location for the CgemDigi Collection
55 CgemDigiCol* cgemDigiTdsCol = new CgemDigiCol;
56 refpObject=cgemDigiTdsCol;
57// sc = m_eds->registerObject(EventModel::Digi::CgemDigiCol, cgemDigiTdsCol);
58// if (sc.isFailure()) {
59// log << "Failed to register CgemDigi Collection" << endreq;
60// return StatusCode::FAILURE;
61// }
62
63 // now convert
64 if (!m_cgemDigiCol) return sc;
65 TIter cgemDigiIter(m_cgemDigiCol);
66 TCgemDigi *cgemDigiRoot = 0;
67 while ((cgemDigiRoot = (TCgemDigi*)cgemDigiIter.Next()))
68 {
69 unsigned int id = cgemDigiRoot->getIntId();
70 unsigned int time = cgemDigiRoot->getTimeChannel();
71 unsigned int charge = cgemDigiRoot->getChargeChannel();
72 unsigned int overflow = cgemDigiRoot->getOverflow();
73 unsigned int trackIndex = cgemDigiRoot->getTrackIndex();
74
75 CgemDigi *cgemDigiTds = new CgemDigi(id);
76 m_common.m_rootCgemDigiMap[cgemDigiRoot] = cgemDigiTds;
77
78 //myModify
79 log << MSG::INFO << "My Message::CgemDigiCnv::TObjectToDataObject: "
80 << "id=" << id
81 << ",time=" << time
82 << ",charge=" << charge
83 << ",overflow=" << overflow << endreq;
84
85 cgemDigiTds->setTimeChannel(time);
86 cgemDigiTds->setChargeChannel(charge);
87 cgemDigiTds->setOverflow(overflow);
88 cgemDigiTds->setTrackIndex(trackIndex);
89
90 cgemDigiTdsCol->push_back(cgemDigiTds);
91 }
92 //m_cgemDigiCol->Delete(); // wensp add 2005/12/30
93 delete m_cgemDigiCol;
94 m_cgemDigiCol = 0;
95
96 //myModify
97 log << MSG::INFO << "My Message::CgemDigiCnv::TObjectToDataObject()-finished" << endreq;
98
99 return StatusCode::SUCCESS;
100}
101
102StatusCode CgemDigiCnv::DataObjectToTObject(DataObject* obj,RootAddress* rootaddr) {
103
104 MsgStream log(msgSvc(), "CgemDigiCnv");
105 //myModify
106 log << MSG::INFO << "My Message::CgemDigiCnv::DataObjectToTObject()" << endreq;
107
108 log << MSG::DEBUG << "CgemDigiCnv::DataObjectToTObject" << endreq;
109 StatusCode sc=StatusCode::SUCCESS;
110
111 CgemDigiCol * cgemDigiColTds=dynamic_cast<CgemDigiCol *> (obj);
112 if (!cgemDigiColTds) {
113 log << MSG::ERROR << "Could not downcast to CgemDigiCol" << endreq;
114 //myModify
115 log << MSG::INFO << "My Message::CgemDigiCnv::DataObjectToTObject()-finished" << endreq;
116
117 return StatusCode::FAILURE;
118 }
119
120 DataObject *evt;
121 m_eds->findObject(EventModel::Digi::Event,evt);
122 if (evt==NULL) {
123 log << MSG::ERROR << "Could not get DigiEvent in TDS " << endreq;
124//myModify
125 log << MSG::INFO << "My Message::CgemDigiCnv::DataObjectToTObject()-finished" << endreq;
126
127 return StatusCode::FAILURE;
128 }
129 DigiEvent * devtTds=dynamic_cast<DigiEvent *> (evt);
130 if (!devtTds) {
131//myModify
132 log << MSG::INFO << "My Message::CgemDigiCnv::DataObjectToTObject()-finished" << endreq;
133
134 log << MSG::ERROR << "CgemDigiCnv:Could not downcast to TDS DigiEvent" << endreq;
135 }
136
137 IOpaqueAddress *addr;
138
139
140 m_cnvSvc->getDigiCnv()->createRep(evt,addr);
141
142 //createRep(evt,addr);
143
145
146 const TObjArray *m_cgemDigiCol = recEvt->getCgemDigiCol();
147 if (!m_cgemDigiCol) return sc;
148 recEvt->clearCgemDigiCol(); //necessary in case there is I/O at the same time since array is static
149 CgemDigiCol::const_iterator cgemDigiTds;
150
151 for (cgemDigiTds=cgemDigiColTds->begin(); cgemDigiTds!=cgemDigiColTds->end(); cgemDigiTds++)
152 {
153 UInt_t overflow = (*cgemDigiTds)->getOverflow();
154 UInt_t time = (*cgemDigiTds)->getTimeChannel();
155 UInt_t charge = (*cgemDigiTds)->getChargeChannel();
156 UInt_t id = (*cgemDigiTds)->getIntId();
157 Int_t trackIndex = (*cgemDigiTds)->getTrackIndex();
158
159 TCgemDigi *cgemDigiRoot = new TCgemDigi();
160 //m_common.m_cgemDigiMap[(*cgemDigiTds)] = cgemDigiRoot;
161 //myModify
162 log << MSG::INFO << "My Message::CgemDigiCnv::DataObjectToTObject: "
163 << "id=" << id
164 << ",time=" << time
165 << ",charge=" << charge
166 << ",overflow=" << overflow << endreq;
167
168 cgemDigiRoot->initialize(id, time ,charge);
169 cgemDigiRoot->setOverflow(overflow);
170 cgemDigiRoot->setTrackIndex(trackIndex);
171 recEvt->addCgemDigi(cgemDigiRoot);
172 }
173
174 //myModify
175 log << MSG::INFO << "My Message::CgemDigiCnv::DataObjectToTObject()-finished" << endreq;
176
177 return StatusCode::SUCCESS;
178}
179
180#endif
Double_t time
virtual StatusCode DataObjectToTObject(DataObject *obj, RootAddress *addr)
transformation to root
virtual StatusCode TObjectToDataObject(DataObject *&obj)
transformation from root
static TDigiEvent * getWriteObject()
returns object to be written (maintained here for all DIGI-converters)
void setTrackIndex(const int trackIndex)
Definition: RawData.cxx:35
void setChargeChannel(const unsigned int chargeChannel)
Definition: RawData.cxx:30
void setTimeChannel(const unsigned int timeChannel)
Definition: RawData.cxx:25
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 setOverflow(const UInt_t overflow)
void clearCgemDigiCol()
clear the whole array (necessary because of the consts-s)
const TObjArray * getCgemDigiCol() const
retrieve the whole TObjArray of TkrDigi Data
void addCgemDigi(TCgemDigi *digi)
Add a TkrDigi into the TKR data collection.
void initialize(UInt_t id, UInt_t time=0, UInt_t charge=0)
void setTrackIndex(const int trackIndex)
static std::map< const TObject *, const CgemDigi * > m_rootCgemDigiMap