BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
PackedRawDataCnvSvc.cxx
Go to the documentation of this file.
1//====================================================================
2// PackedRawDataCnvSvc.cpp
3//--------------------------------------------------------------------
4//
5// Package : AsciiFile Conversion Service
6//
7//====================================================================
8
9static const char* rcsid = "$Id: PackedRawDataCnvSvc.cxx,v 1.23 2010/10/20 07:16:09 zoujh Exp $";
10
11// Include files
12#include "GaudiKernel/MsgStream.h"
13#include "GaudiKernel/ConversionSvc.h"
14#include "GaudiKernel/ISvcLocator.h"
15#include "GaudiKernel/SmartDataPtr.h"
16
20
42
43using namespace std;
44
45static const InterfaceID IID_IRawDataBaseCnv("IRawDataBaseCnv", 1 , 0);
46
47/// Standard constructor
48PackedRawDataCnvSvc::PackedRawDataCnvSvc(const std::string& name, ISvcLocator* svc)
50{
51 declareProperty("RawDataOutputSvc", m_ioSvcName);
52 declareProperty("Status", m_status=0xFFFFFFFF); //fucd
53}
54
55/// Standard Destructor
57{}
58
59/// Initialize the service.
61 MsgStream log(messageService(), name());
62 log << MSG::INFO << name() << " PackedRawDataCnvSvc::initialize RawDataOutputSvc:" << m_ioSvcName<< endreq;
63
64 StatusCode sc = RawDataCnvSvc::initialize();
65 if( sc.isFailure() ) {
66 log << MSG::ERROR << "Unable to initialize service " << endreq;
67 return sc;
68 }
69
70 IService* svc ;
71 sc = service(m_ioSvcName, svc);
72 if (sc != StatusCode::SUCCESS ) {
73 log << MSG::WARNING << "Cant get RawDataOutputSvc " << endreq;
74 //return sc ;
75 }
76
77 m_ioSvc = dynamic_cast<IRawDataOutputSvc*> (svc);
78 if (m_ioSvc == 0 ) {
79 log << MSG::WARNING << "Cant cast to RawDataOutputSvc " << endreq;
80 //return StatusCode::FAILURE;
81 }
82
83 return StatusCode::SUCCESS;
84}
85
86/// Add converters to the service
88 MsgStream log(messageService(), name());
89 //log << MSG::INFO << name() << " PackedRawDataCnvSvc::addConverters" << endreq;
90 declareObject(IRawDataCnvSvc::Leaf(EventModel::EventH, RawDataCnv::classID(), "PASS", 0));
91 //log << MSG::INFO << "EventModel::EventH " << RawDataCnv::classID() << endreq;
92 declareObject(IRawDataCnvSvc::Leaf(EventModel::EventHeader, RawDataEvtHeaderCnv::classID(), "PASS", 0));
93 //log << MSG::INFO << "EventModel::EventHeader " << RawDataEvtHeaderCnv::classID() << endreq;
110
111 return StatusCode::SUCCESS;
112}
113
114/// Update state of the service
115StatusCode PackedRawDataCnvSvc::updateServiceState(IOpaqueAddress* pAddress) {
116 MsgStream log(messageService(), name());
117 StatusCode sc = RawDataCnvSvc::updateServiceState(pAddress);
118 //log << MSG::INFO << "In PackedRawDataCnvSvc::updateServiceState" << endreq;
119 return sc;
120}
121
122StatusCode PackedRawDataCnvSvc::queryInterface(const InterfaceID& riid, void** ppvInterface) {
123 if ( IID_IRawDataBaseCnv == riid ) {
124 *ppvInterface = (IRawDataCnvSvc*)this;
125 } else {
126 // Interface is not directly availible: try out a base class
127 return ConversionSvc::queryInterface(riid, ppvInterface);
128 }
129 addRef();
130 return StatusCode::SUCCESS;
131}
132
133StatusCode PackedRawDataCnvSvc::connectOutput(const std::string& /* t */)
134{
135
136 MsgStream log(messageService(), name() );
137
138 log << MSG::DEBUG << " In connectOutput "<< endreq;
139
140 // Get DataObj from TDS
141 SmartDataPtr<Event::EventHeader> evt(dataProvider(), EventModel::EventHeader);
142 if (!evt) {
143 log << MSG::ERROR << "Did not retrieve event" << endreq;
144 return StatusCode::FAILURE;
145 }
146 unsigned int eventNo = evt->eventNumber();
147 unsigned int runNo = evt->runNumber();
148
149 m_rawEvent = new WriteRawEvent(0x790000, // source_id
150 eventNo, // global_id
151 runNo, // run_no
152 eventNo, // lel1_id
153 0, // lel1_type
154 0, // lel2_info
155 ef_info // ef_info
156 );
157 //const unsigned int status = 0; // place holder for status
158 if(m_status!=0xFFFFFFFF) m_rawEvent->status(1, &m_status);
159 else m_rawEvent->status(0, NULL); //fucd
160
161 return StatusCode::SUCCESS;
162}
163
164StatusCode PackedRawDataCnvSvc::commitOutput(const std::string& /* t*/ , bool /*b*/ )
165{
166 MsgStream log(messageService(), name() );
167
168 log << MSG::DEBUG << "In flushOutput" << endreq;
169
170 if (!m_ioSvc) {
171 log << MSG::ERROR << "RawDataCnvSvc not configure for output" << endreq;
172 return StatusCode::FAILURE;
173 }
174
175 /*if (!m_rawEvent->is_valid()) {
176 log << MSG::ERROR << "commitOutput failed, because FullEventFragment invalid"
177 << m_rawEvent << endreq;
178 return StatusCode::FAILURE;
179 }*/
180
181 log << MSG::DEBUG << "commitOutput: Size of Event (words) ="
182 << m_rawEvent->size_word() << endreq;
183
184 if (!m_ioSvc->putEvent(m_rawEvent) ) {
185 log << MSG::ERROR << "commitOutput failed to send output" << endreq;
186 return StatusCode::FAILURE;
187 }
188
189 // delete ...
190 const eformat::write::SubDetectorFragment* sd = m_rawEvent->first_child();
191 while ( sd != 0) {
192 const eformat::write::ROSFragment* ros = sd->first_child();
193 while (ros != 0) {
194 const eformat::write::ROBFragment* rob = ros->first_child();
195 while (rob != 0) {
196 const eformat::write::ROBFragment* rob_tmp = rob;
197 rob = rob->next();
198 delete rob_tmp;
199 }
200 const eformat::write::ROSFragment* ros_tmp = ros;
201 ros = ros->next();
202 delete ros_tmp;
203 }
204 const eformat::write::SubDetectorFragment* sd_tmp = sd;
205 sd = sd->next();
206 delete sd_tmp;
207 }
208 delete m_rawEvent;
209
210 return StatusCode::SUCCESS;
211}
212
unsigned const long PACKEDRAWEVENT_StorageType
Definition: ClassID_temp.h:17
int runNo
int eventNo
eformat::write::FullEventFragment WriteRawEvent
Definition: RawEvent.h:9
The event conversion service needs an additional interface used by the converters to declare their ob...
virtual bool putEvent(WriteRawEvent *re)=0
PackedRawDataCnvSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
virtual StatusCode commitOutput(const std::string &t, bool b)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Override inherited queryInterface.
virtual StatusCode initialize()
Initialize the service.
virtual StatusCode connectOutput(const std::string &t)
virtual StatusCode addConverters()
Add converters to the service.
virtual ~PackedRawDataCnvSvc()
Standard Destructor.
virtual StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
StatusCode updateServiceState(IOpaqueAddress *pAddress)
Update state of the service.
virtual StatusCode initialize()
virtual StatusCode declareObject(const IRawDataCnvSvc::Leaf &leaf)
Associates a path on TDS with a particular converter.
static const CLID & classID()
Definition: RawDataCnv.cxx:83
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
static const CLID & classID()
void status(uint32_t n, const uint32_t *status)
const SubDetectorFragment * first_child(void) const
void next(const ROBFragment *n)
const ROSFragment * next(void) const
const ROBFragment * first_child(void) const
const ROSFragment * first_child(void) const
const SubDetectorFragment * next(void) const
_EXTERN_ std::string Event
Definition: EventModel.h:56
_EXTERN_ std::string MdcDigiCol
Definition: EventModel.h:57
_EXTERN_ std::string MucDigiCol
Definition: EventModel.h:60
_EXTERN_ std::string LumiDigiCol
Definition: EventModel.h:61
_EXTERN_ std::string EmcDigiCol
Definition: EventModel.h:58
_EXTERN_ std::string TofDigiCol
Definition: EventModel.h:59
_EXTERN_ std::string Event
Definition: EventModel.h:72
_EXTERN_ std::string HltRawCol
Definition: EventModel.h:73
_EXTERN_ std::string EmcMcHitCol
Definition: EventModel.h:46
_EXTERN_ std::string MucMcHitCol
Definition: EventModel.h:47
_EXTERN_ std::string MdcMcHitCol
Definition: EventModel.h:44
_EXTERN_ std::string TofMcHitCol
Definition: EventModel.h:45
_EXTERN_ std::string McParticleCol
Definition: EventModel.h:41
_EXTERN_ std::string Event
Definition: EventModel.h:39
_EXTERN_ std::string Event
Definition: EventModel.h:66
_EXTERN_ std::string TrigGTDCol
Definition: EventModel.h:67