BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
WriteRawData.cxx
Go to the documentation of this file.
1// Include files.
2#include <vector>
3#include "WriteRawData.h"
4#include "GaudiKernel/MsgStream.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/PropertyMgr.h"
7#include "GaudiKernel/SmartDataPtr.h"
8#include "RawDataCnv/EventManagement/RAWEVENT.h"
9#include "GaudiKernel/IDataProviderSvc.h"
10#include "GaudiKernel/IDataManagerSvc.h"
11
12// Event Model related classes
13#include "EventModel/Event.h"
14#include "RawEvent/DigiEvent.h"
15#include "MdcRawEvent/MdcDigi.h"
16#include "EmcRawEvent/EmcDigi.h"
17#include "TofRawEvent/TofDigi.h"
18#include "MucRawEvent/MucDigi.h"
19
20#include "EventModel/EventModel.h"
21
22using namespace std;
23
24// Constructor.
25WriteRawData::WriteRawData(const string& name, ISvcLocator* pSvcLocator)
26 : Algorithm(name, pSvcLocator)
27{}
28
29// WriteRawData::initialize().
31{
32
33 MsgStream log(msgSvc(), name());
34 m_count = 0;
35
36 log << MSG::INFO << "in initialize()" << endreq;
37
38 return StatusCode::SUCCESS;
39}
40
41// WriteRawData::execute().
43{
44 StatusCode sc;
45 MsgStream log( msgSvc(), name() );
46
47 log << MSG::INFO << "================================================" << endreq;
48 log << MSG::INFO << "In execute()" << endreq;
49 log << MSG::INFO << "++++++++++++++++++++++++++++++++++++++++++++++++" << endreq;
50
51 static int evtnum = 0;
52 static int runnum = 999;
53
54 // Create the Event header and set it as "root" of the event store
56 event->setEventNumber(evtnum++);
57 event->setRunNumber(runnum);
58
59 IDataManagerSvc* evtmgr = dynamic_cast<IDataManagerSvc*>(eventSvc());
60 sc = evtmgr->setRoot(EventModel::EventHeader , event);
61 if( sc.isFailure() ) {
62 log << MSG::ERROR << "Unable to register /Event object" << endreq;
63 return sc;
64 }
65
66 DigiEvent* digi = new DigiEvent;
67 log << MSG::INFO << " DigiEvent clID :: " << digi->clID() << endreq;
68 sc = eventSvc()->registerObject(EventModel::Digi::Event, digi);
69 if( sc.isFailure() ) {
70 log << MSG::ERROR << "Unable to register /Event/Digi object" << endreq;
71 return sc;
72 }
73
74 sc = writeMdcDigiData();
75 if( sc.isFailure() ) {
76 log << MSG::ERROR << "Unable to register /Event/Digi/MdcDigiCol object" << endreq;
77 return sc;
78 }
79
80 sc = writeEmcDigiData();
81 if( sc.isFailure() ) {
82 log << MSG::ERROR << "Unable to register /Event/Digi/EmcDigiCol object" << endreq;
83 return sc;
84 }
85
86 sc = writeTofDigiData();
87 if( sc.isFailure() ) {
88 log << MSG::ERROR << "Unable to register /Event/Digi/EmcDigiCol object" << endreq;
89 return sc;
90 }
91
92 sc = writeMucDigiData();
93 if( sc.isFailure() ) {
94 log << MSG::ERROR << "Unable to register /Event/Digi/EmcDigiCol object" << endreq;
95 return sc;
96 }
97
98 m_count++;
99
100 return StatusCode::SUCCESS;
101}
102
103StatusCode WriteRawData::writeMdcDigiData()
104{
105 int n = 10;
106 MdcDigiCol* mdcCol = new MdcDigiCol;
107 for (int i=0; i < n; i++) {
108 // Create new MdcDigi
109 MdcDigi* mdcDigi = new MdcDigi(m_count);
110 mdcDigi->setTimeChannel(8);
111 mdcDigi->setChargeChannel(10);
112 mdcDigi->setOverflow(0);
113 // And add the stuff to the container
114 mdcCol->push_back ( mdcDigi );
115 }
116
117 StatusCode sc = StatusCode::SUCCESS;
118 sc = eventSvc()->registerObject(EventModel::Digi::MdcDigiCol, mdcCol);
119 return sc;
120}
121
122StatusCode WriteRawData::writeEmcDigiData()
123{
124 int n = 10;
125 EmcDigiCol* emcCol = new EmcDigiCol;
126 for (int i=0; i < n; i++) {
127 // Create new EmcDigi
128 EmcDigi* emcDigi = new EmcDigi(m_count);
129 emcDigi->setTimeChannel(9);
130 emcDigi->setChargeChannel(9);
131 emcDigi->setMeasure(0);
132 // And add the stuff to the container
133 emcCol->push_back ( emcDigi );
134 }
135
136 StatusCode sc = StatusCode::SUCCESS;
137 sc = eventSvc()->registerObject(EventModel::Digi::EmcDigiCol, emcCol);
138 return sc;
139}
140
141StatusCode WriteRawData::writeTofDigiData()
142{
143 int n = 10;
144 TofDigiCol* tofCol = new TofDigiCol;
145 for (int i=0; i < n; i++) {
146 // Create new TofDigi
147 TofDigi* tofDigi = new TofDigi(m_count);
148 tofDigi->setTimeChannel(10);
149 tofDigi->setChargeChannel(8);
150 tofDigi->setOverflow(0);
151 // And add the stuff to the container
152 tofCol->push_back ( tofDigi );
153 }
154
155 StatusCode sc = StatusCode::SUCCESS;
156 sc = eventSvc()->registerObject(EventModel::Digi::TofDigiCol, tofCol);
157 return sc;
158}
159
160StatusCode WriteRawData::writeMucDigiData()
161{
162 int n = 10;
163 MucDigiCol* mucCol = new MucDigiCol;
164 for (int i=0; i < n; i++) {
165 // Create new MucDigi
166 MucDigi* mucDigi = new MucDigi(m_count);
167 // And add the stuff to the container
168 mucCol->push_back ( mucDigi );
169 }
170
171 StatusCode sc = StatusCode::SUCCESS;
172 sc = eventSvc()->registerObject(EventModel::Digi::MucDigiCol, mucCol);
173
174 return sc;
175}
176
177// WriteRawData::finalize().
179{
180
181 MsgStream log(msgSvc(), name());
182
183 log << MSG::INFO << "In finalize()" << endreq;
184
185 return StatusCode::SUCCESS;
186}
const Int_t n
ObjectVector< MdcDigi > MdcDigiCol
ObjectVector< MucDigi > MucDigiCol
ObjectVector< TofDigi > TofDigiCol
virtual const CLID & clID() const
Retrieve reference to class definition structure.
void setMeasure(const unsigned int measure)
void setOverflow(const unsigned int overflow)
void setChargeChannel(const unsigned int chargeChannel)
Definition: RawData.cxx:30
void setTimeChannel(const unsigned int timeChannel)
Definition: RawData.cxx:25
void setOverflow(const unsigned int overflow)
WriteRawData(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode initialize()
StatusCode execute()
StatusCode finalize()