BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
DstEventMaker.cxx
Go to the documentation of this file.
1#include "DstEventMaker.h"
2
3#include "CLHEP/Matrix/SymMatrix.h"
4#include "CLHEP/Matrix/Vector.h"
5#include "CLHEP/Vector/ThreeVector.h"
6#include "GaudiKernel/IDataProviderSvc.h"
7#include "GaudiKernel/ISvcLocator.h"
8#include "GaudiKernel/MsgStream.h"
9#include "GaudiKernel/PropertyMgr.h"
10#include "GaudiKernel/SmartDataPtr.h"
11#include <cmath>
12#include <cstdlib>
13#include <iostream>
14#include <map>
15#include <vector>
16
17#include "DstEvent/DstEmcShower.h"
18#include "DstEvent/DstEvent.h"
19#include "DstEvent/DstExtTrack.h" // track extrapolation add 2005-09-02
20#include "DstEvent/DstMdcDedx.h"
21#include "DstEvent/DstMdcKalTrack.h" //Mdc Kal add 2005-09-24
22#include "DstEvent/DstMdcTrack.h"
23#include "DstEvent/DstMucTrack.h"
24#include "DstEvent/DstTofTrack.h"
25#include "EmcRecEventModel/RecEmcShower.h"
26#include "EventModel/Event.h"
27#include "EventModel/EventHeader.h"
28#include "EventModel/EventModel.h"
29#include "ExtEvent/RecExtTrack.h" // track extrapolation add 2005-09-02
30#include "MdcRecEvent/RecMdcDedx.h"
31#include "MdcRecEvent/RecMdcDedxHit.h"
32#include "MdcRecEvent/RecMdcHit.h"
33#include "MdcRecEvent/RecMdcKalTrack.h" // Mdc Kal Add 2005-09-24
34#include "MdcRecEvent/RecMdcTrack.h"
35#include "MucRecEvent/MucRecHit.h"
36#include "MucRecEvent/RecMucTrack.h"
37#include "TofRecEvent/RecTofTrack.h"
38
39using namespace std;
40using namespace Event;
41// using CLHEP::HepVector;
42using CLHEP::Hep3Vector;
43using CLHEP::HepSymMatrix;
44
45// typedef std::vector<MdcRecHit*> HitRefVec;
46
47/////////////////////////////////////////////////////////////////////////////
49DstEventMaker::DstEventMaker( const std::string& name, ISvcLocator* pSvcLocator )
50 : Algorithm( name, pSvcLocator ) {}
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
54
55 MsgStream log( msgSvc(), name() );
56 log << MSG::INFO << "in initialize()" << endmsg;
57
58 return StatusCode::SUCCESS;
59}
60
61// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
63
64 MsgStream log( msgSvc(), name() );
65 log << MSG::INFO << "in execute()" << endmsg;
66
67 // Part 1: Get the event header, print out event and run number
68
69 SmartDataPtr<Event::EventHeader> eventHeader( eventSvc(), "/Event/EventHeader" );
70 if ( !eventHeader )
71 {
72 log << MSG::FATAL << "Could not find Event Header" << endmsg;
73 return ( StatusCode::FAILURE );
74 }
75
76 int eventId = eventHeader->eventNumber();
77 int runId = eventHeader->runNumber();
78 log << MSG::INFO << "DstEventMaker: retrieved event: "
79 << " Event Number " << eventId << " run: " << runId << endmsg;
80
81 StatusCode sc = StatusCode::SUCCESS;
82 int trackID;
83
84 // register ReconEvent Data Object to TDS; 2005/09/14
85 DstEvent* dstEvt = new DstEvent();
86 // dstEvt->setEventId(eventId);
87 // dstEvt->setRunId(runId);
88 sc = eventSvc()->registerObject( EventModel::Dst::Event, dstEvt );
89
90 // Part 2: Retrieve Mdc Track
91 SmartDataPtr<RecMdcTrackCol> recMdcTrackCol( eventSvc(), "/Event/Recon/RecMdcTrackCol" );
92 if ( !recMdcTrackCol ) { log << MSG::INFO << "Could not find RecMdcTrackCol" << endmsg; }
93 else
94 {
95 DstMdcTrackCol* dstMdcTrackCol = new DstMdcTrackCol();
96 RecMdcTrackCol::iterator iter_mdc = recMdcTrackCol->begin();
97 trackID = 0;
98 for ( ; iter_mdc != recMdcTrackCol->end(); iter_mdc++, trackID++ )
99 {
100 DstMdcTrack* dstMdcTrack = new DstMdcTrack();
101 *dstMdcTrack = **iter_mdc;
102 ( *dstMdcTrackCol ).push_back( dstMdcTrack );
103
104 log << MSG::INFO << " Mdc Track ID = " << trackID
105 << " Mdc Track Nster = " << ( *iter_mdc )->nster() << endmsg;
106 }
107 sc = eventSvc()->registerObject( EventModel::Dst::DstMdcTrackCol, dstMdcTrackCol );
108 }
109
110 // Part 3: Retrieve Tof Track
111 SmartDataPtr<RecTofTrackCol> tofTrackCol( eventSvc(), "/Event/Recon/RecTofTrackCol" );
112 if ( !tofTrackCol ) { log << MSG::INFO << "Could not find TofTrackCol" << endmsg; }
113 else
114 {
115 DstTofTrackCol* dstTofTrackCol = new DstTofTrackCol();
116 RecTofTrackCol::iterator iter_tof = tofTrackCol->begin();
117 for ( ; iter_tof != tofTrackCol->end(); iter_tof++ )
118 {
119 DstTofTrack* dstTofTrack = new DstTofTrack();
120 *dstTofTrack = **iter_tof;
121 ( *dstTofTrackCol ).push_back( dstTofTrack );
122
123 log << MSG::INFO << "Tof Track ID = " << ( *iter_tof )->tofTrackID()
124 << " Track ID = " << ( *iter_tof )->trackID()
125 << " Tof Counter ID = " << ( *iter_tof )->tofID()
126 << " Quality = " << ( *iter_tof )->quality() << endmsg;
127 }
128 sc = eventSvc()->registerObject( EventModel::Dst::DstTofTrackCol, dstTofTrackCol );
129 }
130
131 // Part 4: Retrieve Muc Track
132 SmartDataPtr<RecMucTrackCol> mucTrackCol( eventSvc(), "/Event/Recon/RecMucTrackCol" );
133 if ( !mucTrackCol ) { log << MSG::INFO << "Could not find RecMucTrackCol" << endmsg; }
134 else
135 {
136 DstMucTrackCol* dstMucTrackCol = new DstMucTrackCol();
137 RecMucTrackCol::iterator iter_muc = mucTrackCol->begin();
138 trackID = 0;
139 for ( ; iter_muc != mucTrackCol->end(); iter_muc++, trackID++ )
140 {
141 DstMucTrack* dstMucTrack = new DstMucTrack();
142 *dstMucTrack = **iter_muc;
143 ( *dstMucTrackCol ).push_back( dstMucTrack );
144 log << MSG::INFO << "Muc Track ID = " << trackID
145 << " Muc NumHits = " << ( *iter_muc )->GetTotalHits()
146 << " Muc Pos x = " << ( *iter_muc )->getMucPos().x()
147 << " Muc Pos y = " << ( *iter_muc )->getMucPos().y()
148 << " Muc Pos z = " << ( *iter_muc )->getMucPos().z() << endmsg;
149 }
150 sc = eventSvc()->registerObject( EventModel::Dst::DstMucTrackCol, dstMucTrackCol );
151 }
152
153 // Part 5: Retrieve MdcDedx Track
154
155 SmartDataPtr<RecMdcDedxCol> mdcDedxCol( eventSvc(), "/Event/Recon/RecMdcDedxCol" );
156 if ( !mdcDedxCol ) { log << MSG::INFO << "Could not find RecMdcDedxCol" << endmsg; }
157 else
158 {
159 trackID = 0;
160 DstMdcDedxCol* dstMdcDedxCol = new DstMdcDedxCol();
161 RecMdcDedxCol::iterator iter_dedx = mdcDedxCol->begin();
162 for ( ; iter_dedx != mdcDedxCol->end(); iter_dedx++, trackID++ )
163 {
164 DstMdcDedx* dstMdcDedx = new DstMdcDedx();
165 *dstMdcDedx = **iter_dedx;
166 ( *dstMdcDedxCol ).push_back( dstMdcDedx );
167 log << MSG::INFO << " Dedx TrackID = "
168 << trackID
169 // << " Num Sigma E = " << (*iter_dedx)->getSigmaDedx(1)
170 // << " Num Sigma Mu = " << (*iter_dedx)->getSigmaDedx(2)
171 << endmsg;
172 }
173 sc = eventSvc()->registerObject( EventModel::Dst::DstMdcDedxCol, dstMdcDedxCol );
174 }
175
176 // Part 6: Retrieve Emc shower
177
178 SmartDataPtr<RecEmcShowerCol> emcRecShowerCol( eventSvc(), "/Event/Recon/RecEmcShowerCol" );
179 if ( !emcRecShowerCol )
180 {
181 log << /* MSG::FATAL*/ MSG::INFO << "Could not find RecEmcShowerCol" << endmsg;
182 // return( StatusCode::FAILURE);
183 }
184 else
185 {
186 trackID = 0;
187 DstEmcShowerCol* dstEmcTrackCol = new DstEmcShowerCol();
188 RecEmcShowerCol::iterator iter_emc = emcRecShowerCol->begin();
189 for ( ; iter_emc != emcRecShowerCol->end(); iter_emc++, trackID++ )
190 {
191 DstEmcShower* dstEmcTrack = new DstEmcShower( *( *iter_emc ) );
192 ( *dstEmcTrackCol ).push_back( dstEmcTrack );
193 log << MSG::INFO << " Emc Track Id = "
194 << trackID
195 //<< " Emc Shower Cell Id = " << (*iter_emc)->ShowerId()
196 << endmsg;
197 }
198 sc = eventSvc()->registerObject( EventModel::Dst::DstEmcShowerCol, dstEmcTrackCol );
199 }
200
201 // Part 7: Retrieve Ext shower
202
203 SmartDataPtr<RecExtTrackCol> extTrackCol( eventSvc(), "/Event/Recon/RecExtTrackCol" );
204 if ( !extTrackCol )
205 {
206 log << /* MSG::FATAL*/ MSG::INFO << "Could not find RecExtTrackCol" << endmsg;
207 // return( StatusCode::FAILURE);
208 }
209 else
210 {
211 trackID = 0;
212 DstExtTrackCol* dstExtTrackCol = new DstExtTrackCol();
213 RecExtTrackCol::iterator iter_ext = extTrackCol->begin();
214 for ( ; iter_ext != extTrackCol->end(); iter_ext++, trackID++ )
215 {
216 DstExtTrack* dstExtTrack = new DstExtTrack();
217 *dstExtTrack = **iter_ext;
218 ( *dstExtTrackCol ).push_back( dstExtTrack );
219 log << MSG::INFO << " Ext Track Id = " << trackID
220 << "volume name of Tof1 : " << ( *iter_ext )->tof1VolumeName()
221 << " Ext Tof1 Error Z = " << ( *iter_ext )->tof1PosSigmaAlongZ()
222 << " Ext Tof2 Error Z = " << ( *iter_ext )->tof2PosSigmaAlongZ()
223 << " Ext Emc Error theta = " << ( *iter_ext )->emcPosSigmaAlongTheta()
224 << " Ext Muc Error Z = " << ( *iter_ext )->mucPosSigmaAlongZ() << endmsg;
225 }
226
227 sc = eventSvc()->registerObject( EventModel::Dst::DstExtTrackCol, dstExtTrackCol );
228 }
229 // Part 8: Retrieve MdcKal track
230
231 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol( eventSvc(),
232 "/Event/Recon/RecMdcKalTrackCol" );
233 if ( !mdcKalTrackCol )
234 {
235 log << /* MSG::FATAL*/ MSG::INFO << "Could not find MdcKalTrackCol" << endmsg;
236 // return( StatusCode::FAILURE);
237 }
238 else
239 {
240 trackID = 0;
241 int nhits[5];
242 int stat[2][5];
243 float chisq[2][5];
244 int ndf[2][5];
245 int nster[2][5];
246 int fL[2][5];
247 int lL[2][5];
248
249 DstMdcKalTrackCol* dstMdcKalTrackCol = new DstMdcKalTrackCol();
250 RecMdcKalTrackCol::iterator iter_kal = mdcKalTrackCol->begin();
251 for ( ; iter_kal != mdcKalTrackCol->end(); iter_kal++, trackID++ )
252 {
253 DstMdcKalTrack* dstMdcKalTrack = new DstMdcKalTrack();
254 *dstMdcKalTrack = **iter_kal;
255
256 /*
257 for (int i=0; i<5; i++){
258 nhits[i] = (*iter_kal)->getNhits(i);
259 stat[i] = (*iter_kal)->getStat(0,i);
260 chisq[i] = (*iter_kal)->getChisq(0,i);
261 ndf[i] = (*iter_kal)->getNdf(0,i);
262 nster[i] = (*iter_kal)->getNster(0,i);
263 fL[i] = (*iter_kal)->getFirstLayer(0,i);
264 lL[i] = (*iter_kal)->getLastLayer(0,i);
265
266 dstMdcKalTrack->setNhits(nhits[i],i);
267 dstMdcKalTrack->setStat(stat[i],i);
268 dstMdcKalTrack->setChisq(chisq[i],i);
269 dstMdcKalTrack->setNdf(ndf[i],i);
270 dstMdcKalTrack->setNster(nster[i],i);
271 dstMdcKalTrack->setFirstLayer(fL[i],i);
272 dstMdcKalTrack->setLastLayer(lL[i],i);
273 }
274 dstMdcKalTrack->setTrackId((*iter_kal)->getTrackId());
275
276 for(int j=0; j<5; j++){
277 dstMdcKalTrack->setPoca((*iter_kal)->getPoca(j),j);
278 dstMdcKalTrack->setZHelix((*iter_kal)->getZHelix(j),j);
279 dstMdcKalTrack->setZError((*iter_kal)->getZError(j),j);
280 }
281
282 */
283
284 ( *dstMdcKalTrackCol ).push_back( dstMdcKalTrack );
285
286 log << MSG::INFO << " * * * * * * * * * * * * * * * * * * * * * * * * * * *" << endmsg;
287 for ( int i = 0; i < 5; i++ )
288 {
289 log << MSG::INFO << "dstMdcKalTrack ZHelix[" << i
290 << "] = " << dstMdcKalTrack->getZHelix( i ) << endmsg;
291 log << MSG::INFO << "number of total hits contained [" << i << "]" << nhits[i]
292 << endmsg;
293 log << MSG::INFO << "status flag [" << i << "]" << stat[i] << endmsg;
294 log << MSG::INFO << "dstMdcKalTrack ZError [" << i << "]"
295 << dstMdcKalTrack->getZError( i ) << endmsg;
296 log << MSG::INFO << "dstMdcKalTrack Poca [" << i << "]" << dstMdcKalTrack->getPoca( i )
297 << endmsg;
298 }
299 }
300 sc = eventSvc()->registerObject( EventModel::Dst::DstMdcKalTrackCol, dstMdcKalTrackCol );
301 }
302
303 return sc;
304}
305
306// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
308
309 MsgStream log( msgSvc(), name() );
310 log << MSG::INFO << "in finalize()" << endmsg;
311
312 return StatusCode::SUCCESS;
313}
DECLARE_COMPONENT(BesBdkRc)
ObjectVector< DstEmcShower > DstEmcShowerCol
ObjectVector< DstExtTrack > DstExtTrackCol
ObjectVector< DstMdcDedx > DstMdcDedxCol
ObjectVector< DstMdcKalTrack > DstMdcKalTrackCol
ObjectVector< DstMdcTrack > DstMdcTrackCol
ObjectVector< DstMucTrack > DstMucTrackCol
ObjectVector< DstTofTrack > DstTofTrackCol
IMessageSvc * msgSvc()
StatusCode finalize()
StatusCode initialize()
StatusCode execute()
DstEventMaker(const std::string &name, ISvcLocator *pSvcLocator)
const HepVector & getZHelix(const int pid) const
const HepSymMatrix & getZError(const int pid) const
const HepPoint3D & getPoca(const int pid) const