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