BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
TofRec Class Reference

#include <TofRec.h>

+ Inheritance diagram for TofRec:

Public Member Functions

 TofRec (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode beginRun ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
void clearTofTrackVec (std::vector< TofTrack * > *&tofTrackVec)
 
 TofRec (const std::string &name, ISvcLocator *pSvcLocator)
 
StatusCode initialize ()
 
StatusCode beginRun ()
 
StatusCode execute ()
 
StatusCode finalize ()
 
void clearTofTrackVec (std::vector< TofTrack * > *&tofTrackVec)
 

Detailed Description

Definition at line 17 of file InstallArea/include/TofRec/TofRec/TofRec.h.

Constructor & Destructor Documentation

◆ TofRec() [1/2]

TofRec::TofRec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 49 of file TofRec.cxx.

49 :
50 Algorithm(name, pSvcLocator)
51{
52 declareProperty( "AcceleratorStatus", m_acceleratorStatus );
53 declareProperty( "MagneticField", m_magneticField );
54 declareProperty( "ForCalibration", m_forCalibration );
55 declareProperty( "Data", m_data );
56 declareProperty( "CalibData", m_calibData );
57 // declareProperty( "CalibDataBarrel", m_calibDataBarrel );
58 declareProperty( "FirstIteration", m_firstIteration );
59 declareProperty( "CheckTrigger", m_checkTrigger );
60 declareProperty( "SaveRootFile4Rec", m_saveRootFile );
61 declareProperty( "PrintOutInfo", m_printOutInfo );
62 declareProperty( "CheckDigi", m_checkDigi );
63 declareProperty( "CheckDigiRaw", m_checkDigiRaw );
64 declareProperty( "CheckDigiExt", m_checkDigiExt );
65 declareProperty( "CheckMcTruth", m_checkMcTruth );
66}

◆ TofRec() [2/2]

TofRec::TofRec ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Member Function Documentation

◆ beginRun() [1/2]

StatusCode TofRec::beginRun ( )

Definition at line 180 of file TofRec.cxx.

180 {
181 MsgStream log(msgSvc(), name());
182 log << MSG::INFO <<"TofRec begin_run!"<< endreq;
183 return StatusCode::SUCCESS;
184}

◆ beginRun() [2/2]

StatusCode TofRec::beginRun ( )

◆ clearTofTrackVec() [1/2]

void TofRec::clearTofTrackVec ( std::vector< TofTrack * > *&  tofTrackVec)

Definition at line 652 of file TofRec.cxx.

652 {
653 if( tofTrackVec ) {
654 std::vector<TofTrack*>::iterator iter = tofTrackVec->begin();
655 for( ; iter < tofTrackVec->end(); iter++ ) {
656 delete (*iter);
657 }
658 tofTrackVec->clear();
659 delete tofTrackVec;
660 }
661 return;
662}
EvtStreamInputIterator< typename Generator::result_type > iter(Generator gen, int N=0)

Referenced by execute().

◆ clearTofTrackVec() [2/2]

void TofRec::clearTofTrackVec ( std::vector< TofTrack * > *&  tofTrackVec)

◆ execute() [1/2]

StatusCode TofRec::execute ( )

Definition at line 188 of file TofRec.cxx.

188 {
189
190 MsgStream log(msgSvc(), name());
191 log << MSG::INFO << "TofRec in execute()!" << endreq;
192
193 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc(),"/Event/EventHeader");
194 if( !eventHeader ) {
195 log << MSG::FATAL << "TofRec could not find Event Header!" << endreq;
196 return StatusCode::FAILURE;
197 }
198 int run = eventHeader->runNumber();
199 int event = eventHeader->eventNumber();
200 if( ( event % 1000 == 0 ) && m_printOutInfo ) {
201 std::cout << "run:" << run << " event: " << event << std::endl;
202 }
203 log << MSG::INFO << "run= " << run << " event= " << event << endreq;
204
205 TofRecTDS tds;
207
208 // Magnetic Field: Colliding data and Cosmic Ray
209 if( m_acceleratorStatus == "Colliding" ) {
210 // Retrieve Event Start Time
211 SmartDataPtr<RecEsTimeCol> estimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
212 if( !estimeCol || ( estimeCol->size() == 0 ) ) {
213 log << MSG::WARNING << "TofRec Could not find RecEsTimeCol! Run = " << run << " Event = " << event << endreq;
214 return StatusCode::SUCCESS;
215 }
216 RecEsTimeCol::iterator iter_ESTime=estimeCol->begin();
217 double t0 = (*iter_ESTime)->getTest();
218 int t0Stat = (*iter_ESTime)->getStat();
219 log << MSG::INFO << "t0= " << t0 << " t0Stat= " << t0Stat << endreq;
220
221 // Kalman Filter Track
222 SmartDataPtr<RecMdcKalTrackCol> mdcKalTrackCol(eventSvc(),"/Event/Recon/RecMdcKalTrackCol");
223 if( !mdcKalTrackCol ) {
224 log << MSG::WARNING << "No MdcKalTrackCol in TDS! Run = " << run << " Event = " << event << endreq;
225 return StatusCode::SUCCESS;
226 }
227 SmartDataPtr<RecMdcTrackCol> mdcTrackCol(eventSvc(),"/Event/Recon/RecMdcTrackCol");
228 if( !mdcTrackCol ) {
229 log << MSG::FATAL << "Could NOT find RecMdcTrackCol in TDS! Run = " << run << " Event = " << event << endreq;
230 return StatusCode::SUCCESS;
231 }
232
233 // Tof Get Extrapolated Track
234 SmartDataPtr<RecExtTrackCol> extTrackCol(eventSvc(),"/Event/Recon/RecExtTrackCol");
235 if( !extTrackCol ) {
236 log << MSG::WARNING << "No ExtTrackCol in TDS! Run = " << run << " Event = " << event << endreq;
237 return StatusCode::SUCCESS;
238 }
239 else {
240 if( m_printOutInfo ) { m_printOut->setExtTrackNum( extTrackCol->size() ); }
241 if( m_checkDigi && m_checkDigiExt ) { m_checkdigi_tuple->FillCol( *eventHeader, mdcTrackCol, mdcKalTrackCol, extTrackCol ); }
242 }
243
244 //sunss add 08/9/17
245 if( m_forCalibration ) { // Bhabha Events Selection
246 if( m_printOutInfo ) { m_printOut->addNumber(0); }
247 // if( t0Stat != 111 && t0Stat != 121 ) return StatusCode::SUCCESS;
248 if( t0Stat%10 != 1 ) return StatusCode::SUCCESS;
249 if( m_printOutInfo ) { m_printOut->addNumber(1); }
250
251 if( extTrackCol->size() != 2 ) return StatusCode::SUCCESS;
252 if( m_printOutInfo ) { m_printOut->addNumber(2); }
253
254 if( mdcTrackCol->size() != 2 ) return StatusCode::SUCCESS;
255 if( m_printOutInfo ) { m_printOut->addNumber(3); }
256
257 SmartDataPtr<RecEmcShowerCol> emcShowerCol(eventSvc(),"/Event/Recon/RecEmcShowerCol");
258 if( !emcShowerCol ) {
259 log << MSG::FATAL << "Could NOT find EmcRecShowerCol in TDS! Run = " << run << " Event = " << event << endreq;
260 return StatusCode::SUCCESS;
261 }
262 if( m_printOutInfo ) { m_printOut->addNumber(4); }
263
264 if( emcShowerCol->size() < 2 ) return StatusCode::SUCCESS;
265 if( m_printOutInfo ) { m_printOut->addNumber(5); }
266
267 RecMdcTrackCol::iterator iter_mdc1 = mdcTrackCol->begin();
268 RecMdcTrackCol::iterator iter_mdc2 = mdcTrackCol->begin() + 1;
269
270 RecMdcKalTrackCol::iterator iter_kal1 = mdcKalTrackCol->begin();
271 RecMdcKalTrackCol::iterator iter_kal2 = mdcKalTrackCol->begin() + 1;
272
273 RecExtTrackCol::iterator iter_ext1 = extTrackCol->begin();
274 RecExtTrackCol::iterator iter_ext2 = extTrackCol->begin() + 1;
275 Hep3Vector extPos1 = (*iter_ext1)->emcPosition();
276 Hep3Vector extPos2 = (*iter_ext2)->emcPosition();
277
278 RecEmcShowerCol::iterator iter_emc1 = emcShowerCol->begin();
279 RecEmcShowerCol::iterator iter_emc2 = emcShowerCol->begin() + 1;
280 Hep3Vector emcPos1((*iter_emc1)->x(),(*iter_emc1)->y(),(*iter_emc1)->z());
281 Hep3Vector emcPos2((*iter_emc2)->x(),(*iter_emc2)->y(),(*iter_emc2)->z());
282
283 Hep3Vector pep = (*iter_mdc1)->p3();
284 Hep3Vector pem = (*iter_mdc2)->p3();
285 double delta_angle = 180.0 - pep.angle( pem.unit() )*180.0/pi;
286 double delta_phi = abs( (*iter_mdc1)->phi() - (*iter_mdc2)->phi() )*180.0/pi;
287
288 Hep3Vector distant1 = extPos1 - emcPos1;
289 Hep3Vector distant2 = extPos2 - emcPos1;
290 if( distant1.r() > distant2.r() ) {
291 RecEmcShowerCol::iterator iter_tmp = iter_emc1;
292 iter_emc1 = iter_emc2;
293 iter_emc2 = iter_tmp;
294 Hep3Vector emc_tmp = emcPos1;
295 emcPos1 = emcPos2;
296 emcPos2 = emc_tmp;
297 }
298 distant1 = extPos1 - emcPos1;
299 distant2 = extPos2 - emcPos2;
300
301 double p1 = (*iter_mdc1)->p();
302 double p2 = (*iter_mdc2)->p();
303 double e1 = (*iter_emc1)->energy();
304 double e2 = (*iter_emc2)->energy();
305 double etot = 0.0;
306 RecEmcShowerCol::iterator iter_emc = emcShowerCol->begin();
307 for( ; iter_emc != emcShowerCol->end(); iter_emc++ ) {
308 etot += (*iter_emc)->energy();
309 }
310
311 if( m_checkDigi ) { m_checkdigi_tuple->FillCol( *eventHeader, extTrackCol, mdcTrackCol, emcShowerCol, mdcKalTrackCol ); }
312
313 if( ( (*iter_mdc1)->charge() + (*iter_mdc2)->charge() )!= 0 ) return StatusCode::SUCCESS;
314 if( m_printOutInfo ) { m_printOut->addNumber(6); }
315
316 if( delta_angle > 10.0 ) return StatusCode::SUCCESS;
317 if( m_printOutInfo ) { m_printOut->addNumber(7); }
318
319 if( (*iter_kal1)->getStat(1,0)!=0 || (*iter_kal2)->getStat(1,0)!=0 ) return StatusCode::SUCCESS;
320 if( m_printOutInfo ) { m_printOut->addNumber(8); }
321
322 if( distant1.r()>6.0 || distant2.r()>6.0 ) return StatusCode::SUCCESS;
323 if( m_printOutInfo ) { m_printOut->addNumber(9); }
324
325 // Jpsi data taken in 2009
326 if( m_data == "jpsi09" ) {
327 if( (*iter_mdc1)->x()<-0.2 || (*iter_mdc1)->x()>0.4 || (*iter_mdc1)->y()<-0.5 || (*iter_mdc1)->y()>0.1 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
328 if( m_printOutInfo ) { m_printOut->addNumber(10); }
329 if( (*iter_mdc2)->x()<-0.2 || (*iter_mdc2)->x()>0.4 || (*iter_mdc2)->y()<-0.5 || (*iter_mdc2)->y()>0.1 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
330 if( m_printOutInfo ) { m_printOut->addNumber(11); }
331 if( delta_phi<174.0 || delta_phi>186.0 ) return StatusCode::SUCCESS;
332 if( m_printOutInfo ) { m_printOut->addNumber(12); }
333 if( m_calibData == "Bhabha" ) {
334 if( e1 < 1.1 || e2 < 1.1 ) return StatusCode::SUCCESS;
335 if( m_printOutInfo ) { m_printOut->addNumber(13); }
336 }
337 }
338 // Psi prime data taken in 2009
339 else if( m_data == "psip09" ) {
340 if( (*iter_mdc1)->x()<-0.2 || (*iter_mdc1)->x()>0.4 || (*iter_mdc1)->y()<-0.5 || (*iter_mdc1)->y()>0.1 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
341 if( m_printOutInfo ) { m_printOut->addNumber(10); }
342 if( (*iter_mdc2)->x()<-0.2 || (*iter_mdc2)->x()>0.4 || (*iter_mdc2)->y()<-0.5 || (*iter_mdc2)->y()>0.1 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
343 if( m_printOutInfo ) { m_printOut->addNumber(11); }
344 if( delta_phi<174.0 || delta_phi>183.0 ) return StatusCode::SUCCESS;
345 if( m_printOutInfo ) { m_printOut->addNumber(12); }
346 if( m_calibData == "Bhabha" ) {
347 if( e1 < 1.4 || e2 < 1.4 ) return StatusCode::SUCCESS;
348 if( m_printOutInfo ) { m_printOut->addNumber(13); }
349 }
350 }
351 // Psi double prime data taken in first half of 2010
352 else if( m_data == "psipp10" ) {
353 if( (*iter_mdc1)->x()<-0.2 || (*iter_mdc1)->x()>1.2 || (*iter_mdc1)->y()<-0.9 || (*iter_mdc1)->y()>0.5 || abs((*iter_mdc1)->z())>6.0 ) return StatusCode::SUCCESS;
354 if( m_printOutInfo ) { m_printOut->addNumber(10); }
355 if( (*iter_mdc2)->x()<-0.2 || (*iter_mdc2)->x()>1.2 || (*iter_mdc2)->y()<-0.9 || (*iter_mdc2)->y()>0.5 || abs((*iter_mdc2)->z())>6.0 ) return StatusCode::SUCCESS;
356 if( m_printOutInfo ) { m_printOut->addNumber(11); }
357 if( delta_phi<174.0 || delta_phi>186.0 ) return StatusCode::SUCCESS;
358 if( m_printOutInfo ) { m_printOut->addNumber(12); }
359 if( m_calibData == "Bhabha" ) {
360 if( e1 < 1.4 || e2 < 1.4 ) return StatusCode::SUCCESS;
361 if( m_printOutInfo ) { m_printOut->addNumber(13); }
362 }
363 }
364 // Psi double prime data taken in end of 2010 and 2011
365 else if( m_data == "psipp11" ) {
366 if( (*iter_mdc1)->x()<-0.15 || (*iter_mdc1)->x()>0.3 || (*iter_mdc1)->y()<-0.3 || (*iter_mdc1)->y()>0.15 || abs((*iter_mdc1)->z())>6.0 ) return StatusCode::SUCCESS;
367 if( m_printOutInfo ) { m_printOut->addNumber(10); }
368 if( (*iter_mdc2)->x()<-0.15 || (*iter_mdc2)->x()>0.3 || (*iter_mdc2)->y()<-0.3 || (*iter_mdc2)->y()>0.15 || abs((*iter_mdc2)->z())>6.0 ) return StatusCode::SUCCESS;
369 if( m_printOutInfo ) { m_printOut->addNumber(11); }
370 if( delta_phi<174.0 || delta_phi>184.0 ) return StatusCode::SUCCESS;
371 if( m_printOutInfo ) { m_printOut->addNumber(12); }
372 if( m_calibData == "Bhabha" ) {
373 if( e1 < 1.4 || e2 < 1.4 ) return StatusCode::SUCCESS;
374 if( m_printOutInfo ) { m_printOut->addNumber(13); }
375 }
376 }
377 // Psi prime data taken in end of 2011 and 2012
378 else if( m_data == "psip12" ) {
379 if( (*iter_mdc1)->x()<-0.25 || (*iter_mdc1)->x()>0.3 || (*iter_mdc1)->y()<-0.3 || (*iter_mdc1)->y()>0.15 || abs((*iter_mdc1)->z())>6.0 ) return StatusCode::SUCCESS;
380 if( m_printOutInfo ) { m_printOut->addNumber(10); }
381 if( (*iter_mdc2)->x()<-0.25 || (*iter_mdc2)->x()>0.3 || (*iter_mdc2)->y()<-0.3 || (*iter_mdc2)->y()>0.15 || abs((*iter_mdc2)->z())>6.0 ) return StatusCode::SUCCESS;
382 if( m_printOutInfo ) { m_printOut->addNumber(11); }
383 if( delta_phi<172.0 || delta_phi>188.0 ) return StatusCode::SUCCESS;
384 if( m_printOutInfo ) { m_printOut->addNumber(12); }
385 if( m_calibData == "Bhabha" ) {
386 if( e1 < 1.4 || e2 < 1.4 ) return StatusCode::SUCCESS;
387 if( m_printOutInfo ) { m_printOut->addNumber(13); }
388 }
389 }
390 // Jpsi data taken in 2012
391 else if( m_data == "jpsi12" ) {
392 if( (*iter_mdc1)->x()<-0.2 || (*iter_mdc1)->x()>0.4 || (*iter_mdc1)->y()<-0.4 || (*iter_mdc1)->y()>0.2 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
393 if( m_printOutInfo ) { m_printOut->addNumber(10); }
394 if( (*iter_mdc2)->x()<-0.2 || (*iter_mdc2)->x()>0.4 || (*iter_mdc2)->y()<-0.4 || (*iter_mdc2)->y()>0.2 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
395 if( m_printOutInfo ) { m_printOut->addNumber(11); }
396 if( delta_phi<172.0 || delta_phi>188.0 ) return StatusCode::SUCCESS;
397 if( m_printOutInfo ) { m_printOut->addNumber(12); }
398 if( m_calibData == "Bhabha" ) {
399 if( e1 < 1.1 || e2 < 1.1 ) return StatusCode::SUCCESS;
400 if( m_printOutInfo ) { m_printOut->addNumber(13); }
401 }
402 }
403 // Y(4260) and Y(4360) taken in 2013
404 else if( m_data == "psi13" ) {
405 if( (*iter_mdc1)->x()<-0.15 || (*iter_mdc1)->x()>0.35 || (*iter_mdc1)->y()<-0.35 || (*iter_mdc1)->y()>0.15 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
406 if( m_printOutInfo ) { m_printOut->addNumber(10); }
407 if( (*iter_mdc2)->x()<-0.15 || (*iter_mdc2)->x()>0.35 || (*iter_mdc2)->y()<-0.35 || (*iter_mdc2)->y()>0.15 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
408 if( m_printOutInfo ) { m_printOut->addNumber(11); }
409 if( delta_phi<172.0 || delta_phi>188.0 ) return StatusCode::SUCCESS;
410 if( m_printOutInfo ) { m_printOut->addNumber(12); }
411 if( m_calibData == "Bhabha" ) {
412 if( e1 < 1.5 || e2 < 1.5 ) return StatusCode::SUCCESS;
413 if( m_printOutInfo ) { m_printOut->addNumber(13); }
414 }
415 }
416 else if( m_data == "rxyz14" ) {
417 if( (*iter_mdc1)->x()<-0.15 || (*iter_mdc1)->x()>0.35 || (*iter_mdc1)->y()<-0.35 || (*iter_mdc1)->y()>0.15 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
418 if( m_printOutInfo ) { m_printOut->addNumber(10); }
419 if( (*iter_mdc2)->x()<-0.15 || (*iter_mdc2)->x()>0.35 || (*iter_mdc2)->y()<-0.35 || (*iter_mdc2)->y()>0.15 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
420 if( m_printOutInfo ) { m_printOut->addNumber(11); }
421 if( delta_phi<175.0 || delta_phi>185.0 ) return StatusCode::SUCCESS;
422 if( m_printOutInfo ) { m_printOut->addNumber(12); }
423 if( m_calibData == "Bhabha" ) {
424 if( e1/p1 < 0.75 || e2/p2 < 0.75 ) return StatusCode::SUCCESS;
425 if( m_printOutInfo ) { m_printOut->addNumber(13); }
426 }
427 }
428 else if( m_data == "r15" ) {
429 if( (*iter_mdc1)->x()<-0.15 || (*iter_mdc1)->x()>0.35 || (*iter_mdc1)->y()<-0.35 || (*iter_mdc1)->y()>0.15 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
430 if( m_printOutInfo ) { m_printOut->addNumber(10); }
431 if( (*iter_mdc2)->x()<-0.15 || (*iter_mdc2)->x()>0.35 || (*iter_mdc2)->y()<-0.35 || (*iter_mdc2)->y()>0.15 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
432 if( m_printOutInfo ) { m_printOut->addNumber(11); }
433 if( delta_phi<175.0 || delta_phi>185.0 ) return StatusCode::SUCCESS;
434 if( m_printOutInfo ) { m_printOut->addNumber(12); }
435 if( m_calibData == "Bhabha" ) {
436 if( e1/p1 < 0.75 || e2/p2 < 0.75 ) return StatusCode::SUCCESS;
437 if( m_printOutInfo ) { m_printOut->addNumber(13); }
438 }
439 }
440 else if( m_data == "data16" ) {
441 if( (*iter_mdc1)->x()<-0.15 || (*iter_mdc1)->x()>0.35 || (*iter_mdc1)->y()<-0.35 || (*iter_mdc1)->y()>0.2 || abs((*iter_mdc1)->z())>4.0 ) return StatusCode::SUCCESS;
442 if( m_printOutInfo ) { m_printOut->addNumber(10); }
443 if( (*iter_mdc2)->x()<-0.15 || (*iter_mdc2)->x()>0.35 || (*iter_mdc2)->y()<-0.35 || (*iter_mdc2)->y()>0.2 || abs((*iter_mdc2)->z())>4.0 ) return StatusCode::SUCCESS;
444 if( m_printOutInfo ) { m_printOut->addNumber(11); }
445 if( delta_phi<170.0 || delta_phi>190.0 ) return StatusCode::SUCCESS;
446 if( m_printOutInfo ) { m_printOut->addNumber(12); }
447 if( m_calibData == "Bhabha" ) {
448 if( e1/p1 < 0.75 || e2/p2 < 0.75 ) return StatusCode::SUCCESS;
449 if( m_printOutInfo ) { m_printOut->addNumber(13); }
450 }
451 }
452
453 if( m_calibData == "Bhabha" ) {
454 if( ( etot - e1 - e2 ) > 0.3 ) return StatusCode::SUCCESS;
455 if( m_printOutInfo ) { m_printOut->addNumber(14); }
456 }
457 else if( m_calibData == "Dimu" ) {
458 if( e1 > 0.5 || e2 > 0.5 )return StatusCode::SUCCESS;
459 if( m_printOutInfo ) { m_printOut->addNumber(13); }
460 }
461 }
462 //sunss add 08/9/17
463
464 TofTrackVec* tofTrackVec = new TofTrackVec;
465 RecExtTrackCol::iterator iter_track = extTrackCol->begin();
466 for( ; iter_track < extTrackCol->end(); iter_track++ ) {
467 RecMdcTrackCol::iterator iter_mdc = mdcTrackCol->begin();
468 for( ; iter_mdc != mdcTrackCol->end(); iter_mdc++ ) {
469 if( (*iter_mdc)->trackId() == (*iter_track)->trackId() ) break;
470 }
471 double costheta = cos( (*iter_mdc)->theta() );
472 RecMdcKalTrackCol::iterator iter_kal = mdcKalTrackCol->begin();
473 for( ; iter_kal != mdcKalTrackCol->end(); iter_kal++ ) {
474 if( (*iter_kal)->trackId() == (*iter_track)->trackId() ) break;
475 }
476 double p[5] = {-1.0};
477 int kal[5] = {-1};
478 if( iter_kal != mdcKalTrackCol->end() ) {
479 for( unsigned int i=0; i<5; i++ ) {
480 if( i==0 ) { (*iter_kal)->setPidType(RecMdcKalTrack::electron); }
481 else if( i==1 ) { (*iter_kal)->setPidType(RecMdcKalTrack::muon); }
482 else if( i==2 ) { (*iter_kal)->setPidType(RecMdcKalTrack::pion); }
483 else if( i==3 ) { (*iter_kal)->setPidType(RecMdcKalTrack::kaon); }
484 else if( i==4 ) { (*iter_kal)->setPidType(RecMdcKalTrack::proton); }
485 p[i] = (*iter_kal)->p3().mag();
486 kal[i] = (*iter_kal)->getStat(0,i);
487 }
488 }
489 TofTrack* tof = new TofTrack( run, event );
490 tof->setExtTrack( (*iter_track), costheta, p, kal, t0, t0Stat );
491
492 if( tofTrackVec->size()>0 ) {
493 std::vector<TofTrack*>::iterator iterExt = tofTrackVec->begin();
494 for( ; iterExt < tofTrackVec->end(); iterExt++ ) {
495 if( (*iterExt)->isNoHit() ) continue;
496 tof->getMultiHit( *iterExt );
497 }
498 }
499
500 tofTrackVec->push_back( tof );
501 }
502
503 if( m_printOutInfo ) {
504 m_printOut->setTrack1Col( tofTrackVec );
505 }
506
507 // Retrieve Tof Digi Data
508 TofDataMap tofDataMap = tofDigiSvc->tofDataMapTof( t0 );
509 if( tofDataMap.empty() ) {
510 log << MSG::WARNING << "No Tof Data Map in RawDataProviderSvc! Run=" << run << " Event=" << event << endreq;
511 }
512
513 if( m_checkDigi && m_checkDigiRaw ) {
514 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc(),"/Event/Digi/TofDigiCol");
515 if( !tofDigiCol ) {
516 log << MSG::ERROR << "TofRec could not find Tof digi! Event = " << event << endreq;
517 }
518 else { m_checkdigi_tuple->FillCol( *eventHeader, tofDigiCol, t0, t0Stat ); }
519
520 m_checkdigi_tuple->FillCol( *eventHeader, tofDataMap, t0, t0Stat );
521 }
522
523 std::vector<int> deadId;
524 if( m_forCalibration ) {
525 for( unsigned int i=0; i<5; i++ ) {
526 int identmp = tofCaliSvc->BrEast(i);
527 if( identmp != 0x2fffffff ) {
528 deadId.push_back( identmp );
529 }
530 identmp = tofCaliSvc->BrWest(i);
531 if( identmp != 0x2fffffff ) {
532 deadId.push_back( identmp );
533 }
534 identmp = tofCaliSvc->Endcap(i);
535 if( identmp != 0x2fffffff ) {
536 deadId.push_back( identmp );
537 }
538 }
539 }
540
541 std::vector<TofTrack*>::iterator iter = tofTrackVec->begin();
542 for( ; iter < tofTrackVec->end(); iter++ ) {
543 if( (*iter)->isNoHit() ) continue;
544 (*iter)->setTofData( tofDataMap );
545 if( m_printOutInfo ) { m_printOut->setTrack2( (*iter) ); }
546 if( (*iter)->isNoHit() ) continue;
547 (*iter)->match( m_forCalibration, deadId, tofTrackVec );
548 if( m_printOutInfo ) { m_printOut->setTrack3( (*iter) ); }
549 }
550
551 iter = tofTrackVec->begin();
552 for( ; iter < tofTrackVec->end(); iter++ ) {
553
554 (*iter)->setCalibration();
555
556 if( m_checkDigi ) {
557 if( m_checkTrigger ) {
558 // retrieve trigger data for physics analysis
559 SmartDataPtr<TrigData> trigData(eventSvc(), "/Event/Trig/TrigData");
560 if (!trigData) {
561 log << MSG::FATAL << "Could not find Trigger Data for physics analysis" << endreq;
562 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *iter, t0, t0Stat );
563 }
564 else {
565 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *iter, t0, t0Stat, trigData );
566 }
567 }
568 else {
569 if( ( run < 0 ) && m_checkMcTruth ) {
570 SmartDataPtr<TofMcHitCol> tofMcCol(eventSvc(),"/Event/MC/TofMcHitCol");
571 SmartDataPtr<McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
572 if ( !tofMcCol || !mcParticleCol ) {
573 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *iter, t0, t0Stat, mdcKalTrackCol );
574 }
575 else {
576 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *iter, t0, t0Stat, mdcKalTrackCol, tofMcCol, mcParticleCol, m_calibData );
577 }
578 }
579 else {
580 m_checkdigi_tuple->Fill_TofTrack( *eventHeader, *iter, t0, t0Stat, mdcKalTrackCol );
581 }
582 }
583 }
584 }
585
586 tds.RegisterTDS( eventHeader->runNumber(), eventHeader->eventNumber(), tofTrackVec, m_forCalibration, m_calibData );
587
588 clearTofTrackVec( tofTrackVec );
589
590// Check RecTofTrackCol Registered
591 SmartDataPtr<RecTofTrackCol> tofTrackCol(eventSvc(),"/Event/Recon/RecTofTrackCol");
592 if (!tofTrackCol) {
593 log << MSG::FATAL << "TofRec could not find RecTofTrackCol!" << endreq;
594 return StatusCode::FAILURE;
595 }
596 else{
597 if( m_saveRootFile ) {
598 m_checkdata_tuple->FillCol( *eventHeader, tofTrackCol, mdcKalTrackCol );
599 }
600 }
601
602 if( m_forCalibration ) {
603 SmartDataPtr<RecBTofCalHitCol> bhitCol(eventSvc(),"/Event/Recon/RecBTofCalHitCol");
604 if (!bhitCol) {
605 log << MSG::WARNING << "TofRec could not find RecBTofCalHitCol!" << endreq;
606 }
607 else {
608 if( m_saveRootFile ) {
609 m_checkdata_tuple->FillCol( *eventHeader, bhitCol );
610 }
611 }
612
613 SmartDataPtr<RecETofCalHitCol> ehitCol(eventSvc(),"/Event/Recon/RecETofCalHitCol");
614 if (!ehitCol) {
615 log << MSG::WARNING << "TofRec could not find RecETofCalHitCol!" << endreq;
616 }
617 else {
618 if( m_saveRootFile ) {
619 m_checkdata_tuple->FillCol( *eventHeader, ehitCol );
620 }
621 }
622 }
623
624 }
625 else {
626 log << MSG::FATAL << "In TofRec: AcceleratorStatus is NOT correct! m_acceleratorStatus = " << m_acceleratorStatus << endreq;
627 return StatusCode::FAILURE;
628 }
629
630 return StatusCode::SUCCESS;
631
632}
Double_t etot
Double_t e1
Double_t e2
double cos(const BesAngle a)
std::vector< TofTrack * > TofTrackVec
IRawDataProviderSvc * tofDigiSvc
ITofCaliSvc * tofCaliSvc
virtual TofDataMap & tofDataMapTof(double estime=0)=0
virtual const int BrWest(unsigned int No)=0
virtual const int BrEast(unsigned int No)=0
virtual const int Endcap(unsigned int No)=0
void FillCol(Event::EventHeader &, RecTofTrackCol &, RecMdcKalTrackCol &)
void Fill_TofTrack(Event::EventHeader &, TofTrack *&, double, int)
void FillCol(Event::EventHeader &, TofDigiCol &, double, int)
void setExtTrackNum(unsigned int ntrk)
Definition: TofCount.cxx:92
void setTrack1Col(std::vector< TofTrack * > *&tofTrackVec)
Definition: TofCount.cxx:111
void addNumber(unsigned int i)
Definition: TofCount.cxx:207
void setTrack3(TofTrack *&tof)
Definition: TofCount.cxx:135
void setTrack2(TofTrack *&tof)
Definition: TofCount.cxx:120
StatusCode RegisterTDS(int runNumber, int eventNumber, std::vector< TofTrack * > *&tofTrackVec, bool m_forCalibration, std::string m_calibData)
Definition: TofRecTDS.cxx:58
StatusCode RegisterNullRecTofTrackCol()
Definition: TofRecTDS.cxx:22
void clearTofTrackVec(std::vector< TofTrack * > *&tofTrackVec)
Definition: TofRec.cxx:652
void getMultiHit(TofTrack *&)
Definition: TofTrack.cxx:404
void setExtTrack(RecExtTrack *extTrack, double costheta, double p[5], int kal[5], double t0, int t0Stat)
Definition: TofTrack.cxx:145

◆ execute() [2/2]

StatusCode TofRec::execute ( )

◆ finalize() [1/2]

StatusCode TofRec::finalize ( )

Definition at line 636 of file TofRec.cxx.

636 {
637 if( m_printOutInfo ) {
638 if( m_forCalibration ) {
639 m_printOut->finalBhabha( m_calibData );
640 }
641 m_printOut->final();
642 delete m_printOut;
643 }
644 if( m_checkDigi ) delete m_checkdigi_tuple;
645 if( m_saveRootFile ) delete m_checkdata_tuple;
646 return StatusCode::SUCCESS;
647}
void finalBhabha(std::string calibData)
Definition: TofCount.cxx:215
void final()
Definition: TofCount.cxx:182

◆ finalize() [2/2]

StatusCode TofRec::finalize ( )

◆ initialize() [1/2]

StatusCode TofRec::initialize ( )

Definition at line 70 of file TofRec.cxx.

70 {
71
72 MsgStream log(msgSvc(), name());
73 log << MSG::INFO << "TofRec in initialize()" << endreq;
74
75 //Get TOF Geomertry Service
76 StatusCode scg = service("TofGeomSvc", tofGeomSvc);
77 if (scg== StatusCode::SUCCESS) {
78 log << MSG::INFO << "TofRec Get Geometry Service Sucessfully!" << endreq;
79 }else {
80 log << MSG::ERROR << "TofRec Get Geometry Service Failed !" << endreq;
81 return StatusCode::FAILURE;
82 }
83
84 //Get TOF Calibtration Service
85 StatusCode scc = service("TofCaliSvc", tofCaliSvc);
86 if (scc == StatusCode::SUCCESS) {
87 log << MSG::INFO << "TofRec Get Calibration Service Sucessfully!" << endreq;
88 } else {
89 log << MSG::ERROR << "TofRec Get Calibration Service Failed !" << endreq;
90 return StatusCode::FAILURE;
91 }
92
93 //Get TOF Raw Data Provider Service
94 StatusCode scd = service("RawDataProviderSvc", tofDigiSvc);
95 if (scd == StatusCode::SUCCESS) {
96 log << MSG::INFO << "TofRec Get Tof Raw Data Service Sucessfully!" << endreq;
97 } else {
98 log << MSG::ERROR << "TofRec Get Tof Raw Data Service Failed !" << endreq;
99 return StatusCode::FAILURE;
100 }
101
102 if( m_checkDigi ) {
103 NTuplePtr nt11(ntupleSvc(),"FILE203/digi");
104 NTuplePtr nt12(ntupleSvc(),"FILE203/barrel");
105 NTuplePtr nt13(ntupleSvc(),"FILE203/endcap");
106 NTuplePtr nt14(ntupleSvc(),"FILE203/mrpc");
107 NTuplePtr nt15(ntupleSvc(),"FILE203/ext");
108 NTuplePtr nt16(ntupleSvc(),"FILE203/tof");
109 NTuplePtr nt17(ntupleSvc(),"FILE203/bb");
110
111 if( nt11 || nt12 || nt13 || nt14 || nt15 || nt16 || nt17) {
112 m_tuple_digi = nt11;
113 m_tuple_barrel = nt12;
114 m_tuple_endcap = nt13;
115 m_tuple_endcap = nt14;
116 m_tuple_ext = nt15;
117 m_tuple_tof = nt16;
118 m_tuple_bb = nt17;
119 }
120 else {
121 m_tuple_digi = ntupleSvc()->book("FILE203/digi",CLID_ColumnWiseTuple,"TofRec");
122 m_tuple_barrel = ntupleSvc()->book("FILE203/barrel",CLID_ColumnWiseTuple,"TofRec");
123 m_tuple_endcap = ntupleSvc()->book("FILE203/endcap",CLID_ColumnWiseTuple,"TofRec");
124 m_tuple_mrpc = ntupleSvc()->book("FILE203/mrpc",CLID_ColumnWiseTuple,"TofRec");
125 m_tuple_ext = ntupleSvc()->book("FILE203/ext",CLID_ColumnWiseTuple,"TofRec");
126 m_tuple_tof = ntupleSvc()->book("FILE203/tof",CLID_ColumnWiseTuple,"TofRec");
127 m_tuple_bb = ntupleSvc()->book("FILE203/bb",CLID_ColumnWiseTuple,"TofRec");
128
129 if( m_tuple_digi || m_tuple_barrel || m_tuple_endcap || m_tuple_mrpc || m_tuple_ext || m_tuple_tof || m_tuple_bb ) {
130 m_checkdigi_tuple = new TofCheckDigi( m_tuple_digi, m_tuple_barrel, m_tuple_endcap, m_tuple_mrpc, m_tuple_ext, m_tuple_tof, m_tuple_bb );
131 }
132 else {
133 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_digi) <<endmsg;
134 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_barrel) <<endmsg;
135 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_endcap) <<endmsg;
136 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_mrpc) <<endmsg;
137 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_ext) <<endmsg;
138 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_tof) <<endmsg;
139 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_bb) <<endmsg;
140 return StatusCode::FAILURE;
141 }
142 }
143 }
144
145 if( m_saveRootFile ) {
146 NTuplePtr nt21(ntupleSvc(),"FILE201/trk");
147 NTuplePtr nt22(ntupleSvc(),"FILE201/cbtrk");
148 NTuplePtr nt23(ntupleSvc(),"FILE201/cetrk");
149 NTuplePtr nt24(ntupleSvc(),"FILE201/cetftrk");
150
151 if( nt21 || nt22 || nt23 || nt24 ) {
152 m_tuple_trk = nt21;
153 m_tuple_cbtrk = nt22;
154 m_tuple_cetrk = nt23;
155 m_tuple_cetftrk = nt24;
156 }
157 else {
158 m_tuple_trk = ntupleSvc()->book("FILE201/trk",CLID_ColumnWiseTuple,"TofRec");
159 m_tuple_cbtrk = ntupleSvc()->book("FILE201/cbtrk",CLID_ColumnWiseTuple,"TofRec");
160 m_tuple_cetrk = ntupleSvc()->book("FILE201/cetrk",CLID_ColumnWiseTuple,"TofRec");
161 m_tuple_cetftrk = ntupleSvc()->book("FILE201/cetftrk",CLID_ColumnWiseTuple,"TofRec");
162 if( m_tuple_trk || m_tuple_cbtrk || m_tuple_cetrk || m_tuple_cetftrk) {
163 m_checkdata_tuple = new TofCheckData( m_tuple_trk, m_tuple_cbtrk, m_tuple_cetrk, m_tuple_cetftrk );
164 }
165 else {
166 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_trk) <<endmsg;
167 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_cbtrk) <<endmsg;
168 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_cetrk) <<endmsg;
169 log << MSG::ERROR <<"Cannot book N-tuple:" << long(m_tuple_cetftrk) <<endmsg;
170 return StatusCode::FAILURE;
171 }
172 }
173 }
174
175 if( m_printOutInfo ) { m_printOut = new TofCount; }
176
177 return StatusCode::SUCCESS;
178}
ITofGeomSvc * tofGeomSvc
Definition: TofRec.cxx:43

◆ initialize() [2/2]

StatusCode TofRec::initialize ( )

The documentation for this class was generated from the following files: