BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EmcTimeRec.cxx
Go to the documentation of this file.
1#include "GaudiKernel/IDataProviderSvc.h"
2#include "GaudiKernel/ISvcLocator.h"
3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/SmartDataPtr.h"
5
6#include "EmcRecEventModel/RecEmcEventModel.h"
7#include "EvTimeEvent/RecEsTime.h"
8#include "EventModel/EventHeader.h"
9
10#include "EmcTimeRec.h"
11
12using namespace std;
13using namespace Event;
14
15/////////////////////////////////////////////////////////////////////////////
17EmcTimeRec::EmcTimeRec( const std::string& name, ISvcLocator* pSvcLocator )
18 : Algorithm( name, pSvcLocator ) {
19 declareProperty( "Output", m_output = false );
20}
21
22// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
24
25 MsgStream log( msgSvc(), name() );
26 log << MSG::INFO << "in initialize()" << endmsg;
27
28 if ( m_output )
29 {
30 NTuplePtr nt( ntupleSvc(), "FILE303/n1" );
31 if ( nt ) m_tuple = nt;
32 else
33 {
34 m_tuple = ntupleSvc()->book( "FILE303/n1", CLID_ColumnWiseTuple, "EmcTimeRec" );
35 if ( m_tuple )
36 {
37 m_tuple->addItem( "emcTime", m_nt_emcTime );
38 m_tuple->addItem( "estTime", m_nt_estTime );
39 m_tuple->addItem( "corTime", m_nt_corTime );
40 m_tuple->addItem( "npart", m_nt_npart );
41 m_tuple->addItem( "ntheta", m_nt_ntheta );
42 m_tuple->addItem( "nphi", m_nt_nphi );
43 m_tuple->addItem( "e5x5", m_nt_e5x5 );
44 m_tuple->addItem( "status", m_nt_status );
45 }
46 else
47 { // did not manage to book the N tuple....
48 log << MSG::ERROR << "Cannot book N-tuple:" << long( m_tuple ) << endmsg;
49 return StatusCode::FAILURE;
50 }
51 }
52 }
53
54 return StatusCode::SUCCESS;
55}
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
58StatusCode EmcTimeRec::execute() {
59
60 MsgStream log( msgSvc(), name() );
61 log << MSG::DEBUG << "in execute()" << endmsg;
62
63 SmartDataPtr<RecEsTimeCol> estimeCol( eventSvc(), "/Event/Recon/RecEsTimeCol" );
64
65 if ( !estimeCol || ( estimeCol->size() == 0 ) )
66 {
67 log << MSG::WARNING << "Could not find RecEsTimeCol!" << endmsg;
68 return StatusCode::SUCCESS;
69 }
70
71 RecEsTimeCol::iterator iter_ESTime = estimeCol->begin();
72 double t0 = ( *iter_ESTime )->getTest(); // get t0
73
74 SmartDataPtr<RecEmcShowerCol> emcRecShowerCol( eventSvc(),
76 if ( !emcRecShowerCol )
77 {
78 log << MSG::WARNING << "Could not find RecEmcShowerCol!" << endmsg;
79 return StatusCode::SUCCESS;
80 }
81
82 RecEmcShowerCol::iterator iShowerCol;
83 for ( iShowerCol = emcRecShowerCol->begin(); iShowerCol != emcRecShowerCol->end();
84 iShowerCol++ )
85 {
86
87 if ( ( *iShowerCol )->status() >= 100 ) continue; // estTime has been subtracted
88
89 double tEmc = ( *iShowerCol )->time();
90 ( *iShowerCol )->setTime( tEmc - (int)( t0 / 50 ) );
91 ( *iShowerCol )->setStatus( ( *iShowerCol )->status() % 100 + 100 );
92
93 if ( m_output )
94 {
95 m_nt_emcTime = tEmc;
96 m_nt_estTime = (double)(int)( t0 / 50 );
97 m_nt_corTime = ( *iShowerCol )->time();
98 RecEmcID id( ( *iShowerCol )->getShowerId() );
99 m_nt_npart = EmcID::barrel_ec( id );
100 m_nt_ntheta = EmcID::theta_module( id );
101 m_nt_nphi = EmcID::phi_module( id );
102 m_nt_e5x5 = ( *iShowerCol )->e5x5();
103 m_nt_status = ( *iShowerCol )->status();
104 m_tuple->write();
105 }
106 }
107
108 return StatusCode::SUCCESS;
109}
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
113
114 MsgStream log( msgSvc(), name() );
115 log << MSG::INFO << "in finalize()" << endmsg;
116
117 return StatusCode::SUCCESS;
118}
DECLARE_COMPONENT(BesBdkRc)
INTupleSvc * ntupleSvc()
IMessageSvc * msgSvc()
static unsigned int barrel_ec(const Identifier &id)
Values of different levels (failure returns 0).
Definition EmcID.cxx:36
static unsigned int theta_module(const Identifier &id)
Definition EmcID.cxx:41
static unsigned int phi_module(const Identifier &id)
Definition EmcID.cxx:46
StatusCode finalize()
StatusCode initialize()
EmcTimeRec(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode execute()