BOSS 7.0.6
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcRecTDS.cxx
Go to the documentation of this file.
1
2#include "GaudiKernel/MsgStream.h"
3#include "GaudiKernel/ISvcLocator.h"
4#include "GaudiKernel/IDataProviderSvc.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/IMessageSvc.h"
7#include "GaudiKernel/StatusCode.h"
8
9#include "GaudiKernel/SmartDataPtr.h"
11#include "EmcRec/EmcRecTDS.h"
12
13using namespace std;
14
16 RecEmcClusterMap& aClusterMap, RecEmcShowerMap& aShowerMap)
17{
18 RegisterCluster(aClusterMap);
19 RegisterShower(aShowerMap);
20 RegisterHit(aHitMap);
21 return StatusCode::SUCCESS;
22}
23
25{
26 IMessageSvc* msgSvc;
27 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
28 MsgStream log(msgSvc, "EmcRecTDS");
29
30 IDataProviderSvc* eventSvc;
31 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
32
33 //check whether the Recon has been already registered
34 DataObject *aReconEvent;
35 eventSvc->findObject("/Event/Recon",aReconEvent);
36 if(aReconEvent==NULL) {
37 log << MSG::INFO << "EmcRecTDS::RegisterReconEvent()" << endreq;
38 //then register Recon
39 aReconEvent = new ReconEvent();
40 StatusCode sc = eventSvc->registerObject("/Event/Recon",aReconEvent);
41 if(sc!=StatusCode::SUCCESS) {
42 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
43 return StatusCode::FAILURE;
44 }
45 }
46
47 return StatusCode::SUCCESS;
48}
49
51{
53
54 IMessageSvc* msgSvc;
55 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
56 MsgStream log(msgSvc, "EmcRecTDS");
57 log << MSG::INFO << "EmcRecTDS::RegisterHit()" << endreq;
58
59 IDataProviderSvc* eventSvc;
60 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
61
62 RecEmcHitCol *aRecEmcHitCol = new RecEmcHitCol;
63 RecEmcHitMap::iterator iHitMap;
64 for(iHitMap=aHitMap.begin();
65 iHitMap!=aHitMap.end();
66 iHitMap++){
67 aRecEmcHitCol->add(new RecEmcHit(iHitMap->second));
68 }
69
70 //check whether the RecEmcHitCol has been already registered
71 StatusCode sc;
72 DataObject *aRecEmcHitEvent;
73 eventSvc->findObject("/Event/Recon/RecEmcHitCol", aRecEmcHitEvent);
74 if(aRecEmcHitEvent!=NULL) {
75 //then unregister RecEmcHitCol
76 sc = eventSvc->unregisterObject("/Event/Recon/RecEmcHitCol");
77 delete aRecEmcHitEvent; //it must be delete to avoid memory leakage
78 if(sc!=StatusCode::SUCCESS) {
79 log << MSG::FATAL << "Could not unregister EMC shower collection" << endreq;
80 return( StatusCode::FAILURE);
81 }
82 }
83
84 sc = eventSvc->registerObject("/Event/Recon/RecEmcHitCol", aRecEmcHitCol);
85 if(sc!=StatusCode::SUCCESS) {
86 log << MSG::FATAL << "Could not register EMC hit collection" << endreq;
87 return( StatusCode::FAILURE);
88 }
89
90 return StatusCode::SUCCESS;
91}
92
94{
96
97 IMessageSvc* msgSvc;
98 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
99 MsgStream log(msgSvc, "EmcRecTDS");
100 log << MSG::INFO << "EmcRecTDS::RegisterCluster()" << endreq;
101
102 IDataProviderSvc* eventSvc;
103 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
104
105 RecEmcClusterCol *aRecEmcClusterCol = new RecEmcClusterCol;
106 RecEmcClusterMap::iterator iClusterMap;
107 for(iClusterMap=aClusterMap.begin();
108 iClusterMap!=aClusterMap.end();
109 iClusterMap++){
110 aRecEmcClusterCol->add(new RecEmcCluster(iClusterMap->second));
111 }
112
113 //check whether the RecEmcClusterCol has been already registered
114 StatusCode sc;
115 DataObject *aRecEmcClusterEvent;
116 eventSvc->findObject("/Event/Recon/RecEmcClusterCol", aRecEmcClusterEvent);
117 if(aRecEmcClusterEvent!=NULL) {
118 //then unregister RecEmcClusterCol
119 sc = eventSvc->unregisterObject("/Event/Recon/RecEmcClusterCol");
120 delete aRecEmcClusterEvent; //it must be delete to avoid memory leakage
121 if(sc!=StatusCode::SUCCESS) {
122 log << MSG::FATAL << "Could not unregister EMC cluster collection" << endreq;
123 return( StatusCode::FAILURE);
124 }
125 }
126
127 sc = eventSvc->registerObject("/Event/Recon/RecEmcClusterCol", aRecEmcClusterCol);
128 if(sc!=StatusCode::SUCCESS) {
129 log << MSG::FATAL << "Could not register EMC cluster collection" << endreq;
130 return( StatusCode::FAILURE);
131 }
132
133 return StatusCode::SUCCESS;
134}
135
137{
139
140 IMessageSvc* msgSvc;
141 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
142 MsgStream log(msgSvc, "EmcRecTDS");
143 log << MSG::INFO << "EmcRecTDS::RegisterShower()" << endreq;
144
145 IDataProviderSvc* eventSvc;
146 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
147
148 SmartDataPtr<RecEmcClusterCol> aClusterCol(eventSvc,"/Event/Recon/RecEmcClusterCol");
149 if (!aClusterCol) {
150 log << MSG::INFO << "Could not find emcRecClusterCol" << endreq;
151 }
152
153 // ShowerMap --> Shower Container
154 RecEmcShowerCol *aRecEmcShowerCol = new RecEmcShowerCol;
155 RecEmcShowerVec aShowerVec;
156
157 RecEmcShowerMap::iterator iShowerMap;
158 for(iShowerMap=aShowerMap.begin();
159 iShowerMap!=aShowerMap.end();
160 iShowerMap++) {
161 //Find cluster in TDS
162 if(aClusterCol) {
163 RecEmcID clusterId(iShowerMap->second.getClusterId());
164 RecEmcClusterCol::iterator iClusterCol;
165 for(iClusterCol=aClusterCol->begin();
166 iClusterCol!=aClusterCol->end();
167 iClusterCol++){
168 if(clusterId==(*iClusterCol)->getClusterId()) {
169 iShowerMap->second.Cluster(*iClusterCol);
170 break;
171 //emcRecClusterCol->InsertShower(*iCluster);
172 }
173 }
174 }
175 aShowerVec.push_back(iShowerMap->second);
176 }
177 sort(aShowerVec.begin(), aShowerVec.end(), greater<RecEmcShower>());
178 RecEmcShowerVec::iterator iShowerVec;
179 for(iShowerVec=aShowerVec.begin();
180 iShowerVec!=aShowerVec.end();
181 iShowerVec++) {
182 aRecEmcShowerCol->add(new RecEmcShower(*iShowerVec));
183 }
184
185 //check whether the RecEmcShowerCol has been already registered
186 StatusCode sc;
187 DataObject *aRecEmcShowerEvent;
188 eventSvc->findObject("/Event/Recon/RecEmcShowerCol", aRecEmcShowerEvent);
189 if(aRecEmcShowerEvent!=NULL) {
190 //then unregister RecEmcShowerCol
191 StatusCode sc = eventSvc->unregisterObject("/Event/Recon/RecEmcShowerCol");
192 delete aRecEmcShowerEvent; //it must be delete to avoid memory leakage
193 if(sc!=StatusCode::SUCCESS) {
194 log << MSG::FATAL << "Could not unregister EMC shower collection" << endreq;
195 return( StatusCode::FAILURE);
196 }
197 }
198
199 sc = eventSvc->registerObject("/Event/Recon/RecEmcShowerCol", aRecEmcShowerCol);
200 if(sc!=StatusCode::SUCCESS) {
201 log << MSG::FATAL << "Could not register EMC shower collection" << endreq;
202 return( StatusCode::FAILURE);
203 }
204
205 return StatusCode::SUCCESS;
206}
207
209{
210 IMessageSvc* msgSvc;
211 Gaudi::svcLocator()->service("MessageSvc", msgSvc);
212 MsgStream log(msgSvc, "EmcRecTDS");
213 log << MSG::INFO << "EmcRecTDS::CheckRegister()" << endreq;
214
215 IDataProviderSvc* eventSvc;
216 Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
217
218 // check RecEmcHitCol registered
219 SmartDataPtr<RecEmcHitCol> aHitCol(eventSvc,"/Event/Recon/RecEmcHitCol");
220 if (!aHitCol) {
221 log << MSG::FATAL << "Could not find emcRecHitCol" << endreq;
222 return( StatusCode::FAILURE);
223 }
224
225 RecEmcHitCol::iterator iHitCol;
226 for(iHitCol=aHitCol->begin();
227 iHitCol!=aHitCol->end();
228 iHitCol++){
229 //cout<<*(*iHitCol);
230 }
231
232 // check RecEmcClusterCol registered
233 SmartDataPtr<RecEmcClusterCol> aClusterCol(eventSvc,"/Event/Recon/RecEmcClusterCol");
234 if (!aClusterCol) {
235 log << MSG::FATAL << "Could not find emcRecClusterCol" << endreq;
236 return( StatusCode::FAILURE);
237 }
238
239 RecEmcClusterCol::iterator iClusterCol;
240 for(iClusterCol=aClusterCol->begin();
241 iClusterCol!=aClusterCol->end();
242 iClusterCol++){
243 //cout<<*(*iClusterCol);
244 }
245
246 // check RecEmcShowerCol registered
247 SmartDataPtr<RecEmcShowerCol> aShowerCol(eventSvc,"/Event/Recon/RecEmcShowerCol");
248 if (!aShowerCol) {
249 log << MSG::FATAL << "Could not find emcRecShowerCol" << endreq;
250 return( StatusCode::FAILURE);
251 }
252
253 RecEmcShowerCol::iterator iShowerCol;
254 for(iShowerCol=aShowerCol->begin();
255 iShowerCol!=aShowerCol->end();
256 iShowerCol++){
257 //cout<<*(*iShowerCol);
258 }
259
260 return StatusCode::SUCCESS;
261}
map< RecEmcID, RecEmcCluster, less< RecEmcID > > RecEmcClusterMap
Definition: RecEmcCluster.h:92
ObjectVector< RecEmcCluster > RecEmcClusterCol
Definition: RecEmcCluster.h:93
ObjectVector< RecEmcHit > RecEmcHitCol
Definition: RecEmcHit.h:76
map< RecEmcID, RecEmcHit, less< RecEmcID > > RecEmcHitMap
Definition: RecEmcHit.h:75
map< RecEmcID, RecEmcShower, less< RecEmcID > > RecEmcShowerMap
Definition: RecEmcShower.h:169
ObjectVector< RecEmcShower > RecEmcShowerCol
Definition: RecEmcShower.h:171
vector< RecEmcShower > RecEmcShowerVec
Definition: RecEmcShower.h:170
IMessageSvc * msgSvc()
StatusCode RegisterCluster(RecEmcClusterMap &aClusterMap)
Definition: EmcRecTDS.cxx:93
StatusCode RegisterShower(RecEmcShowerMap &aShowerMap)
Definition: EmcRecTDS.cxx:136
StatusCode RegisterToTDS(RecEmcHitMap &aHitMap, RecEmcClusterMap &aClusterMap, RecEmcShowerMap &aShowerMap)
Definition: EmcRecTDS.cxx:15
StatusCode CheckRegister()
Definition: EmcRecTDS.cxx:208
StatusCode RegisterHit(RecEmcHitMap &aHitMap)
Definition: EmcRecTDS.cxx:50
StatusCode RegisterReconEvent()
Definition: EmcRecTDS.cxx:24